* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a0f08; color: #f3ead8;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; }
body { position: fixed; inset: 0; width: 100%; overflow: clip; }
#app { display: flex; flex-direction: column; height: 100%; height: 100dvh;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#hud { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
#status { flex: 1; text-align: center; font-size: 18px; font-weight: 600; }
#stage { flex: 1; position: relative; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#pips { text-align: center; font-size: 13px; line-height: 16px; min-height: 28px; opacity: .7; padding: 4px 0 8px; }
button { -webkit-appearance: none; appearance: none; font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 12px 18px;
  background: linear-gradient(#e2b765, #b07f2c); color: #1d140a; font-weight: 600; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .35; cursor: default; filter: none; }
button.small { padding: 6px 12px; font-size: 18px; background: #3a2416; color: #f3ead8; }
button.ghost { background: transparent; color: #f3ead8; border: 1px solid #f3ead855; }
.overlay { position: fixed; inset: 0; background: #0b120ecc; display: flex;
  align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.hidden { display: none !important; }
.panel { background: #2e1c11; border-radius: 16px; padding: 24px; width: min(420px, 100%);
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px #000a;
  max-height: 100%; overflow: auto; }
.panel h1, .panel h2 { margin: 0 0 8px; text-align: center; }
.panel.text p { margin: 0; line-height: 1.4; font-size: 15px; }
#stats { text-align: center; opacity: .7; font-size: 14px; margin-top: 6px; }

#btnAmb.off { opacity: 0.45; }

button.small.icon { display: inline-grid; place-items: center; padding: 6px 10px; }
button.small.icon svg { display: block; width: 22px; height: 22px; }
button.icon .offLine { display: none; }
button.icon.off .offLine { display: inline; }
button.icon.off .onWaves { display: none; }
button.icon .fsOut, button.icon.on .fsIn { display: none; }
button.icon.on .fsOut { display: inline; }


#colorPick { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 2px 0 6px; color: #f3ead8; }
#colorPick button.seg { display: inline-flex; align-items: center; gap: 8px; width: auto; margin: 0; padding: 8px 14px;
  background: transparent; color: #f3ead8; border: 1px solid #f3ead855; }
#colorPick button.seg.on { background: #f3ead822; border-color: #f3ead8; }
#colorPick .dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; box-shadow: inset 0 -2px 3px #0006; }
#colorPick .dot.w { background: #efe3c4; }
#colorPick .dot.b { background: #2a1d17; border: 1px solid #f3ead855; }


#menuMain, #menuAI { display: flex; flex-direction: column; gap: 10px; }
#menuMain.hidden, #menuAI.hidden { display: none; }


#menu .panel { width: min(560px, 100%); padding: 40px 44px 32px; gap: 14px; border-radius: 22px; }
#menu .panel h1 { font-size: 44px; margin: 0 0 18px; letter-spacing: .5px; }
#menuMain, #menuAI { gap: 14px; }
#menu #menuContent > button, #menuMain > button, #menuAI > button { padding: 18px 22px; font-size: 21px; border-radius: 14px; }
#menu #colorPick { font-size: 19px; gap: 12px; margin: 0 0 6px; }
#menu #colorPick button.seg { font-size: 19px; padding: 11px 18px; }
#menu #stats { font-size: 16px; margin-top: 10px; }
#menu #btnResetStats { align-self: center; font-size: 14px; padding: 6px 14px; margin-top: 2px; opacity: .8; }

#menu { background: rgba(8, 6, 4, .78); }
.invis { visibility: hidden; }


.drinkCorner { position: absolute; left: 16px; bottom: 10%; width: 140px; text-align: center; }
.drinkCup { position: relative; display: block; width: 140px; height: 147px; padding: 0; background: none; filter: none; }
.drinkCup svg { display: block; width: 140px; height: 147px; overflow: visible; }
.drinkCup:focus-visible { outline: 2px solid #d7b56d; outline-offset: -8px; }
#drinkHint, #opponentdrinkHint { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#drinkPicker { position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); top: auto;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 9;
  width: min(340px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - 100px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid #99733f; border-radius: 14px; background: #2e1c11; box-shadow: 0 8px 24px #0008; }
#drinkPicker button { padding: 10px 16px; font-size: 14px; }
#drinkPicker button.on { outline: 2px solid #f3ead8; outline-offset: 2px; }

.drinkCup svg.steamLayer { position: absolute; left: 0; top: 0; pointer-events: none; opacity: .08; will-change: transform, opacity;
  animation: steam-rise 7s ease-in-out infinite; animation-play-state: paused; }
.drinkCup:not(.steaming) svg.steamLayer { animation: none; }
.drinkCup.steaming svg.steamLayer { animation-play-state: running; }
.drinkCup.empty svg.steamLayer { visibility: hidden; }
@keyframes steam-rise { 0%, 100% { opacity: calc(.025 * var(--steam-level, 1)); transform: translate(0, 3px); } 50% { opacity: calc(.1 * var(--steam-level, 1)); transform: translate(3px, -9px); } }
@media (prefers-reduced-motion: reduce) { .drinkCup svg.steamLayer { animation: none; } }

#opponentdrinkCorner { top: 6%; bottom: auto; }
.drinkOwnerLabel { color: #d8c7a5; font-size: 14px; }
.cupStyles { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid #99733f55; }
.cupStyles button { flex: 1; background: #463021; color: #eee3cf; }
.drinkCup:disabled { opacity: 1; cursor: default; }
.drinkChoices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.drinkSurface { transition: opacity .5s; }
@media (prefers-reduced-motion: reduce) { .drinkSurface { transition: none; } }


#menu .panel { border: 1px solid #d9a75a33; box-shadow: 0 20px 60px #000c, inset 0 1px 0 #ffffff12; }
#menu .panel h1 { color: #f6e7c8; text-shadow: 0 2px 0 #0008; }
#menuMain > button:not(.ghost), #menuAI > button:not(.ghost), #menuOnline button:not(.ghost), #menu #menuContent > #btnContinue {
  background: linear-gradient(180deg, #f2d08a 0%, #dcae5c 45%, #b9873a 100%);
  color: #2a1a08; border: 1px solid #8a5f22; letter-spacing: .3px;
  text-shadow: 0 1px 0 #fff4d655;
  box-shadow: inset 0 1px 0 #fff3d0aa, inset 0 -3px 0 #8a5f2299, 0 4px 0 #5a3a12, 0 8px 18px #0008;
  transition: transform .12s ease, box-shadow .12s ease;
}
#menuMain > button:not(.ghost):hover, #menuAI > button:not(.ghost):hover, #menuOnline button:not(.ghost):hover, #menu #menuContent > #btnContinue:hover {
  
  filter: none; background: linear-gradient(180deg, #f7da9a 0%, #e4b866 45%, #c2913f 100%); transform: translateY(-2px);
  box-shadow: inset 0 1px 0 #fff3d0aa, inset 0 -3px 0 #8a5f2299, 0 6px 0 #5a3a12, 0 12px 24px #000a;
}
#menuMain > button:not(.ghost):active, #menuAI > button:not(.ghost):active, #menuOnline button:not(.ghost):active, #menu #menuContent > #btnContinue:active {
  transform: translateY(3px);
  box-shadow: inset 0 1px 0 #fff3d066, inset 0 2px 6px #6a451a88, 0 1px 0 #5a3a12, 0 3px 8px #0008;
}
#menu button.ghost { color: #ecd3a0; border: 1px solid #d9a75a66; background: #ffffff05;
  transition: background .12s ease, border-color .12s ease; }
#menu button.ghost:hover { background: #d9a75a1a; border-color: #d9a75aaa; filter: none; }


#stage { --cupW: clamp(84px, calc(var(--side, 156px) + var(--frame, 30px) * 1.3), 170px); }
.drinkCorner { left: max(calc(var(--side, 156px) / 2), calc(var(--cupW) / 2 + 6px)); transform: translateX(-50%);
  width: var(--cupW); bottom: calc(var(--boardTop, 0px) + 6px); }
#opponentdrinkCorner { top: calc(var(--boardTop, 0px) + 6px); bottom: auto; }

#tableFooter { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 4px 12px; }
#tableFooter #pips { flex: 1; min-width: 0; min-height: 0; padding: 0; font-size: 12px; line-height: 17px; }
#drinkDock { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

#drinkCorner { width: var(--decorCupW, var(--cupW)); left: auto; right: max(calc(var(--side, 156px) / 2), calc(var(--cupW) / 2 + 6px)); transform: translateX(50%);
  bottom: calc(var(--boardTop, 0px) + var(--frame, 30px) * 1.5 + 6px); }
#btnDrink { display: grid; place-items: center; width: 48px; height: 48px; padding: 8px; border-radius: 50%;
  color: #efd6a1; background: linear-gradient(145deg, #533923, #302015); border: 1px solid #99733f;
  box-shadow: inset 0 1px 0 #ffffff12, 0 3px 9px #0005; }
#btnDrink svg { display: block; width: 32px; height: 32px; }
#btnDrink:focus-visible { outline: 2px solid #efd6a1; outline-offset: 3px; }
#btnDrink[aria-expanded="true"] { background: #62472b; border-color: #efd6a1; }
.drinkIconGlass, .drinkIconThermos { display: none; }
#btnDrink[data-vessel="glass"] .drinkIconCup, #btnDrink[data-vessel="thermos"] .drinkIconCup { display: none; }
#btnDrink[data-vessel="glass"] .drinkIconGlass, #btnDrink[data-vessel="thermos"] .drinkIconThermos { display: inline; }
#btnDrink[data-selected="true"] .drinkIconPlus { display: none; }
.drinkCorner .drinkCup, .drinkCorner .drinkCup svg { width: 100%; height: auto; aspect-ratio: 200 / 210; }


#tablePhone { position: absolute; top: 50%; right: max(calc(var(--side, 156px) / 2), calc(var(--cupW) / 2 + 6px));
  width: calc(var(--cupW) * .65); transform: translate(50%, -50%) rotate(14deg); cursor: pointer; z-index: 3;
  filter: drop-shadow(3px 6px 6px #000a); container-type: inline-size; transform-origin: 50% 50%;
  transition: transform .35s cubic-bezier(.2,.8,.3,1), filter .35s; -webkit-tap-highlight-color: transparent; }
#tablePhone.up { transform: translate(50%, -50%) translateX(calc(-1 * var(--cupW) * .55)) rotate(0deg) scale(2.3);
  filter: drop-shadow(6px 14px 14px #000c); z-index: 6; cursor: default; }
#tablePhone.buzz { animation: phBuzz .45s; }
#tablePhone.up.buzz { animation: none; }
@keyframes phBuzz { 0%,100% { translate: 0 0; } 20% { translate: -1.5px 0; } 40% { translate: 1.5px 0; } 60% { translate: -1px 0; } 80% { translate: 1px 0; } }
#phScreen { position: absolute; left: 8.75%; top: 4.4%; width: 82.5%; height: 91.2%; border-radius: 11cqw; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; padding: 14cqw 4cqw 4cqw; box-sizing: border-box;
  background: radial-gradient(120% 70% at 30% 0%, #3a4a6a, #141a28 60%, #07080c); color: #fff;
  font: 500 6cqw/1.25 system-ui, -apple-system, sans-serif; opacity: 0; transition: opacity .3s; pointer-events: none; }
#tablePhone.lit #phScreen { opacity: 1; }
#tablePhone.up #phScreen { pointer-events: auto; }
#phTime { font-size: 24cqw; font-weight: 300; letter-spacing: -.02em; line-height: 1; }
#phDate { font-size: 6.5cqw; opacity: .75; margin-bottom: 5cqw; }
#phNotes { width: 100%; display: flex; flex-direction: column; gap: 2.5cqw; flex: 1; overflow: hidden; }
.phNote { background: #ffffff26; border-radius: 4cqw; padding: 2.5cqw 3.5cqw; font-size: 5.6cqw; animation: phIn .3s; }
.phNote.bot { background: #4a7bd94d; }
.phNote b { display: block; font-size: 4.8cqw; opacity: .8; font-weight: 600; }
@keyframes phIn { from { opacity: 0; transform: translateY(-4cqw); } }
#phBar { width: 100%; display: flex; flex-direction: column; gap: 2.5cqw; }
#phBar button { all: unset; box-sizing: border-box; width: 100%; padding: 3cqw; border-radius: 5cqw; background: #ffffff2e;
  font-size: 5.6cqw; text-align: center; cursor: pointer; display: flex; gap: 2cqw; justify-content: center; }
#phBar button:hover { background: #ffffff45; }
#phBar button:disabled { opacity: .4; cursor: default; }
#tablePhone svg { display: block; width: 100%; height: auto; }
#tablePhone:not(.up) #phBar { display: none; }


#phChat { display: none; width: 100%; flex: 1.4; min-height: 0; overflow-y: auto; flex-direction: column; gap: 1.8cqw; margin: 2.5cqw 0; scrollbar-width: none; }
#phChat::-webkit-scrollbar { display: none; }
#phChat button { all: unset; box-sizing: border-box; width: 100%; padding: 2.2cqw 3cqw; border-radius: 4cqw; background: #4a7bd973;
  font-size: 5.2cqw; line-height: 1.2; cursor: pointer; text-align: left; }
#phChat button:hover { background: #4a7bd9b0; }
#phChat button:disabled { opacity: .45; cursor: default; }
#tablePhone.chat.up #phChat { display: flex; }
#tablePhone.chat #phHint { display: none; }
#tablePhone.chat.up #phDate { margin-bottom: 2cqw; }
#tablePhone.chat.up #phNotes { flex: 1; }
.phNote.mine { background: #3c8a5a66; align-self: flex-end; }


#peerPhone { position: absolute; top: 50%;
  left: max(calc(var(--side, 156px) / 2), calc(var(--phoneW) / 2 + 6px)); width: var(--phoneW);
  transform: translate(-50%, -50%) rotate(166deg); z-index: 2; pointer-events: none; container-type: inline-size;
  filter: drop-shadow(3px -6px 6px #000a); transition: transform .45s cubic-bezier(.2,.8,.3,1), filter .45s; }
#peerPhone[hidden] { display: none; }

#peerName { position: absolute; top: calc(var(--boardTop, 0px) + var(--frame, 30px) / 2); left: var(--barX, 50%);
  transform: translate(-50%, -50%); max-width: calc(var(--frame, 30px) * 7); z-index: 2; pointer-events: none;
  padding: 1px 12px; border-radius: 3px; font: 600 clamp(12px, calc(var(--frame, 30px) * .5), 17px)/1.35 Georgia, serif;
  background: linear-gradient(#f0d99a, #c9a75a 55%, #a8843c); color: #3a2610; text-shadow: 0 1px 0 #f6e6b866;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 3px #000a, inset 0 1px 0 #fff6; }
#peerName[hidden] { display: none; }
#nameRow.hidden { display: none; }
#nameRow { display: flex; flex-direction: column; }
#myName { flex: 1; min-width: 0; font-size: 19px; text-align: center; padding: 10px; border-radius: 12px; border: 1px solid rgba(240,212,138,.5); background: rgba(0,0,0,.35); color: #f5ecd8; }
#peerPhone svg { display: block; width: 100%; height: auto; }
#peerPhone.up { transform: translate(-50%, -58%) rotate(180deg) scale(1.25); filter: drop-shadow(6px -14px 14px #000c); }
#peerScreen { position: absolute; left: 8.75%; top: 4.4%; width: 82.5%; height: 91.2%; border-radius: 11cqw; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 6cqw; box-sizing: border-box;
  background: radial-gradient(120% 70% at 30% 0%, #3a4a6a, #141a28 60%, #07080c); color: #fff; opacity: 0; transition: opacity .3s;
  font: 600 12cqw/1.2 system-ui, -apple-system, sans-serif; text-align: center; }
#peerPhone.lit #peerScreen { opacity: .85; }
#peerPhone.msg #peerScreen { opacity: 1; }
#peerMsg { background: #3c8a5a99; border-radius: 5cqw; padding: 4cqw 5cqw; opacity: 0; transition: opacity .3s; }
#peerPhone.msg #peerMsg { opacity: 1; }


#phBubble { position: absolute; bottom: calc(50% + var(--cupW) * .65 + 12px);
  right: max(12px, calc(var(--side, 156px) / 2 - var(--cupW) * .325));
  width: 236px; max-width: calc(100% - 24px); box-sizing: border-box; z-index: 5;
  padding: 12px 15px; border: 1px solid #e9d9bd; border-radius: 15px;
  background: #f5ead7; color: #35291f; box-shadow: 0 5px 18px #0005;
  font: 400 14px/1.4 system-ui, -apple-system, sans-serif; text-align: left;
  cursor: pointer; animation: phBubbleIn .22s ease-out; }
#phBubble[hidden] { display: none; }
#phBubble::after { content: ''; position: absolute; bottom: -7px; right: 30px;
  width: 12px; height: 12px; background: #f5ead7; border-right: 1px solid #e9d9bd;
  border-bottom: 1px solid #e9d9bd; transform: rotate(45deg); }
#phBubble b { display: block; margin-bottom: 3px; color: #806044; font-size: 12px; font-weight: 600; }
#phBubbleText { display: block; overflow-wrap: anywhere; }
#phBubble:hover { background: #fff3df; }
#phBubble:focus-visible { outline: 2px solid #bd9657; outline-offset: 4px; }
@keyframes phBubbleIn { from { opacity: 0; transform: translateY(5px); } }
@media (prefers-reduced-motion: reduce) { #phBubble { animation: none; } }


#menuAI > button.char { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left;
  padding: 11px 20px; column-gap: 12px; row-gap: 2px; }
#menuAI > button.char .chName { font-size: 20px; }
#menuAI > button.char .chSub { grid-row: 2; font-size: 14px; opacity: .72; font-weight: 400; }
#menuAI > button.char .chLvl { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 13px; letter-spacing: 2px; opacity: .8; }
#menuAI { gap: 10px; }


:is(#oppHandClip, #zinaHandClip) { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
:is(#oppHand, #zinaHand, #lyohaHand) { position: absolute; left: var(--handX); top: var(--handY); width: var(--handW); 
  filter: drop-shadow(1px 2px 2px rgba(0,0,0,.42)); }
:is(#oppHand, #zinaHand, #lyohaHand).hidden { display: none; }
:is(#oppHand, #zinaHand, #lyohaHand) svg { display: block; width: 100%; height: auto; overflow: visible; transform: rotate(-18deg); transform-origin: 50% 12%; }
:is(#oppHand, #zinaHand, #lyohaHand) .fing, :is(#oppHand, #zinaHand, #lyohaHand) .thumb { transform-box: view-box; }
:is(#oppHand, #zinaHand, #lyohaHand) .f1 { transform-origin: 82px 150px; } :is(#oppHand, #zinaHand, #lyohaHand) .f2 { transform-origin: 106px 153px; }
:is(#oppHand, #zinaHand, #lyohaHand) .f3 { transform-origin: 130px 151px; } :is(#oppHand, #zinaHand, #lyohaHand) .f4 { transform-origin: 152px 144px; }


:is(#oppHand, #zinaHand, #lyohaHand).drum .fing { animation: fingTap .34s ease-in-out 2; }
:is(#oppHand, #zinaHand, #lyohaHand).drum .f4 { animation-delay: 0s; } :is(#oppHand, #zinaHand, #lyohaHand).drum .f3 { animation-delay: .09s; }
:is(#oppHand, #zinaHand, #lyohaHand).drum .f2 { animation-delay: .18s; } :is(#oppHand, #zinaHand, #lyohaHand).drum .f1 { animation-delay: .27s; }
@keyframes fingTap { 0%, 100% { transform: none; } 40% { transform: scaleY(.84); } 70% { transform: scaleY(1.01); } }

:is(#oppHand, #zinaHand, #lyohaHand).doubleTap .fing { animation: fingDoubleTap .36s ease-in-out 2; }
@keyframes fingDoubleTap { 0%, 100% { transform: none; } 30% { transform: scaleY(.8); }
  57% { transform: scaleY(1.015); } 72% { transform: none; } }


#lyohaKeys { position: absolute; pointer-events: none; z-index: 2;
  left: max(calc(var(--side, 156px) / 2), calc(var(--cupW) / 2 + 6px));
  top: calc(var(--boardTop, 0px) + var(--cupW) * 1.12 + 16px);
  width: calc(var(--cupW) * .72); transform: translateX(-50%) rotate(-12deg);
  filter: drop-shadow(2px 3px 2px #0008); }
#lyohaKeys svg { display: block; width: 100%; }
#lyohaKeys.moving svg { animation: keysShift .65s ease-in-out; transform-origin: 46% 25%; }
@keyframes keysShift { 0%,100% { transform: none; } 35% { transform: translate(3px,-2px) rotate(7deg); } 65% { transform: rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) { #lyohaKeys.moving svg { animation: none; } }


:is(#goshaHandClip, #lyohaHandClip) { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
#goshaHabit { position: absolute; pointer-events: none; z-index: 2; 
  left: var(--goshaX); top: var(--goshaY); width: var(--goshaW); filter: drop-shadow(1px 2px 2px #0006); }
#goshaHabit svg { display: block; width: 100%; overflow: visible; }


.onHand { position: absolute; pointer-events: none; z-index: 2;
  --onlineHandW: min(calc(var(--decorCupW, 84px) * 1.5), max(36px, calc((var(--side, 156px) - 12px) / .8)));
  width: var(--onlineHandW); filter: drop-shadow(1px 2px 2px #0006); }
.onHand.hidden { display: none; }
.onHand svg { display: block; width: 100%; overflow: visible; }
.onHand.peer { right: max(0px, calc(var(--side, 156px) / 2 - var(--onlineHandW) * .425));
  top: calc(var(--onlineHandW) * -.08); }
.onHand.me { left: max(0px, calc(var(--side, 156px) / 2 - var(--onlineHandW) * .575));
  bottom: calc(var(--onlineHandW) * -.08);
  transform: rotate(180deg); filter: drop-shadow(-1px -2px 2px #0006); }
.onHand .handShape { transform: translateX(11px) scaleX(.9); transform-origin: 0 0; }
.onHand .mashaFist { opacity: 0; }
.onHand.shuffle .mashaFist { opacity: 1; }
.onHand.shuffle .fing, .onHand.shuffle .thumb, .onHand.shuffle .openPalm { display: none; }
.onHand.shuffle svg { animation: onlineHandShake .9s ease-in-out; transform-origin: 50% 12%; }
@keyframes onlineHandShake {
  0%, 100% { transform: none; }
  15%, 35% { transform: rotate(-2deg); }
  25%, 45% { transform: rotate(2deg); }
  65% { transform: translateY(-5px); }
}
.onHand .fing, .onHand .thumb { transform-box: view-box; }
.onHand .f1 { transform-origin: 82px 150px; } .onHand .f2 { transform-origin: 106px 153px; }
.onHand .f3 { transform-origin: 130px 151px; } .onHand .f4 { transform-origin: 152px 144px; }
.onHand.tap .fing { animation: fingTap .34s ease-in-out 2; }
@media (prefers-reduced-motion: reduce) { .onHand * { animation: none !important; } }

#goshaHabit.shuffle .goshaPalm { animation: goshaThrow 1s ease-in-out; transform-origin: 105px 20px; }
#goshaHabit.shuffle .goshaOpen { animation: goshaOpenPose 1s step-end; }
#goshaHabit .goshaFist { visibility: hidden; }
#goshaHabit.shuffle .goshaFist { animation: goshaClosedPose 1s step-end; }

@keyframes goshaOpenPose { 0%, 64% { visibility: hidden; } 65%, 100% { visibility: visible; } }
@keyframes goshaClosedPose { 0%, 64% { visibility: visible; } 65%, 100% { visibility: hidden; } }
#goshaHabit .f1 { transform-origin: 78px 150px; } #goshaHabit .f2 { transform-origin: 104px 153px; }
#goshaHabit .f3 { transform-origin: 130px 151px; } #goshaHabit .f4 { transform-origin: 154px 144px; }
@keyframes goshaCurl { 0% { transform: none; } 15%, 58% { transform: scaleY(.32); } 70% { transform: scaleY(1.08); } 100% { transform: none; } }
@keyframes goshaThumb { 0%, 100% { transform: none; } 15%, 58% { transform: rotate(-28deg) translate(14px, 6px); } 72% { transform: none; } }
@keyframes goshaThrow { 0% { transform: none; } 15% { transform: translateY(-6px); }
  24% { transform: translateY(-6px) rotate(5deg); } 33% { transform: translateY(-6px) rotate(-5deg); }
  42% { transform: translateY(-6px) rotate(5deg); } 52% { transform: translateY(-12px); }
  64% { transform: translate(-10px, 14px) rotate(-6deg); } 100% { transform: none; } }
#goshaHabit.tap .goshaPalm { animation: goshaTap .3s ease-in-out 3; }
#opponentcup.adjusting svg { animation: goshaAdjust .85s ease-in-out; transform-origin: center; }
@keyframes goshaTap { 50% { translate: 0 -4px; } }
@keyframes goshaAdjust { 45% { transform: translate(5px, 2px) rotate(6deg); } }
#goshaChat { margin: 6px 0 12px; padding: 10px 14px; border: 1px solid #99733f; border-radius: 12px; background: #251b14; }
#goshaChatText { white-space: pre-line; text-align: left; line-height: 1.5; margin: 0 0 10px; }
@media (prefers-reduced-motion: reduce) {
  #goshaHabit * , #opponentcup.adjusting svg { animation: none !important; }
}


#zinaJam { position: absolute; pointer-events: none; z-index: 2;
  left: max(calc(var(--side, 156px) / 2), calc(var(--cupW) / 2 + 6px));
  top: calc(var(--boardTop, 0px) + var(--cupW) * 1.05 + 18px);
  width: calc(var(--cupW) * .95); transform: translateX(-50%);
  filter: drop-shadow(1px 2px 2px #0003); }
#zinaJam svg { display: block; width: 100%; height: auto; }


#goshaNotes, #seregaBeads { position: absolute; pointer-events: none; z-index: 2;
  
  left: var(--decorCupX); top: calc(var(--decorCupY) + var(--decorCupW) * 1.08 + 16px);
  width: var(--beadsW); transform: translateX(-50%);
  filter: drop-shadow(1px 2px 2px #0005); }
#seregaBeads { transform: translateX(-50%) rotate(-18deg); }
#goshaNotes svg, #seregaBeads svg { display: block; width: 100%; height: auto; }


#menuOnline { display: flex; flex-direction: column; gap: 14px; }
#menuOnline.hidden, #roomBox.hidden { display: none; }
#menuOnline > button { padding: 18px 22px; font-size: 21px; border-radius: 14px; }
#roomBox { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; font-size: 19px; }
#roomShow { font-size: 32px; letter-spacing: 6px; color: #f0d48a; }
#joinRow { display: flex; gap: 10px; }
#roomCode { flex: 1; min-width: 0; font-size: 24px; letter-spacing: 5px; text-transform: uppercase; text-align: center;
  padding: 12px; border-radius: 12px; border: 1px solid rgba(240,212,138,.5); background: rgba(0,0,0,.35); color: #f5ecd8; }
#joinRow > button { padding: 12px 22px; font-size: 20px; border-radius: 12px; }
#menuOnline .onHead { font-size: 17px; font-weight: 600; text-align: center; color: #e8d3a8; margin-bottom: -6px; }
#menuOnline .onHint { font-size: 15px; opacity: .7; text-align: center; margin-top: -6px; }
#menuOnline .orLine { display: flex; align-items: center; gap: 12px; font-size: 15px; opacity: .6; margin: 2px 0; }
#menuOnline .orLine::before, #menuOnline .orLine::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .5; }
#roomCode::placeholder { letter-spacing: 1px; text-transform: none; font-size: 19px; }
#nameRow label { display: block; margin-bottom: 7px; font-size: 14px; color: #e8d3a8; }
#onlineTabs { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
#onlineTabs button { padding: 12px 8px; font-size: 16px; border-radius: 12px; }
#onlineTabs button.on { background: #d9a75a24; border-color: #e8d3a8; color: #fff1d5; }
.onlinePane { display: flex; flex-direction: column; gap: 14px; }
.onlinePane > button { padding: 18px 22px; font-size: 21px; border-radius: 14px; }
#menuOnline .onlinePane > .onHint { margin-top: 0; line-height: 1.4; }
#onlineNote { min-height: 1.3em; font-size: 16px; opacity: .85; text-align: center; }
#resultNote { margin: 0 0 12px; font-size: 17px; color: #f0d48a; text-align: center; }
#resultNote.hidden { display: none; }
#btnAgain:disabled { opacity: .55; cursor: default; }
#langSwitch { display: flex; justify-content: center; gap: 6px; margin: 12px 0 0; }
#langSwitch button { min-width: 0; width: auto; margin: 0; padding: 4px 12px; font-size: 13px; background: transparent; color: inherit; border: 1px solid rgba(214,178,94,.35); border-radius: 6px; box-shadow: none; opacity: .55; transform: none; }
#langSwitch button.on { opacity: 1; border-color: rgba(214,178,94,.85); }
#contacts { margin: 10px 0 0; font-size: 12px; text-align: center; }
#contacts a { color: inherit; text-underline-offset: 3px; }
#copyright { margin: 10px 0 0; font-size: 11px; opacity: .4; text-align: center; }


#opponentdrinkCorner { left: var(--decorCupX); top: var(--decorCupY); width: var(--decorCupW); }
#lyohaKeys { left: var(--keysX); top: var(--keysY); width: var(--keysW); transform: translateX(-50%) rotate(-8deg); }
#tablePhone { left: var(--phoneX); right: auto; top: var(--phoneY); width: var(--phoneW);
  transform: translate(-50%, -50%) rotate(8deg); }
#tablePhone.up { z-index: 9; position: fixed; left: 50%; right: auto; top: 50%;
  width: min(180px, calc((100dvh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) / 2));
  transform: translate(-50%, -50%); }
#hud, #tableFooter { position: relative; z-index: 7; }


button.tip { position: relative; }
button.tip:hover::after, button.tip:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0;
  white-space: nowrap; padding: 5px 9px; border-radius: 6px; background: rgba(20,14,10,.94); color: #f3ead8;
  font-size: 13px; line-height: 1.2; pointer-events: none; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.4); }


#menu .panel h1.logo { margin: 0 0 22px; text-shadow: none; line-height: 0; text-align: center; }
#menu .logoSvg { width: min(420px, 100%); height: auto; filter: drop-shadow(0 3px 5px #0008); }
#menu .logoName.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


#cookieNote { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 1000;
  display: flex; gap: 14px; align-items: center; max-width: min(620px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: 10px; background: rgba(20,14,9,.92); color: #e9dcc4;
  font-size: 13px; line-height: 1.35; box-shadow: 0 4px 18px rgba(0,0,0,.4); }
#cookieNote button { flex: none; padding: 6px 14px; border: 1px solid rgba(214,177,106,.6); border-radius: 7px;
  background: transparent; color: #e9dcc4; font: inherit; cursor: pointer; }


.segPick { display: flex; justify-content: center; gap: 10px; margin: 2px 0 8px; }
.segPick button.seg { width: auto; min-width: 0; margin: 0; padding: 9px 22px; font-size: 18px;
  background: transparent; color: #f3ead8; border: 1px solid #f3ead855; box-shadow: none; transform: none; opacity: .7; }
.segPick button.seg.on { background: #f3ead822; border-color: #f3ead8; opacity: 1; }


#newGameLabel { text-align: center; font-size: 15px; color: #e8d3a8; margin-top: 8px; }
#menuMain > button.modeCard { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 18px; }
.modeCard small { font-size: 14px; line-height: 1.35; font-weight: 400; letter-spacing: 0; opacity: .8; }
#statsSection { text-align: center; font-size: 14px; color: #d6c6ab; }
#statsSection summary { cursor: pointer; padding: 8px; }
#statsSection #stats { margin: 8px 0 12px; }
#statsSection #btnResetStats { margin: 0 auto 8px; }
#statsSection summary:focus-visible { outline: 2px solid #e8d3a8; outline-offset: 2px; border-radius: 6px; }


#profile { z-index: 110; }
.panel.profilePanel { width: min(780px, 90vw); max-width: 780px; max-height: 85vh; overflow-y: auto; text-align: left; padding: 28px; }
.profileHeading { display: flex; align-items: center; justify-content: space-between; gap: 24px; position: sticky; top: -28px; background: #201a13; padding: 12px 0; z-index: 1; }
.profileHeading h2 { margin: 0; }
.profileHeading button { width: auto; margin: 0; font-size: 16px; padding: 10px 18px; }
.profileIdentity label { display: grid; gap: 8px; }
.profileIdentity input { color: #f2dfb7; background: #15120e; border: 1px solid #8b7347; border-radius: 8px; padding: 12px; font: inherit; }
#profileContent h3 { color: #e4c890; margin-top: 28px; border-bottom: 1px solid #77613c; padding-bottom: 10px; }
#profileContent progress { width: 100%; height: 14px; accent-color: #c4a161; }
#profileContent p { line-height: 1.5; }
#profileContent .profileHint { font-size: 14px; color: #c2b298; }
#profileContent table { width: 100%; border-collapse: collapse; font-size: 14px; }
#profileContent th, #profileContent td { text-align: left; padding: 10px 6px; border-bottom: 1px solid #51432f; }
.careerCard { border: 1px solid #6f5939; border-radius: 10px; padding: 16px; margin: 14px 0; background: #ffffff04; }
.careerCard h4 { color: #efdab0; margin: 0 0 10px; font-size: 20px; }
.careerCard p { margin: 7px 0; }
#profileContent button { font-size: 16px; }
#profileContent button:disabled { opacity: .5; cursor: default; }
#profileTrophy { position: absolute; bottom: 100px; left: 24px; pointer-events: none; text-align: center; color: #c8a468; text-shadow: 2px 5px 4px #0009; }
#profileTrophy span { display: block; font-size: 56px; }
#profileTrophy small { display: block; max-width: 130px; font-size: 12px; }
#progressResult { color: #e7cd8e; line-height: 1.6; }

.profileIdentity > button { margin-top: 14px; }
#profileContent .progressRow { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 10px 0; border-bottom: 1px solid #51432f; font-size: 15px; }
.progressRow strong { white-space: nowrap; color: #e4c890; font-size: 14px; }
.profileDetails { margin-top: 14px; }
.profileDetails summary { cursor: pointer; color: #c2b298; font-size: 14px; }
#profileContent progress { appearance: none; border: 0; border-radius: 7px; overflow: hidden; background: #51432f; }
#profileContent progress::-webkit-progress-bar { background: #51432f; }
#profileContent progress::-webkit-progress-value { background: #c4a161; }
#profileContent progress::-moz-progress-bar { background: #c4a161; }


.panel.profilePanel { width: min(680px, 92vw); padding: 24px; background: linear-gradient(145deg, #302216, #211a13); border: 1px solid #76603b; border-radius: 22px; box-shadow: 0 24px 80px #0008; }
.profileHeading { position: static; background: transparent; padding: 0 0 20px; gap: 12px; }
.profileHeading h2 { font-size: 26px; }
.profileHeading button { font-size: 14px; padding: 8px 14px; }
.profileNav { display: flex; gap: 6px; padding: 5px; margin-bottom: 22px; border-radius: 12px; background: #100e0b66; }
#profileContent .profileNav button { flex: 1; width: auto; margin: 0; padding: 10px 6px; border: 0; border-radius: 8px; font-size: 14px; color: #bdae94; background: transparent; box-shadow: none; }
#profileContent .profileNav button[aria-pressed="true"] { color: #f6dfac; background: #68502d; }
.profilePage[hidden] { display: none; }
.profileIdentity { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: end; }
.profileIdentity label { font-size: 13px; color: #c2b298; gap: 6px; }
.profileIdentity input { width: 100%; box-sizing: border-box; font-size: 17px; padding: 11px 12px; border-color: #685332; }
#profileContent .profileIdentity > button { width: auto; margin: 0; padding: 12px 18px; font-size: 14px; }
#profileContent .profileSaveStatus { grid-column: 1 / -1; margin: 0; font-size: 12px; color: #dfc68e; }
.profileSaveStatus:empty { display: none; }
.profileLevel { margin-top: 22px; padding: 20px; border: 1px solid #735a35; border-radius: 14px; background: linear-gradient(120deg, #a8833424, #a8833405); }
.profileEyebrow { font-size: 10px; letter-spacing: 1.6px; color: #c3a66c; }
#profileContent .profileLevel h3 { margin: 7px 0 16px; padding: 0; border: 0; font-size: 26px; }
#profileContent .profileLevel p { margin: 10px 0 0; font-size: 12px; color: #c2b298; }
#profileContent progress { display: block; height: 8px; }
#profileContent h3 { margin: 22px 0 14px; padding: 0; border: 0; font-size: 18px; }
.profileMetrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.profileMetrics > div { display: grid; gap: 7px; padding: 15px 8px; text-align: center; border: 1px solid #665132; border-radius: 12px; background: #ffffff03; }
.profileMetrics strong { font-size: 25px; color: #f0d9a7; }
.profileMetrics span { font-size: 12px; color: #c2b298; }
.profileStatsDetails { padding: 14px 0 0; }
.profileTableWrap { overflow-x: auto; }
#profileContent table { white-space: nowrap; font-size: 12px; margin-top: 12px; }
.profileCollection { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.careerCard { margin: 0; padding: 15px; }
.careerCard h4 { font-size: 17px; }
#profileContent .careerCard p { font-size: 12px; }
#profileContent .careerCard button { width: auto; margin: 8px 0 0; font-size: 12px; padding: 8px 12px; }
#profileContent .profileHint { font-size: 12px; }
.profileDetails summary { padding: 4px 0; }
@media (max-width: 520px) {
  .panel.profilePanel { padding: 18px; max-height: 90dvh; }
  .profileHeading h2 { font-size: 22px; }
  .profileMetrics { gap: 6px; }
  .profileMetrics strong { font-size: 22px; }
  .profileMetrics span { font-size: 10px; }
  .profileCollection { grid-template-columns: 1fr; }
  #profileContent .progressRow { font-size: 13px; gap: 10px; }
  .progressRow strong { font-size: 12px; }
}


.matchFormat { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 18px; cursor: pointer; }
.matchFormat input { width: 20px; height: 20px; accent-color: #b69a60; }
#menuAI > .onHint { font-size: 14px; line-height: 1.4; opacity: .72; margin: 0 0 4px; }


.rewardObject { display:block; width:100px; height:112px; margin:0 auto; filter:drop-shadow(2px 4px 2px #0005); }
#profileTrophy { left: max(4px, calc(var(--side, 160px) / 2 - 40px)); bottom:auto; top:calc(var(--boardTop, 50px) + var(--boardH, 400px) * .64); width: clamp(45px, calc(var(--side, 160px) * .65), 90px); }
#profileTrophy .rewardObject { width:100%; height:auto; }
.cosmeticCard canvas { width:100%; max-width:240px; height:auto; display:block; margin:auto; }
.cosmeticCard .rewardObject { height:140px; width:120px; }
.plainCup { filter: grayscale(1) drop-shadow(2px 4px 2px #0005); }
#cup[data-cosmetic="gilded"] #vesselPorcelain { filter: sepia(.45) saturate(1.2); }
#cup[data-cosmetic="gilded"] #cupRim { stroke:#d4ad50; stroke-width:4; stroke-opacity:1; }


.rewardTeaser { display:flex; align-items:center; gap:14px; padding:14px; border:1px solid #a78349; border-radius:14px; background:linear-gradient(120deg,#b88b3026,#20180f); color:#f2ddb1; text-align:left; }
.rewardTeaser.hidden { display:none; }
.rewardTeaser canvas, .rewardTeaser > .rewardObject { flex:0 0 104px; width:104px; height:auto; margin:0; }
.rewardCopy { display:flex; flex:1; min-width:0; flex-direction:column; gap:7px; }
.rewardCopy strong { font-size:16px; line-height:1.2; }
.rewardCopy > span { font-size:12px; line-height:1.4; color:#cdbc9d; }
.rewardCopy progress { display:block; width:100%; height:7px; accent-color:#d5af65; }
#menuMain > #nextReward { padding:14px; font-size:14px; }
#menuMain > #btnCollection { padding:7px 12px; font-size:13px; margin-top:-8px; border-color:transparent; }
#rewardResult { margin:14px 0; }
#rewardResult:has(> .rewardTeaser) { display:flex; flex-direction:column; padding:0; border:0; background:none; }
#rewardResult > .rewardTeaser { width:100%; box-sizing:border-box; }
.rewardTeaser > button { padding:9px 12px; font-size:13px; width:auto; }
@media (max-width:520px) {
  .rewardTeaser { gap:10px; padding:10px; flex-wrap:wrap; }
  .rewardTeaser canvas, .rewardTeaser > .rewardObject { flex-basis:82px; width:82px; }
  .rewardCopy strong { font-size:14px; }
  .rewardCopy .profileEyebrow { font-size:9px; letter-spacing:1px; }
}
@media (prefers-reduced-motion:no-preference) {
  #rewardResult:not(.hidden) { animation:rewardReveal .4s ease-out; }
  @keyframes rewardReveal { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
}


#menu .panel { padding: 28px 32px 22px; gap: 11px; }
#menu .panel h1.logo { margin-bottom: 12px; }
#menu .logoSvg { width: min(336px, 100%); }
#menuMain { display:grid; grid-template-columns:minmax(0,1fr); gap:24px; margin:4px 0 12px; }
#menuMain > button.modeCard { padding: 11px 16px; font-size: 19px; gap: 4px; }
#menuMain .modeCard small { font-size: 13px; }
#menu #menuContent > #btnContinue { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 18px; font-size: 21px; }
#continueSummary { font-size: 13px; line-height: 1.4; font-weight: 400; opacity: .8; }
#continueSummary:empty { display: none; }
#menu #menuContent > #btnCollection { padding: 11px 14px; font-size: 16px; margin-top: 4px; }
#menuUtilities { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#menuUtilities > button { padding: 10px 8px; font-size: 14px; border-radius: 10px; }
#menu #nextReward, #menu #statsSection { display: none !important; }
#menu #langSwitch { margin-top: 4px; }
@media (max-width: 420px), (max-height: 720px) {
  #menu .panel { padding: 20px; gap: 9px; }
  #menu .logoSvg { width: min(280px, 90%); }
}


#menu .panel:has(#menuMain:not(.hidden)) > * { flex-shrink:0; }
#menu .panel:has(#menuMain:not(.hidden)) > #btnContinue { min-height:84px; padding:16px 24px; font-size:21px; }
#menu .panel:has(#menuMain:not(.hidden)) #continueSummary { font-size:15px; }

#menu #menuContent > #btnContinue { box-shadow: inset 0 1px 0 #fff3d088, 0 2px 0 #795122, 0 4px 10px #0004; }
#menu #menuContent > #btnContinue:hover { transform:translateY(-1px); box-shadow:inset 0 1px 0 #fff3d088, 0 3px 0 #795122, 0 5px 12px #0005; }
#menu #menuContent > #btnContinue:active { transform:translateY(1px); box-shadow:inset 0 1px 3px #79512266; }
#menuMain > button.modeCard { position:relative; align-items:center; justify-content:center; min-width:0; min-height:84px; padding:16px 48px; gap:5px; text-align:center; background:linear-gradient(180deg,#f2d08a 0%,#dcae5c 45%,#b9873a 100%); color:#2a1a08; border:1px solid #8a5f22; text-shadow:0 1px 0 #fff4d655; letter-spacing:0; box-shadow:inset 0 1px 0 #fff3d088,0 2px 0 #795122,0 4px 10px #0004; font-size:21px; line-height:1.25; }
#menuMain > button.modeCard::after { content:""; position:absolute; right:26px; top:calc(50% - 5px); width:9px; height:9px; border-top:2px solid #694418; border-right:2px solid #694418; transform:rotate(45deg); }
#menuMain > button.modeCard small { font-size:14px; color:#59401e; opacity:1; font-weight:400; line-height:1.5; }
#menuMain > button.modeCard:hover { background:linear-gradient(180deg,#f7da9a 0%,#e4b866 45%,#c2913f 100%); border-color:#8a5f22; transform:translateY(-1px); box-shadow:0 3px 7px #0003; }
#menuMain > button.modeCard:active { transform:translateY(1px); box-shadow:inset 0 1px 4px #0004; }
#menu #menuContent > #btnCollection { display:flex; align-items:center; gap:14px; width:100%; min-height:84px; padding:10px 14px; text-align:left; border:1px solid #85613180; background:#20160f66; border-radius:14px; margin-top:8px; }
#btnCollection .tablePreview { width:102px; flex:0 0 102px; margin:0; }
.appearanceCopy { display:flex; flex-direction:column; gap:4px; flex:1; min-width:0; }
.appearanceCopy strong { font-size:17px; font-weight:600; color:#f2d69f; }
.appearanceCopy > span { font-size:13px; font-weight:400; line-height:1.4; color:#cbb58f; }
.appearanceArrow { font-size:26px; color:#d9b875; }
#menuUtilities { gap:20px; margin-top:0; }
#menuUtilities > button { display:flex; align-items:center; justify-content:center; gap:9px; min-height:48px; padding:12px 8px; font-size:14px; border-color:#a47d4855; }
#menuUtilities > button::before { content:''; display:block; flex:0 0 19px; height:19px; background:currentColor; mask:center/contain no-repeat var(--utility-icon); -webkit-mask:center/contain no-repeat var(--utility-icon); }
#btnRules { --utility-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linejoin='round'%3E%3Cpath d='M12 5Q7 2 2 4v15q5-2 10 1 5-3 10-1V4q-5-2-10 1v15'/%3E%3C/svg%3E"); }
#btnProfile { --utility-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3Cpath d='M4 21v-2a8 8 0 0 1 16 0v2'/%3E%3C/svg%3E"); }
.tablePreview { display:block; width:100%; max-width:480px; height:auto; margin:0 auto 18px; }
.cosmeticSelected { border-color:#e8bf6d; box-shadow:inset 0 0 0 1px #e8bf6d; }
.cosmeticProgressText { font-size:14px; line-height:1.5; color:#ead5ae; }
.cosmeticCard progress { display:block; width:100%; height:7px; accent-color:#d9b875; margin:10px 0 12px; }
.cosmeticCharacters { list-style:none; display:grid; gap:7px; padding:0; margin:12px 0; font-size:14px; color:#cbb89b; }
.cosmeticCharacters li { display:flex; align-items:center; gap:8px; }
.cosmeticCharacters .sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.cosmeticCharacters .completed { color:#d7dfa8; }
@media(max-width:699px) {
  #menuMain { grid-template-columns:1fr; gap:22px; margin:4px 0 12px; }
  #menuMain > button.modeCard { min-height:84px; padding:16px 42px 16px 20px; gap:5px; font-size:21px; }
  #menuMain > button.modeCard::after { bottom:auto; top:calc(50% - 5px); }
}
@media(max-width:520px) {
  #menuMain > button.modeCard { padding:16px 42px 16px 20px; font-size:21px; }
  #menu #menuContent > #btnCollection { min-height:84px; gap:12px; padding:10px; }
  #btnCollection .tablePreview { width:82px; flex-basis:82px; }
  .appearanceCopy strong { font-size:16px; } .appearanceCopy > span { font-size:13px; }
  #menuUtilities { gap:8px; } #menuUtilities > button { gap:6px; font-size:13px; }
  #menuUtilities > button::before { flex-basis:17px; height:17px; }
}


html:fullscreen, html:-webkit-full-screen { width: 100%; height: 100%; }
html:fullscreen body, html:-webkit-full-screen body { position: absolute; inset: 0; width: 100%; height: 100%; }
html:fullscreen #app, html:-webkit-full-screen #app { width: 100%; height: 100%; min-width: 0; }
html:fullscreen #hud, html:-webkit-full-screen #hud,
html:fullscreen #tableFooter, html:-webkit-full-screen #tableFooter { width: 100%; min-width: 0; }
html:fullscreen #status, html:-webkit-full-screen #status { min-width: 0; }
html:fullscreen #hud button, html:-webkit-full-screen #hud button,
html:fullscreen #tableFooter button, html:-webkit-full-screen #tableFooter button { flex-shrink: 0; }


@media (pointer: coarse) and (max-width: 1000px) and (max-height: 1000px) {
  #hud { flex-wrap: wrap; gap: 4px; padding: 4px 6px; }
  #hud button.small { min-width: 44px; min-height: 44px; padding: 6px; }
  #status { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
  #tableFooter { min-height: 32px; padding: 4px 8px; }
  #drinkDock, #drinkCorner, #opponentdrinkCorner, #drinkPicker,
  #profileTrophy, :is(#goshaHandClip, #lyohaHandClip), :is(#oppHandClip, #zinaHandClip), #seregaBeads, #lyohaKeys,
  #tablePhone, #peerPhone { display: none !important; }
  #phBubble { right: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  .overlay { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .panel { min-height: 0; padding: 18px; touch-action: pan-y; overscroll-behavior: contain; }
  .panel > * { flex-shrink: 0; }
  #menuMain { gap: 12px; margin: 0; }
  #menuMain > button.modeCard, #menu .panel:has(#menuMain:not(.hidden)) > #btnContinue { min-height: 64px; padding: 12px 30px 12px 12px; font-size: 18px; }
  #menu #menuContent > #btnCollection { min-height: 64px; margin-top: 0; }
  #menu .logoSvg { width: min(250px, 85%); }
  #menuUtilities { gap: 8px; }
}


@media (pointer: coarse) and (max-width: 1000px) and (max-height: 1000px) {
  #stage[style*="--mobilePhones: 1"] #tablePhone:not(.hidden),
  #stage[style*="--mobilePhones: 1"] #peerPhone:not([hidden]):not(.hidden) { display: block !important; }
  #stage #drinkCorner, #stage #opponentdrinkCorner, #stage #zinaJam,
  #stage #goshaNotes, #stage #seregaBeads, #stage #lyohaKeys,
  #stage .onHand { display: none !important; }
  #stage #peerPhone { left: var(--peerPhoneX); top: var(--peerPhoneY); }
  #stage #peerPhone.up { transform: translate(-50%, -50%) rotate(180deg); }
  #stage #drinkCorner { left: var(--myCupX); top: var(--myCupY); right: auto; bottom: auto; transform: translateX(-50%); }
  #stage #zinaJam, #stage #goshaNotes, #stage #seregaBeads, #stage #lyohaKeys {
    left: var(--extraX); top: var(--extraY); width: var(--extraW); transform: translateX(-50%);
  }
}

#btnFull .fsHelpIcon, #btnFull.fsHelp .fsIn, #btnFull.fsHelp .fsOut { display: none; }
#btnFull.fsHelp .fsHelpIcon { display: inline; }
#fullscreenHelp { z-index: 50; }
#fullscreenHelp .panel { line-height: 1.5; }
#fullscreenHelp p { margin: 0; overflow-wrap: anywhere; }
#fullscreenHelpNote { font-size: 14px; color: #d4c6af; }
#fullscreenHelpNote:empty { display: none; }


@media (pointer: coarse) and (max-width: 1000px) and (max-height: 1000px) {
  #phBubble::after {
    top: -7px; bottom: auto; right: auto;
    left: clamp(18px, calc(var(--phoneX) - var(--tableW) + 8px + 100% - 6px), calc(100% - 30px));
    border: 0; border-top: 1px solid #e9d9bd; border-left: 1px solid #e9d9bd;
  }
}


#variantPick, #menu #colorPick { flex-direction: column; gap: 8px; margin-bottom: 18px; }
.pickLabel, .opponentPrompt { color: #e8d3a8; font-size: 16px; text-align: center; }
.choiceSegments { display: inline-flex; padding: 4px; border: 1px solid #d6b25e66; border-radius: 15px; background: #160e0870; max-width: 100%; }
#variantPick .choiceSegments button.seg, #menu #colorPick .choiceSegments button.seg {
  display: inline-flex; justify-content: center; align-items: center; gap: 7px; flex: 1;
  margin: 0; padding: 10px 14px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: #f3ead8; opacity: 1; box-shadow: none; font-size: 18px;
}
#variantPick button.seg::before, #colorPick button.seg::before { content: '✓'; width: 1em; visibility: hidden; }
#variantPick .choiceSegments button.seg.on, #menu #colorPick .choiceSegments button.seg.on {
  background: linear-gradient(#efd08b, #c79849); color: #2b1b09; border-color: #f4dca0;
}
#variantPick button.seg.on::before, #colorPick button.seg.on::before { visibility: visible; }
.choiceSegments button:focus-visible { outline: 2px solid #fff1d5; outline-offset: 2px; }
.opponentPrompt { margin: 18px 0 10px; line-height: 1.4; }

#menuSetup .setupStep { color: #c6b69c; font-size: 16px; margin: 4px 0; }
#selectedOpponent { font-size: 26px; margin: 0 0 22px; color: #efd08b; }
#menuSetup #variantPick { margin-bottom: 20px; }
#menuSetup .matchFormat { font-size: 17px; }
#menuSetup #matchHint { font-size: 14px; line-height: 1.5; margin: 12px 0 22px; }
#menuSetup #btnStartAI { margin-top: 12px; }
#menuAI .opponentPrompt { margin: 0 0 16px; font-size: 21px; }
#menuSetup .setupStep { text-align: center; }
#menuSetup > button { display: block; width: 100%; padding: 15px 18px; font-size: 20px; margin: 10px 0 0; }
#menuSetup > button.ghost { font-size: 16px; padding: 11px 18px; }


#menuSetup .setupStep { font-size: 13px; margin: 0; }
#menuSetup #selectedOpponent { font-size: 23px; margin: 2px 0 0; }
#menuSetup #variantPick { gap: 4px; margin-bottom: 10px; }
#menuSetup .pickLabel { font-size: 13px; }
#menuSetup #variantPick button.seg { padding: 7px 12px; font-size: 16px; }
#setupAppearance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 12px 0 18px; }
.setupAppearanceGroup { min-width: 0; margin: 0; }
.setupAppearanceGroup h3 { color: #e8d3a8; font-size: 14px; text-align: center; margin: 0 0 6px; }
.setupSamples { display: flex; flex-direction: column; gap: 6px; padding: 3px 2px; }
#menuSetup .setupSample { position: relative; flex: none; width: 100%; padding: 4px; margin: 0; border: 1px solid #d6b25e55; border-radius: 9px; background: #1c120b; color: #f3ead8; box-shadow: none; transform: none; scroll-snap-align: start; }
#menuSetup .setupSample.selected { border: 2px solid #efd08b; padding: 3px; background: #654b26; }
.setupSample.selected::after { content: '✓'; position: absolute; top: 2px; right: 5px; color: #ffe2a0; font-size: 14px; }
.setupSample canvas { display: block; width: 100%; height: 54px; object-fit: contain; }
.sampleName { display: block; font-size: 11px; line-height: 1.2; padding: 2px 0; }
#menuSetup .setupSample:focus-visible { outline: 2px solid #fff1d5; outline-offset: 1px; }
#menuSetup .matchFormat { font-size: 15px; }
#menuSetup #matchHint { font-size: 12px; margin: 8px 0 12px; }
#menuSetup > button { padding: 12px 16px; font-size: 18px; margin-top: 10px; }
#menuSetup > button.ghost { padding: 8px 14px; font-size: 14px; }

#menuSetup #btnBackSetup { display: block; width: auto; margin: 2px auto 14px; padding: 4px 8px; border: 0; background: transparent; box-shadow: none; color: #cdb78f; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 480px) {
  #setupAppearance { display: block; margin: 10px 0 14px; }
  .setupAppearanceGroup { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 6px; align-items: center; margin: 6px 0; }
  .setupAppearanceGroup h3 { text-align: left; margin: 0; }
  .setupSamples { flex-direction: row; overflow-x: auto; scroll-snap-type: x proximity; }
  #menuSetup .setupSample { flex: 0 0 calc((100% - 6px) / 2); width: auto; min-width: 88px; }
  .setupSample canvas { height: 46px; }
}


#menu.overlay { box-sizing: border-box; }
#menu.overlay > .panel {
  width: min(560px, 100%); min-width: 0; max-width: 560px;
  height: min(840px, calc(100dvh - 32px)); max-height: none;
  display: flex; flex-direction: column; overflow: hidden;
  padding: 24px; gap: 24px;
}
#menu.overlay > .panel h1.logo { flex: 0 0 auto; position: static; margin: 0; padding: 0; width: 100%; line-height: 0; }
#menu.overlay > .panel h1.logo .logoSvg { display: inline-block; width: min(300px, 85%); height: auto; }
#menuContent {
  flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-gutter: stable both-edges; overscroll-behavior: contain; touch-action: pan-y;
}
#menu.overlay > .panel > #menuContent { flex-shrink: 1; }
#menuContent > * { flex-shrink: 0; }

#menuContent:has(#menuMain:not(.hidden)) { justify-content: flex-start; gap: 16px; }
#menuMain { display: flex; flex-direction: column; gap: 16px; margin: 0; }
#menu #menuContent > #btnContinue, #menuMain > button.modeCard {
  flex: 0 0 auto; box-sizing: border-box; min-height: 76px; margin: 0; padding: 14px 38px; font-size: 20px; line-height: 1.3; gap: 4px;
}
#menu #continueSummary, #menuMain > button.modeCard small { font-size: 14px; line-height: 1.4; }
#menu #menuContent > #btnCollection { flex: 1 0 114px; margin: 0; min-height: 114px; }
#menu #btnCollection .tablePreview { width: 216px; flex: 0 0 216px; margin: 0; }
#menuUtilities { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 0; }
#menuUtilities > button { min-height: 48px; padding: 10px 8px; }
#menuAI:not(.hidden), #menuSetup:not(.hidden), #menuLocal:not(.hidden), #menuOnline:not(.hidden) {
  display: flex; flex-direction: column; justify-content: flex-start; flex: 1 0 auto; gap: 16px; padding: 0;
}
#menu .menuHeading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin: 0 0 8px; }
#menu .menuHeading h2, #menuSetup #selectedOpponent { margin: 0; text-align: left; font-size: 24px; line-height: 1.25; color: #efd08b; }
#menu .menuHeading button.menuBack, #menuSetup .menuHeading #btnBackSetup {
  flex: 0 0 auto; width: auto; margin: 0; padding: 8px 0 8px 12px; font-size: 14px;
  background: transparent; border: 0; box-shadow: none; color: #cdb78f; text-decoration: underline; text-underline-offset: 3px;
}
#menuAI:not(.hidden) { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto repeat(5, minmax(76px, 1fr)); flex: 0 0 auto; gap: 16px; }
#menuAI > .menuHeading { flex: 0 0 auto; justify-content: center; margin-bottom: 8px; }
#menuAI > .menuHeading h2 { text-align: center; }
#menu.overlay > .panel > .menuBack, #setupActions > #btnBackSetup, #profile #btnProfileClose { flex: 0 0 auto; width: 100%; min-height: 48px; margin: 0; padding: 12px 18px; font-size: 16px; border-radius: 10px; color: #f6dfac; background: #ffffff0d; border: 1px solid #d9b87588; }
#menuAI > button.char { flex: 0 0 auto; min-height: 76px; padding: 12px 20px; align-content: center; row-gap: 4px; }
#menuAI > button.char .chName { font-size: 20px; line-height: 1.3; }
#menuAI > button.char .chSub { font-size: 14px; line-height: 1.4; }
#menu #variantPick, #menuSetup #variantPick { gap: 8px; margin: 0; }
#menu .pickLabel, #menuSetup .pickLabel { font-size: 14px; line-height: 1.4; }
#menu #variantPick button.seg, #menuSetup #variantPick button.seg { min-height: 44px; padding: 10px 12px; font-size: 18px; }
#menuSetup #setupAppearance { margin: 8px 0; gap: 16px; }
#menuSetup .setupAppearanceGroup h3 { font-size: 14px; line-height: 1.4; margin: 0 0 8px; }
#menuSetup .matchFormat { margin: 0; min-height: 40px; font-size: 16px; line-height: 1.4; }
#menuSetup #matchHint { margin: 0; font-size: 14px; line-height: 1.4; }
#menuSetup #btnStartAI, #menuLocal #btnStartLocal {
  margin: auto 0 0; width: 100%; min-height: 48px; padding: 12px 16px; font-size: 20px; line-height: 1.3;
}
#menuFooter { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid #d9a75a22; }
#menuFooter #langSwitch { margin: 0; }
#menuFooter #contacts, #menuFooter #copyright { display: block; margin: 0; font-size: 11px; line-height: 1.4; }
@media (max-width: 480px), (max-height: 650px) {
  #menu.overlay { padding: 10px; }
  #menu.overlay > .panel { height: calc(100dvh - 20px); padding: 16px; gap: 20px; }
  #menu.overlay > .panel h1.logo .logoSvg { width: min(250px, 85%); }
  #menuFooter { gap: 4px; padding-top: 10px; }
  #menu .menuHeading h2, #menuSetup #selectedOpponent { font-size: 22px; }
}
@media (max-width: 480px) {
  #menu #menuContent > #btnContinue, #menuMain > button.modeCard { padding: 12px 30px 12px 12px; font-size: 18px; }
  #menu #btnCollection .tablePreview { width: clamp(108px, 32vw, 162px); flex-basis: clamp(108px, 32vw, 162px); }
  #menu #setupAppearance { display: block; }
  #menuSetup .setupAppearanceGroup { margin: 0 0 12px; }
}

@media (max-height: 800px) and (min-width: 481px) {
  #menuSetup:not(.hidden), #menuAI:not(.hidden) { gap: 12px; }
  #menu .menuHeading { margin-bottom: 0; }
  #menuSetup #setupAppearance { margin: 0; }
  #menuSetup .setupSample canvas { height: 44px; }
}


#menuSetup:not(.hidden) { flex: 0 0 auto; gap: 16px; }
#menuSetup .menuHeading { justify-content: center; margin: 0; }
#menuSetup #selectedOpponent { text-align: center; }
#menuSetup #setupAppearance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
#menuSetup .setupAppearanceGroup { display: block; margin: 0; }
#menuSetup .setupSamples { display: grid; grid-auto-rows: 88px; gap: 8px; padding: 2px; overflow: visible; }
#menuSetup .setupSample { width: 100%; min-width: 0; height: 88px; }
#menuSetup .setupSample canvas { height: 58px; }
#menuSetup .sampleName { font-size: 12px; }
#matchPick { display: flex; flex-direction: column; gap: 8px; }
#matchPick .choiceSegments { display: flex; }
#matchPick button.seg { flex: 1; min-width: 0; min-height: 44px; padding: 10px 8px; border: 1px solid transparent; background: transparent; color: #f3ead8; font-size: 16px; }
#matchPick button.seg.on { background: linear-gradient(#efd08b, #c79849); color: #2b1b09; border-color: #f4dca0; }
#menu #setupActions { flex: 0 0 auto; display: grid; gap: 10px; }
#setupActions > button { width: 100%; min-height: 48px; margin: 0; padding: 12px 18px; font-size: 20px; }
#setupActions > #btnBackSetup { min-height: 48px; font-size: 16px; background: #ffffff0d; border-color: #d9b87588; color: #f6dfac; }
@media (max-width: 480px) {
  #menuSetup #setupAppearance { grid-template-columns: minmax(0, 1fr); }
  #menuSetup .setupSamples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


#menuSetup .setupLargePreview { display: block; width: 108px; height: 144px; margin: 0 auto 12px; object-fit: contain; pointer-events: none; }
@media (min-width: 960px) {
  #menuSetup .setupLargePreview { position: fixed; top: 50%; width: min(220px, calc((100vw - 624px) / 2)); height: auto; margin: 0; transform: translateY(-50%); filter: drop-shadow(0 12px 14px #0009); }
  #menuSetup .setupLargePreview-checkers { right: calc(50% + 300px); }
  #menuSetup .setupLargePreview-dice { left: calc(50% + 300px); }
}

.cosmeticSelectable { cursor: pointer; }
.cosmeticSelectable:hover { border-color: #e8bf6d; background: #ffffff08; }


#menuOnline > .menuHeading { justify-content: center; }
#menuOnline > .menuHeading h2 { text-align: center; }

#menuOnline:not(.hidden) { flex: 0 0 auto; gap: 10px; padding-bottom: 6px; }
#menuOnline > .menuHeading { margin: 0; }
#menuOnline .onlinePane { gap: 10px; }
#menuOnline .onHead, #menuOnline .onHint { margin: 0; }
#menuOnline #onlineTabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#menuOnline #onlineTabs button { min-height: 44px; padding: 8px; }
#menuOnline .onlinePane > button { min-height: 48px; padding: 10px 16px; font-size: 20px; }
#menuOnline #roomCode { min-height: 44px; box-sizing: border-box; padding: 8px 12px; font-size: 20px; }
#menuOnline #joinRow > button { min-height: 44px; padding: 8px 18px; }
#onlineNote:empty { display: none; }


#menuOnline:not(.hidden) { gap: 24px; padding-bottom: 4px; }
#menuOnline #onlineTabs { gap: 0; padding: 4px; border: 1px solid #856131; border-radius: 14px; background: #160e08aa; }
#menuOnline #onlineTabs button { min-height: 52px; margin: 0; border: 1px solid transparent; border-radius: 10px; font-size: 18px; }
#menuOnline #onlineTabs button.on { background: linear-gradient(#efd08b, #c79849); border-color: #f4dca0; color: #2b1b09; }
#menuOnline #variantPick { gap: 8px; }
#menuOnline #variantPick .pickLabel { font-size: 13px; color: #cdb78f; }
#menuOnline #variantPick button.seg { min-height: 40px; padding: 8px 12px; font-size: 16px; }
#menuOnline #variantPick button.seg.on { background: #d9a75a24; border-color: #cdb78f; color: #fff1d5; box-shadow: none; }
#menuOnline .onlinePane { gap: 12px; }
#menuOnline .orLine { margin: 4px 0; }
#menuOnline #joinRow > button { background: #d9a75a24; border: 1px solid #cdb78f; color: #fff1d5; box-shadow: none; }
@media (max-width: 480px), (max-height: 650px) {
  #menuOnline:not(.hidden) { gap: 20px; }
  #menuOnline #onlineTabs button { font-size: 16px; }
}


#menu #roomBox:not(.hidden) { display: flex; flex-direction: column; align-items: stretch; gap: 20px; font-size: 16px; }
#roomBox > .menuHeading { justify-content: center; margin: 0; }
#roomBox > .menuHeading h2 { text-align: center; }
#roomBox .onHint { margin: 0; font-size: 14px; line-height: 1.5; color: #cdb78f; }
.roomInviteBlock { display: flex; flex-direction: column; gap: 10px; text-align: center; }
#roomLink { box-sizing: border-box; width: 100%; min-width: 0; padding: 12px; font-size: 14px; border: 1px solid #856131; border-radius: 10px; background: #160e08aa; color: #f3ead8; }
#roomBox button { width: 100%; min-height: 48px; margin: 0; padding: 12px; font-size: 18px; }
#roomBox #roomShow { font-size: 28px; }
#roomNote { font-size: 14px; text-align: center; color: #cdb78f; }
#roomNote:empty { display: none; }

#menu.overlay #roomBox > #btnEnterRoom { flex: 0 0 auto; width: 100%; min-height: 48px; margin: 0; padding: 12px 18px; font-size: 20px; }


#menuContent:has(#roomBox:not(.hidden)) { gap: 0; }
#menu #roomBox:not(.hidden) { flex: 1 0 auto; gap: 16px; }
#roomBox .onHint { text-align: center; }
#roomBox .roomInviteBlock { flex: 1 0 auto; justify-content: center; padding: 14px; border: 1px solid #85613180; border-radius: 14px; background: #160e0833; }
#roomBox #roomLink { min-height: 48px; font-size: 16px; }
#roomBox #btnCopyLink { min-height: 56px; font-size: 20px; }
.roomCodeRow { display: flex; align-items: center; gap: 16px; padding: 6px 10px; border: 1px solid #856131; border-radius: 10px; background: #160e08aa; }
#roomBox #roomShow { flex: 1; min-width: 0; font-size: 30px; letter-spacing: 4px; }
#roomBox #btnCopyCode { width: auto; flex: 0 0 auto; min-width: 136px; min-height: 52px; font-size: 16px; }
#menu.overlay #roomBox > #btnEnterRoom { min-height: 72px; padding: 18px; font-size: 24px; font-weight: 700; }
@media (max-width: 480px) {
  #roomBox .roomInviteBlock { padding: 10px; }
  .roomCodeRow { gap: 8px; padding: 6px; }
  #roomBox #btnCopyCode { min-width: 116px; padding: 10px 8px; font-size: 14px; }
  #roomBox #roomShow { font-size: 24px; letter-spacing: 2px; }
}


#menuContent:has(#menuOnline:not(.hidden)) { gap: 0; }
#menu #menuOnline:not(.hidden) { flex: 1 0 auto; gap: 16px; padding: 0; }
#menuOnline #variantPick { padding: 10px 14px; border: 1px solid #85613180; border-radius: 14px; background: #160e0833; }
#menuOnline #onlineFriend:not(.hidden), #menuOnline #friendSetup { flex: 1 0 auto; gap: 16px; }
#menuOnline .onlineActionBlock { display: flex; flex: 1 0 auto; flex-direction: column; justify-content: center; gap: 12px; padding: 14px; border: 1px solid #85613180; border-radius: 14px; background: #160e0833; }
#menuOnline #btnCreate, #menuOnline #btnQuick { flex: 0 0 auto; width: 100%; min-height: 72px; margin: 0; padding: 18px; font-size: 24px; font-weight: 700; }
#menuOnline .onHint { font-size: 14px; line-height: 1.5; text-align: center; }
#menuOnline #roomCode, #menuOnline #joinRow > button { min-height: 52px; }
#menuOnline #onlineQuick:not(.hidden) { flex: 1 0 auto; justify-content: center; gap: 16px; padding: 14px; border: 1px solid #85613180; border-radius: 14px; background: #160e0833; }
@media (max-width: 480px) {
  #menuOnline #variantPick, #menuOnline .onlineActionBlock, #menuOnline #onlineQuick:not(.hidden) { padding: 10px; }
}


#menuLocal:not(.hidden) {
  display: grid; flex: 1 1 0; min-height: 360px;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(60px, 1fr) auto auto; gap: 16px;
}
#menuLocal > .menuHeading { justify-content: center; margin: 0; }
#menuLocal > .menuHeading h2 { width: 100%; text-align: center; }
#menuLocal .localPreview { position: relative; min-height: 0; }
#menuLocal .localPreview .tablePreview { position: absolute; inset: 0; width: 100%; max-width: none; height: 100%; object-fit: contain; margin: 0; }
#menuLocal #btnStartLocal { flex: none; margin: 0; min-height: 48px; }
@media (max-width: 480px), (max-height: 650px) {
  #menuLocal:not(.hidden) { min-height: 320px; gap: 12px; }
}
#menuLocal .localPlayHint { margin: 0; text-align: center; color: #cbb58f; font-size: 15px; line-height: 1.5; }

#menuSetup .setupSample.setupLocked { border-style: dashed; background: #160e08; }
#menuSetup .setupLocked canvas { opacity: .45; }
#menuSetup .setupSamples { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 88px; gap: 6px; }
#menuSetup .setupSample, #menuSetup .setupSample.setupLocked { box-sizing: border-box; height: 88px; min-height: 0; min-width: 0; }
#menuSetup .setupSample canvas { height: 48px; }
#menuSetup .sampleName { display: block; font-size: 11px; line-height: 1.2; overflow-wrap: anywhere; }
.setupLockLabel { position: absolute; top: 3px; right: 3px; font-size: 11px; line-height: 1; }
#menuSetup #setupAppearance { gap: 10px; }
#menuSetup .setupAppearanceGroup h3 { margin-bottom: 6px; }

.unlockDialog { box-sizing: border-box; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid #856131; border-radius: 18px; background: #2d1b10; color: #f2d69f; text-align: center; }
.unlockDialog::backdrop { background: #000a; }
.unlockDialog h2 { margin: 0 0 12px; font-size: 24px; }
.unlockDialog h3 { font-size: 18px; }
.unlockDialog > canvas { display: block; width: 100%; height: 150px; object-fit: contain; }
.unlockDialog progress { width: 100%; }
.unlockDialog > button { width: 100%; min-height: 44px; margin-top: 16px; }
.unlockDialog .cosmeticCharacters { text-align: left; }
@media (max-height: 800px) and (min-width: 481px) {
  #menu.overlay > .panel:has(#menuSetup:not(.hidden)) { padding: 16px 24px; gap: 12px; }
  #menu.overlay > .panel:has(#menuSetup:not(.hidden)) h1.logo .logoSvg { width: 220px; }
  #menuSetup:not(.hidden) { gap: 8px; }
  #menuSetup > .menuHeading { min-height: 28px; }
  #menuSetup .setupSamples { grid-auto-rows: 70px; }
  #menuSetup .setupSample, #menuSetup .setupSample.setupLocked { height: 70px; }
  #menuSetup .setupSample canvas { height: 34px; }
  #menuSetup .setupAppearanceGroup h3 { margin-bottom: 4px; }
}


#menuSetup:not(.hidden) { gap: 12px; }
#menuSetup .opponentIntro { display: grid; grid-template-columns: 160px minmax(0, 1fr); column-gap: 18px; row-gap: 8px; align-content: center; margin: 4px 0; }
#opponentAvatar { grid-row: 1 / 4; width: 160px; height: 160px; object-fit: cover; border-radius: 20px; border: 1px solid #d9b87577; }
#menuSetup .opponentIntro p { margin: 0; text-align: left; font-size: 14px; line-height: 1.5; color: #cbb58f; }
#menuSetup #opponentStrength { color: #efd08b; font-weight: 600; }
#menuSetup #opponentStyle { font-size: 13px; }
@media (max-width: 480px) {
  #menuSetup .opponentIntro { grid-template-columns: 100px minmax(0, 1fr); gap: 8px 12px; }
  #opponentAvatar { width: 100px; height: 100px; grid-row: 1 / 3; }
  #menuSetup #opponentStyle { grid-column: 1 / -1; text-align: center; }
  #menuSetup .opponentIntro p { font-size: 13px; }
}
@media (max-height: 800px) and (min-width: 481px) {
  #menuSetup:not(.hidden) { gap: 8px; }
  #menuSetup #variantPick > .pickLabel, #menuSetup #matchPick > .pickLabel { display: none; }
  #menuSetup .opponentIntro { grid-template-columns: 128px minmax(0, 1fr); column-gap: 14px; row-gap: 6px; margin: 0; }
  #menuSetup #opponentAvatar { width: 128px; height: 128px; }
  #menuSetup .opponentIntro p { font-size: 13px; line-height: 1.4; }
  #menuSetup #opponentStyle { font-size: 12px; }
}


#menu #setupActions > #btnStartAI { min-height: 76px; padding: 18px 20px; font-size: 26px; font-weight: 700; line-height: 1.3; }


:is(#oppHand, #zinaHand, #lyohaHand) .mashaOnly { display: none; }
:is(#oppHand, #zinaHand, #lyohaHand).masha .mashaOnly { display: inline; }
:is(#oppHand, #zinaHand, #lyohaHand).masha .seregaOnly { display: none; }
:is(#oppHand, #zinaHand, #lyohaHand).masha.drum .f2, :is(#oppHand, #zinaHand, #lyohaHand).masha.drum .f3, :is(#oppHand, #zinaHand, #lyohaHand).masha.drum .f4 { animation: none; }


:is(#oppHand, #zinaHand, #lyohaHand).masha .handShape { transform: translateX(11px) scaleX(.9); transform-origin: 0 0; }
:is(#oppHand, #zinaHand, #lyohaHand).shuffle svg { animation: mashaShake .9s ease-in-out; }
:is(#oppHand, #zinaHand, #lyohaHand).shuffle .fing { display: none; }
:is(#oppHand, #zinaHand, #lyohaHand).shuffle .thumb { display: none; }
@keyframes mashaShake {
  0%,100% { transform: rotate(-18deg); }
  15%,35% { transform: rotate(-20deg); }
  25%,45% { transform: rotate(-16deg); }
  65% { transform: rotate(-18deg) translateY(-5px); }
}
@media (prefers-reduced-motion: reduce) {
  :is(#oppHand, #zinaHand, #lyohaHand).shuffle svg, :is(#oppHand, #zinaHand, #lyohaHand).shuffle .fing, :is(#oppHand, #zinaHand, #lyohaHand).shuffle .thumb { animation: none; }
}


:is(#oppHand, #zinaHand, #lyohaHand) .mashaFist { display: none; }
:is(#oppHand, #zinaHand, #lyohaHand) .mashaFist { display: inline; opacity: 0; }
:is(#oppHand, #zinaHand, #lyohaHand).shuffle .mashaFist { opacity: 1; }


:is(#oppHand, #zinaHand, #lyohaHand).shuffle .openPalm { display: none; }


#lyohaHand.hidden, #zinaHand.hidden { display: none; }
#zinaHand.masha .handShape { transform: translateX(-3px) scaleX(1.03); }


#oppHand:not(.masha) .seregaSleeveOffset { transform: translateY(100px); }

#btnInviteLink .copyStatus, #btnInviteLink.copied svg { display: none; }
#btnInviteLink.copied .copyStatus { display: inline; }


#menu .timePick .choiceSegments { display: flex; }
#menu .timePick button.seg { flex: 1; width: auto; margin: 0; padding: 10px 12px; border: 0; border-radius: 11px; background: transparent; box-shadow: none; font-size: 14px; color: #f3ead8; opacity: 1; }
#menu .timePick button.seg.on { background: #d6b25e; color: #24160b; }
#hudStatus { display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; gap: 16px; }
#hudStatus #status { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#turnClock { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; white-space: nowrap; line-height: 26px; font-size: 22px; color: #f7deb1; font-variant-numeric: tabular-nums; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: #f7deb118; }
#turnClock.urgent { color: #ff9d83; }

#menu .timePick { flex-direction: column; gap: 8px; margin: 0; }

#menuOnline .onHint[data-i18n="timeRules"], #menuOnline .onHint[data-i18n="timeSearchHint"] { font-size: 13px; line-height: 1.35; }

#turnClock.hidden { display: none; }
#turnClockMisses { font-size: 12px; line-height: 16px; font-weight: 500; color: #ddc9a7; }
@media (max-width: 600px) {
  #hudStatus { gap: 8px; }
  #turnClock { font-size: 18px; gap: 6px; padding: 4px 6px; }
  #turnClockMisses { font-size: 10px; }
}

#menuOnline #btnQuick.searching { display: flex; align-items: center; justify-content: center; gap: 12px; opacity: 1; cursor: progress; }
#menuOnline #btnQuick.searching::before { content: ''; width: 18px; height: 18px; flex: 0 0 18px; border: 3px solid #34200b44; border-top-color: #34200b; border-radius: 50%; animation: quickSearchSpin 1s linear infinite; }
@keyframes quickSearchSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #menuOnline #btnQuick.searching::before { animation: none; } }