/* Kotoba — implementation of the Kotoba.dc designs: warm shell, wooden board,
 * rounded tiles, chunky hard-shadow buttons. */

:root {
  --face: linear-gradient(168deg, #FFF6DC 0%, #F5E2B0 55%, #EFD8A0 100%);
  --face-pending: linear-gradient(168deg, #E6FBF0 0%, #C8F0DC 55%, #B6E8CE 100%);
  --edge: #C09A5E;
  --ink-tile: #4A3418;
  --ink-blank: #2F6FE0;
  --green: #35C08A;
  --green-deep: #1E9A6E;
  --coral: #FF7A66;
  --coral-deep: #E0503C;
  --shell: #FFF6E6;
  --card-edge: #EFE2C9;
  --btn-edge: #E4D8C2;
  --cream: #F6EDDA;
  --ink: #2B2622;
  --ink-soft: #6B5F50;
  --ink-faint: #A2937F;
  --ink-dim: #B0A08A;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { touch-action: manipulation; }
body {
  min-height: 100vh;
  padding: 26px 16px 44px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: radial-gradient(120% 80% at 15% 0%, #F3F9E9 0%, #E4F2EF 45%, #DCEBF6 100%);
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: none; background: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
input:focus { outline: none; }
[hidden] { display: none !important; }

.baloo { font-family: 'Baloo 2', cursive; }

/* ── Shell ─────────────────────────────────────────────── */

#shell {
  width: 402px;
  max-width: 100%;
  min-height: 868px;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--shell);
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 34px 70px -24px rgba(48, 38, 26, .42), 0 0 0 1px rgba(43, 38, 34, .07), inset 0 1px 0 rgba(255, 255, 255, .9);
}
body.big #shell { width: min(700px, 100%); min-height: 740px; }

/* Breakpoint helpers: .d-only appears only on desktop, .m-only vanishes there. */
body:not(.desk) .d-only { display: none !important; }
body.desk .m-only { display: none !important; }

/* The game surfaces are tap targets, not text. */
#board, #rack, .actions, .dhead, .game-head, .players, .turnbar {
  user-select: none;
  -webkit-user-select: none;
}

/* Chunky press feedback */
.pressable { transition: transform .08s; }
.pressable:active { transform: translateY(2px); }

/* ── Game screen ───────────────────────────────────────── */

#game { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 0 92px; }
body.big #game { padding: 18px 22px 104px; }
#game .content { width: 100%; display: flex; flex-direction: column; }
body.big #game .content { max-width: 700px; }

.game-head { padding: 16px 16px 8px; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 13px; background: #fff;
  display: flex; align-items: center; justify-content: center; gap: 2.5px;
  box-shadow: 0 3px 0 var(--btn-edge);
  position: relative;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }
.icon-btn .dot { width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--ink-soft); }
.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: #FF6B5A; color: #fff;
  font-size: 10px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2.5px var(--shell);
}
.head-mid { flex: 1; min-width: 0; }
.head-title { font-size: 15px; font-weight: 900; font-family: 'Baloo 2', cursive; line-height: 1.1; }
.head-code { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.head-code .lbl { font-size: 10px; font-weight: 800; letter-spacing: .08em; color: var(--ink-faint); }
.head-code .code { font-size: 10px; font-weight: 900; letter-spacing: .12em; color: var(--ink-soft); background: #F2E7D0; padding: 2px 6px; border-radius: 6px; }

.players { display: flex; gap: 8px; padding: 2px 16px 8px; }
.pcard {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 18px;
  background: #FBF2E0; box-shadow: 0 3px 0 #F1E5CE;
  transition: background .25s, box-shadow .25s;
}
.pcard.active { background: #fff; }
.pcard.active.me { box-shadow: 0 4px 0 var(--card-edge), 0 0 0 2.5px #9BE3C6; }
.pcard.active.opp { box-shadow: 0 4px 0 var(--card-edge), 0 0 0 2.5px #FFC3B8; }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 11px;
  color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.me .avatar { background: var(--green); }
.opp .avatar { background: var(--coral); }
.pcard .pname { font-size: 11px; font-weight: 800; color: #8B7C68; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pscore { font-family: 'Baloo 2', cursive; font-size: 19px; font-weight: 800; line-height: 1; color: #3A322A; }
.pcard .pmid { min-width: 0; flex: 1; }
.pcard .pdot { width: 9px; height: 9px; border-radius: 50%; background: #E3D7BF; transition: background .25s; }
.pcard.active.me .pdot { background: var(--green); box-shadow: 0 0 0 4px rgba(53, 192, 138, .18); }
.pcard.active.opp .pdot { background: var(--coral); box-shadow: 0 0 0 4px rgba(255, 122, 90, .18); }

.turnbar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 2px 16px 10px; }
.turn-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 9px; border-radius: 14px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .08);
  color: #fff; font-size: 12px; font-weight: 900; letter-spacing: .01em;
}
.turn-pill.mine { background: linear-gradient(178deg, #41D199, #2FB683); }
.turn-pill.theirs { background: linear-gradient(178deg, #FF9686, #FF6B5A); }
.turn-pill .arrow {
  width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, .32);
  display: flex; align-items: center; justify-content: center;
  animation: kb-bob 1.6s ease-in-out infinite;
}
.dots { display: flex; gap: 3px; align-items: center; }
.dots span { width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: kb-dot 1.1s infinite; }
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
.bag-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 14px; background: #F2E7D0;
  font-size: 11px; font-weight: 900; color: #7E7058;
}

/* ── Board ─────────────────────────────────────────────── */

.board-wrap { padding: 0 16px; }
.board-frame {
  position: relative;
  padding: 11px;
  border-radius: 24px;
  background: linear-gradient(168deg, #E9B274 0%, #D0913F 52%, #BC7A2C 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), inset 0 -3px 8px rgba(90, 50, 10, .28), 0 7px 0 #A4652A, 0 20px 28px -14px rgba(70, 44, 14, .55);
}
body.big .board-frame { padding: 14px; }
.board-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 1.5px;
  padding: 6px;
  border-radius: 13px;
  background: #7C5C3B;
  box-shadow: inset 0 3px 8px rgba(40, 20, 4, .45);
}
.sq {
  position: relative;
  aspect-ratio: 1;
  border-radius: 3.5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 rgba(90, 60, 25, .14), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: background .2s;
}
.sq span { font-size: 6.2px; font-weight: 900; letter-spacing: .01em; line-height: 1; }
body.big .sq span { font-size: 9.5px; }
.sq.p0 { background: #FFF8EA; } .sq.p0 span { color: #C7B79C; }
.sq.p1 { background: #B7E1EF; } .sq.p1 span { color: #3D7E92; }
.sq.p2 { background: #4CA6CE; } .sq.p2 span { color: #EAF7FD; }
.sq.p3 { background: #FFC0B0; } .sq.p3 span { color: #B4604F; }
.sq.p4 { background: #FF7A66; } .sq.p4 span { color: #FFF0EC; }
.sq.p5 { background: #FFC94D; } .sq.p5 span { color: #8A5F13; }

/* ── Tiles (rounded "tablet" style on every screen size) ── */

.stile { position: absolute; }
.stile .edge {
  position: absolute; inset: 0;
  border-radius: 6px; background: var(--edge);
  box-shadow: 0 2px 0 #A9863F, 0 3px 5px -2px rgba(70, 45, 15, .45);
}
.stile .face {
  position: absolute; left: 1.5px; right: 1.5px; top: 1.5px; bottom: 3px;
  border-radius: 5px; background: var(--face);
  display: flex; align-items: center; justify-content: center;
}
.stile b {
  position: relative; z-index: 2;
  font-family: 'Baloo 2', cursive; font-weight: 800; line-height: 1;
  color: var(--ink-tile);
}
.stile u {
  position: absolute; right: 2.5px; bottom: 1.5px; z-index: 3;
  text-decoration: none; font-weight: 900; line-height: 1;
  color: var(--ink-tile); opacity: .7;
}
.stile.blank b { color: var(--ink-blank); }
.stile.pending { transform: translateY(-2px); }
.stile.pending .edge { background: #2FB683; box-shadow: 0 3px 0 #1E8B63, 0 6px 8px -3px rgba(20, 90, 60, .5); }
.stile.pending .face { background: var(--face-pending); }
.stile.selected { transform: translateY(-8px); }
.stile.selected .edge { background: #FF9F1C; box-shadow: 0 5px 0 #DE7F26, 0 12px 16px -6px rgba(190, 110, 10, .5); }

.sq .stile { inset: -1px; z-index: 2; transition: transform .18s cubic-bezier(.34, 1.56, .64, 1); }
.sq .stile b { font-size: 12.5px; margin-top: 2px; }
.sq .stile u { font-size: 6px; }
body.big .sq .stile b { font-size: 21px; }
body.big .sq .stile u { font-size: 9px; }

/* Score pop */
.pop {
  position: absolute; z-index: 9; pointer-events: none;
  animation: kb-pop 1.25s cubic-bezier(.22, 1, .36, 1) forwards;
}
.pop > div {
  padding: 5px 12px; border-radius: 14px; color: #fff;
  font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 20px; line-height: 1; white-space: nowrap;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .18), 0 10px 18px -6px rgba(0, 0, 0, .4);
}

/* ── Status ────────────────────────────────────────────── */

#status {
  min-height: 40px; display: flex; align-items: center; justify-content: center;
  padding: 9px 18px 3px;
  font-size: 12.5px; font-weight: 800; text-align: center; color: #7E9C86;
}
#status.err { color: #E0503C; animation: kb-shake .4s cubic-bezier(.36, .07, .19, .97); }

/* ── Rack ──────────────────────────────────────────────── */

.dock { padding: 2px 16px 0; }
.rack-tray {
  padding: 8px 10px 11px; border-radius: 20px;
  background: linear-gradient(170deg, #D8B98A, #C09A63 60%, #B08748);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 5px 0 #96703C, 0 14px 20px -12px rgba(70, 44, 14, .5);
}
#rack { display: flex; gap: min(1.3vw, 6px); justify-content: center; }
#rack .slot {
  position: relative; width: min(11.4vw, 52px); height: min(11.4vw, 52px); flex: none; cursor: pointer;
  animation: kb-rack-in .42s cubic-bezier(.34, 1.56, .64, 1) both;
}
body.big #rack .slot { width: 60px; height: 60px; }
#rack .stile { inset: 0; transition: transform .2s cubic-bezier(.34, 1.56, .64, 1); }
#rack .stile .edge { border-radius: 11px; }
#rack .stile .face { border-radius: 9px; left: 2px; right: 2px; top: 2px; bottom: 4px; }
#rack .stile b { font-size: min(6vw, 27px); margin-top: 2px; }
#rack .stile u { font-size: 10px; right: 5px; bottom: 4px; }
body.big #rack .stile b { font-size: 31px; }
body.big #rack .stile u { font-size: 12px; }
#rack .empty { position: absolute; inset: 0; border-radius: 11px; background: rgba(90, 60, 25, .16); }

/* ── Action buttons ────────────────────────────────────── */

.actions { display: flex; gap: 7px; padding: 12px 0 0; }
.actions .act {
  flex: 1; height: 52px; border-radius: 19px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  box-shadow: 0 4px 0 var(--btn-edge);
}
.actions .act:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.actions .act small { font-size: 9.5px; font-weight: 900; color: #7E7058; line-height: 1; }
#playBtn {
  flex: 1.45; height: 52px; border-radius: 19px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(178deg, #BFDCCD, #A8CDBA);
  box-shadow: 0 4px 0 #93BCA7;
  transition: background .2s;
}
#playBtn .t { font-family: 'Baloo 2', cursive; font-size: 16px; font-weight: 800; color: #fff; line-height: 1.05; }
#playBtn .s { font-size: 10px; font-weight: 800; color: rgba(255, 255, 255, .8); line-height: 1; }
#playBtn.ready { background: linear-gradient(178deg, #41D199, #2FB683); box-shadow: 0 4px 0 var(--green-deep), 0 12px 18px -10px rgba(30, 154, 110, .7); }
#playBtn.ready:active { transform: translateY(3px); box-shadow: 0 1px 0 #157E57; }

.log-strip {
  margin: 13px 16px 0; padding: 9px 12px; border-radius: 16px; background: var(--cream);
  display: flex; align-items: center; gap: 9px; cursor: pointer;
}
.log-strip .lbl { font-size: 9.5px; font-weight: 900; letter-spacing: .09em; color: var(--ink-dim); flex: none; }
.log-strip .txt { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Drawer (chat / log) ───────────────────────────────── */

#drawer { position: absolute; inset: 0; z-index: 60; pointer-events: none; background: rgba(43, 38, 34, 0); transition: background .28s; }
#drawer.open { pointer-events: auto; background: rgba(43, 38, 34, .42); }
#drawer .scrim { position: absolute; inset: 0; }
#drawer .panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: 520px;
  border-radius: 30px 30px 36px 36px; background: #FFFDF7;
  box-shadow: 0 -12px 32px -12px rgba(60, 44, 20, .4);
  transform: translateY(105%);
  transition: transform .34s cubic-bezier(.32, 1.2, .5, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
#drawer.open .panel { transform: translateY(0); }
.drawer-handle { padding: 10px 16px 0; display: flex; justify-content: center; }
.drawer-handle i { width: 46px; height: 5px; border-radius: 3px; background: #E7DCC4; }
.drawer-tabs { display: flex; gap: 5px; padding: 11px 16px 10px; }
.drawer-tabs .tab {
  flex: 1; height: 38px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--cream); color: #8B7C68; font-size: 12.5px; font-weight: 900;
}
.drawer-tabs .tab.on { background: var(--ink); color: #fff; }
.drawer-tabs .x { width: 38px; height: 38px; flex: none; border-radius: 14px; background: var(--cream); display: flex; align-items: center; justify-content: center; }

#chatPane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chatList { flex: 1; overflow-y: auto; padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 9px; }
.msg { display: flex; flex-direction: column; animation: kb-in-up .3s ease both; }
.msg.mine { align-items: flex-end; }
.msg.theirs { align-items: flex-start; }
.msg .bubble {
  max-width: 78%; padding: 9px 13px;
  font-size: 13px; font-weight: 700; line-height: 1.35; text-wrap: pretty;
}
.msg.mine .bubble { border-radius: 18px 18px 6px 18px; background: var(--green); color: #fff; box-shadow: 0 2px 0 var(--green-deep); }
.msg.theirs .bubble { border-radius: 18px 18px 18px 6px; background: var(--cream); color: #4A3E30; box-shadow: 0 2px 0 #EADDC2; }
.msg .meta { margin-top: 3px; font-size: 9.5px; font-weight: 800; color: #BFB09A; }
.quick { padding: 4px 16px 8px; display: flex; gap: 6px; overflow-x: auto; }
.quick button { flex: none; padding: 7px 12px; border-radius: 13px; background: var(--cream); font-size: 11.5px; font-weight: 800; color: #7E7058; white-space: nowrap; }
.chat-input { padding: 6px 16px 20px; display: flex; gap: 8px; align-items: center; }
.chat-input input {
  flex: 1; min-width: 0; height: 46px; padding: 0 15px;
  border: none; border-radius: 17px; background: var(--cream);
  font-size: 13px; font-weight: 700; color: #4A3E30;
}
.chat-input .send {
  width: 46px; height: 46px; flex: none; border-radius: 17px; background: var(--green);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 var(--green-deep);
}
.chat-input .send:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-deep); }

#logPane { flex: 1; overflow-y: auto; padding: 4px 16px 26px; display: flex; flex-direction: column; gap: 7px; }
.logrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 17px; background: #FBF6EA; }
.logrow.latest { background: #F4FBF7; }
.logrow .mini { width: 27px; height: 27px; flex: none; border-radius: 10px; color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.logrow .what { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 800; color: #3A322A; }
.logrow .pts { font-family: 'Baloo 2', cursive; font-size: 15px; font-weight: 800; }

/* ── Sheets ────────────────────────────────────────────── */

#sheet { position: absolute; inset: 0; z-index: 70; pointer-events: none; background: rgba(43, 38, 34, 0); transition: background .25s; display: flex; align-items: flex-end; }
#sheet.open { pointer-events: auto; background: rgba(43, 38, 34, .42); }
#sheet .scrim { position: absolute; inset: 0; }
#sheet .card {
  position: relative; width: 100%; padding: 18px 16px 22px;
  border-radius: 30px 30px 36px 36px; background: #FFFDF7;
  box-shadow: 0 -12px 32px -12px rgba(60, 44, 20, .4);
  transform: translateY(108%); transition: transform .3s cubic-bezier(.32, 1.2, .5, 1);
}
#sheet.open .card { transform: translateY(0); }
.sheet-title { font-family: 'Baloo 2', cursive; font-size: 19px; font-weight: 800; }
.sheet-sub { margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--ink-faint); }

#blankGrid { margin-top: 14px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
#blankGrid .slot { position: relative; height: 44px; cursor: pointer; }
#blankGrid .slot:active { transform: translateY(2px); }
#blankGrid .stile { inset: 0; }
#blankGrid .stile .edge { border-radius: 10px; }
#blankGrid .stile .face { border-radius: 8px; }
#blankGrid .stile b { font-size: 18px; margin-top: 1px; color: var(--ink-blank); }

#swapRow { margin-top: 16px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
#swapRow .slot { position: relative; width: 46px; height: 46px; cursor: pointer; }
#swapRow .stile { inset: 0; transition: transform .18s cubic-bezier(.34, 1.56, .64, 1); }
#swapRow .stile .edge { border-radius: 11px; }
#swapRow .stile .face { border-radius: 9px; }
#swapRow .stile b { font-size: 24px; margin-top: 1px; }
#swapRow .stile.selected { transform: translateY(-9px); }
.sheet-btns { display: flex; gap: 9px; margin-top: 20px; }
.sheet-btns .ghost { flex: 1; height: 50px; border-radius: 18px; background: var(--cream); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 900; color: #7E7058; }
#swapGo {
  flex: 1.3; height: 50px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Baloo 2', cursive; font-size: 16px; font-weight: 800; color: #fff;
  background: #D9CDB6; box-shadow: 0 4px 0 #C3B69D;
}
#swapGo.ready { background: linear-gradient(178deg, #FFB84B, #FF9F1C); box-shadow: 0 4px 0 #DE7F26; }

#menuList { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
#menuList .item { display: flex; align-items: center; gap: 11px; padding: 14px; border-radius: 19px; background: #FBF6EA; }
#menuList .item:active { transform: translateY(2px); }
#menuList .item.danger { background: #FFF1EE; }
#menuList .glyph { width: 30px; height: 30px; flex: none; border-radius: 11px; color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center; }
#menuList .item span:last-child { flex: 1; font-size: 13.5px; font-weight: 900; color: #3A322A; }
#menuList .item.danger span:last-child { color: #D8452F; }

/* ── Results ───────────────────────────────────────────── */

#results {
  position: absolute; inset: 0; z-index: 80; overflow-y: auto;
  background: radial-gradient(110% 60% at 50% 0%, #FFF2CE 0%, #FFF6E6 55%, #FFF6E6 100%);
  padding: 26px 18px 30px;
  display: flex; flex-direction: column; align-items: center;
}
body.big #results { padding: 40px 26px 40px; }
#results .inner { width: 100%; display: flex; flex-direction: column; gap: 14px; }
body.big #results .inner { max-width: 520px; }
.res-over { font-size: 12px; font-weight: 900; letter-spacing: .16em; color: #C4A76B; text-align: center; }
.res-headline { margin-top: 5px; font-family: 'Baloo 2', cursive; font-size: 31px; font-weight: 800; line-height: 1.1; text-align: center; }
.res-sub { margin-top: 3px; font-size: 12.5px; font-weight: 800; color: var(--ink-faint); text-align: center; }
#bestWordTiles { display: flex; justify-content: center; gap: 5px; padding: 4px 0 2px; }
#bestWordTiles .slot { position: relative; width: 40px; height: 40px; animation: kb-rack-in .5s cubic-bezier(.34, 1.56, .64, 1) both; }
#bestWordTiles .stile { inset: 0; }
#bestWordTiles .stile .edge { border-radius: 11px; }
#bestWordTiles .stile .face { border-radius: 9px; }
#bestWordTiles .stile b { font-size: 21px; margin-top: 1px; }
.res-caption { text-align: center; font-size: 11.5px; font-weight: 900; color: var(--ink-dim); letter-spacing: .04em; margin-top: -4px; }
.res-scores { padding: 15px; border-radius: 24px; background: #fff; box-shadow: 0 4px 0 var(--card-edge); display: flex; flex-direction: column; gap: 13px; }
.res-row .head { display: flex; align-items: center; gap: 9px; }
.res-row .head span { flex: 1; font-size: 13.5px; font-weight: 900; color: #3A322A; }
.res-row .head b { font-family: 'Baloo 2', cursive; font-size: 21px; font-weight: 800; }
.res-row .track { margin-top: 7px; height: 11px; border-radius: 7px; background: #F4EBD8; overflow: hidden; }
.res-row .bar { height: 100%; border-radius: 7px; transition: width .6s cubic-bezier(.22, 1, .36, 1); }
.res-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.res-stats > div { padding: 12px 9px; border-radius: 19px; background: #FFF9EC; box-shadow: 0 3px 0 #F0E4CD; text-align: center; }
.res-stats b { font-family: 'Baloo 2', cursive; font-size: 20px; font-weight: 800; line-height: 1; color: #3A322A; display: block; }
.res-stats small { margin-top: 4px; font-size: 10px; font-weight: 800; color: var(--ink-faint); line-height: 1.2; display: block; }
.btn-green {
  height: 56px; border-radius: 20px; width: 100%;
  background: linear-gradient(178deg, #41D199, #2FB683);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 5px 0 var(--green-deep);
  font-family: 'Baloo 2', cursive; font-size: 18px; font-weight: 800; color: #fff;
}
.btn-green:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-deep); }
.btn-plain {
  height: 52px; border-radius: 20px; width: 100%;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #7E7058;
  box-shadow: 0 4px 0 var(--card-edge);
}
.btn-plain:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--card-edge); }

/* ── Lobby ─────────────────────────────────────────────── */

#lobby, #profile {
  flex: 1; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; align-content: start; gap: 14px;
  padding: 20px 16px 100px;
}
body.big #lobby, body.big #profile { max-width: 620px; padding: 26px 24px 110px; }
body.desk #lobby, body.desk #profile { max-width: 1000px; display: grid; grid-template-columns: 1fr 1fr; }
body.desk #lobby > .span2, body.desk #profile > .span2 { grid-column: 1 / -1; }

.lobby-head { display: flex; align-items: flex-start; gap: 10px; }
#logoTiles { display: flex; gap: 3px; align-items: flex-end; }
#logoTiles .slot { position: relative; width: 28px; height: 28px; }
#logoTiles .stile { inset: 0; }
#logoTiles .stile .edge { border-radius: 7px; }
#logoTiles .stile .face { border-radius: 6px; }
#logoTiles .stile b { font-size: 15px; margin-top: 1px; }
.tagline { margin-top: 7px; font-size: 12px; font-weight: 800; color: var(--ink-faint); }
.lang-pills { display: flex; padding: 3px; border-radius: 13px; background: #F2E7D0; }
.lang-pills button { padding: 4px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 900; color: var(--ink-dim); }
.lang-pills button.on { background: #fff; color: #3A322A; box-shadow: 0 2px 0 var(--btn-edge); }

.card {
  padding: 15px 15px 16px; border-radius: 26px;
  background: linear-gradient(160deg, #FFFFFF, #FFF9EC);
  box-shadow: 0 4px 0 var(--card-edge), 0 18px 26px -18px rgba(80, 60, 30, .4);
}
.card-title { font-family: 'Baloo 2', cursive; font-size: 19px; font-weight: 800; line-height: 1.15; }
.card-sub { margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--ink-faint); text-wrap: pretty; }
.name-row { margin-top: 12px; display: flex; align-items: center; gap: 8px; }
.name-row label { font-size: 11px; font-weight: 900; color: var(--ink-faint); flex: none; }
.name-row input {
  flex: 1; min-width: 0; height: 40px; padding: 0 13px;
  border: none; border-radius: 14px; background: var(--cream);
  font-size: 14px; font-weight: 800; color: #4A3E30;
}
.btn-create {
  margin-top: 12px; width: 100%; height: 54px; border-radius: 20px;
  background: linear-gradient(178deg, #41D199, #2FB683);
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 5px 0 var(--green-deep), 0 12px 18px -10px rgba(30, 154, 110, .7);
  font-family: 'Baloo 2', cursive; font-size: 18px; font-weight: 800; color: #fff;
}
.btn-create:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-deep); }

#inviteBox { margin-top: 12px; padding: 12px; border-radius: 19px; background: #F4FBF7; box-shadow: inset 0 0 0 2px #D9F0E4; animation: kb-in-up .35s ease both; }
#inviteBox .row { display: flex; align-items: center; gap: 9px; }
#inviteBox .lbl { font-size: 9.5px; font-weight: 900; letter-spacing: .1em; color: #7FB79C; }
#inviteBox .code { font-family: 'Baloo 2', cursive; font-size: 25px; font-weight: 800; letter-spacing: .12em; line-height: 1.1; color: #1E7A57; }
#copyBtn { padding: 9px 13px; border-radius: 14px; background: #fff; font-size: 11.5px; font-weight: 900; color: #2FB683; box-shadow: 0 3px 0 #CFE9DC; }
#copyBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #CFE9DC; }
#inviteBox .wait { display: flex; align-items: center; gap: 7px; margin-top: 11px; }
#inviteBox .wait .dots span { background: #7FB79C; }
#inviteBox .wait .txt { flex: 1; font-size: 11.5px; font-weight: 800; color: #5E9E82; }
#goGameBtn { padding: 8px 13px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 900; box-shadow: 0 3px 0 #1A1613; }
#goGameBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1A1613; }

.card-random {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 24px;
  background: linear-gradient(150deg, #FFC85B, #FF9F3D);
  box-shadow: 0 5px 0 #DE7F26, 0 16px 22px -14px rgba(200, 110, 30, .7);
  cursor: pointer; text-align: left; width: 100%;
}
.card-random:active { transform: translateY(3px); box-shadow: 0 2px 0 #DE7F26; }
.card-random .big-t { font-family: 'Baloo 2', cursive; font-size: 17px; font-weight: 800; color: #fff; line-height: 1.15; }
.card-random .sub-t { margin-top: 1px; font-size: 11.5px; font-weight: 800; color: rgba(255, 255, 255, .88); }
.card-random .avatars { display: flex; align-items: center; }
.card-random .avatars i {
  width: 31px; height: 31px; margin-left: -9px; border-radius: 11px;
  color: #fff; font-family: 'Baloo 2', cursive; font-style: normal; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2.5px #FFB84B;
}

.row2 { display: flex; gap: 10px; }
.card-join { flex: 1.35; min-width: 0; padding: 13px; border-radius: 22px; background: #fff; box-shadow: 0 4px 0 var(--card-edge); }
.card-join .lbl { font-size: 11px; font-weight: 900; letter-spacing: .03em; color: var(--ink-faint); }
.card-join .row { display: flex; gap: 6px; margin-top: 9px; align-items: center; }
#joinCode {
  flex: 1; width: 0; min-width: 0; height: 40px; border: none; border-radius: 14px;
  background: var(--cream); text-align: center;
  font-family: 'Baloo 2', cursive; font-size: 17px; font-weight: 800; letter-spacing: .13em; color: #4A3E30;
}
#joinBtn { width: 40px; height: 40px; flex: none; border-radius: 14px; background: #3B8ED0; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 #2A72AE; }
#joinBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #2A72AE; }
.card-solo {
  flex: 1; min-width: 0; padding: 13px; border-radius: 22px; background: var(--ink);
  box-shadow: 0 4px 0 #17130F; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: left;
}
.card-solo:active { transform: translateY(3px); box-shadow: 0 1px 0 #17130F; }
.card-solo .lbl { font-size: 11px; font-weight: 900; color: rgba(255, 255, 255, .62); }
.card-solo .who { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.card-solo .bot { width: 26px; height: 26px; border-radius: 9px; background: #8B7BF0; display: flex; align-items: center; justify-content: center; }
.card-solo .who span { font-family: 'Baloo 2', cursive; font-size: 16px; font-weight: 800; color: #fff; }
.card-solo .diffs { display: flex; gap: 4px; margin-top: 9px; }
.card-solo .diffs button { flex: 1; padding: 5px 0; border-radius: 9px; text-align: center; font-size: 9.5px; font-weight: 900; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .6); }
.card-solo .diffs button.on { background: #8B7BF0; color: #fff; }

.ongoing-head { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 4px 8px; }
.ongoing-head b { font-family: 'Baloo 2', cursive; font-size: 15px; font-weight: 800; }
.ongoing-head span { font-size: 11px; font-weight: 800; color: var(--ink-dim); }
#ongoingList { display: flex; flex-direction: column; gap: 8px; }
#ongoingList .g {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: 20px; background: #fff; box-shadow: 0 3px 0 var(--card-edge);
  cursor: pointer; width: 100%; text-align: left;
}
#ongoingList .g:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--card-edge); }
#ongoingList .mini { width: 34px; height: 34px; flex: none; border-radius: 12px; color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; }
#ongoingList .mid { flex: 1; min-width: 0; }
#ongoingList .who { font-size: 13px; font-weight: 900; color: #3A322A; }
#ongoingList .st { font-size: 11px; font-weight: 800; margin-top: 1px; }
#ongoingList .sc { font-family: 'Baloo 2', cursive; font-size: 15px; font-weight: 800; color: #3A322A; line-height: 1; text-align: right; }

/* ── Profile ───────────────────────────────────────────── */

.profile-head { display: flex; align-items: center; gap: 13px; }
.profile-avatar {
  width: 70px; height: 70px; flex: none; border-radius: 24px;
  background: linear-gradient(160deg, #4BD6A2, #2FB683);
  color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 var(--green-deep);
}
.profile-name { font-family: 'Baloo 2', cursive; font-size: 23px; font-weight: 800; line-height: 1.1; }
.profile-sub { font-size: 11.5px; font-weight: 800; color: var(--ink-faint); margin-top: 1px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stats-grid > div { padding: 13px; border-radius: 20px; }
.stats-grid b { font-family: 'Baloo 2', cursive; font-size: 25px; font-weight: 800; line-height: 1; display: block; }
.stats-grid small { margin-top: 4px; font-size: 11px; font-weight: 800; display: block; }
.sec-title { padding: 4px 4px 8px; font-family: 'Baloo 2', cursive; font-size: 15px; font-weight: 800; }
#bestList { padding: 13px; border-radius: 20px; background: #fff; box-shadow: 0 3px 0 var(--card-edge); display: flex; flex-direction: column; gap: 11px; }
#bestList .bw { display: flex; align-items: center; gap: 8px; }
#bestList .tiles { flex: 1; display: flex; gap: 3px; flex-wrap: wrap; }
#bestList .slot { position: relative; width: 26px; height: 26px; }
#bestList .stile { inset: 0; }
#bestList .stile .edge { border-radius: 7px; }
#bestList .stile .face { border-radius: 6px; }
#bestList .stile b { font-size: 14px; margin-top: 1px; }
#bestList .sc { padding: 4px 9px; border-radius: 11px; background: var(--cream); font-size: 11.5px; font-weight: 900; color: #8B7C68; }
#bestList .none { font-size: 12px; font-weight: 700; color: var(--ink-dim); }

/* ── Bottom nav ────────────────────────────────────────── */

#nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 9px 16px 14px;
  background: linear-gradient(180deg, rgba(255, 246, 230, 0) 0%, rgba(255, 246, 230, .94) 34%, var(--shell) 60%);
}
body.desk #nav { display: none; }
#nav .pill { display: flex; gap: 5px; padding: 6px; border-radius: 22px; margin: 0 auto; background: #fff; box-shadow: 0 4px 0 var(--card-edge), 0 14px 24px -14px rgba(80, 60, 30, .45); }
body.big #nav .pill { max-width: 440px; }
#nav button { flex: 1; height: 46px; border-radius: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #C0B09A; transition: background .2s; }
#nav .glyph { font-size: 16px; line-height: 1; font-family: 'Baloo 2', cursive; font-weight: 800; }
#nav small { font-size: 9.5px; font-weight: 900; line-height: 1; }
#nav button.on-home { background: #FFF2CE; color: #B0803A; }
#nav button.on-game { background: #E6F8F0; color: var(--green-deep); }
#nav button.on-me { background: #F0EDFE; color: #6A57D6; }

.error-line { font-size: 12px; font-weight: 800; color: #E0503C; margin-top: 8px; }

/* ── Animations ────────────────────────────────────────── */

@keyframes kb-pop {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  35% { transform: translate(-50%, -14px) scale(1.12); opacity: 1; }
  70% { transform: translate(-50%, -22px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -46px) scale(.92); opacity: 0; }
}
@keyframes kb-rack-in {
  0% { transform: translateY(26px) rotate(-6deg); opacity: 0; }
  100% { transform: translateY(0) rotate(0deg); opacity: 1; }
}
@keyframes kb-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@keyframes kb-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes kb-dot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes kb-in-up {
  0% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ── Menu modal: profile header + stats (all breakpoints) ─ */

.menu-profile { display: flex; align-items: center; gap: 13px; }
.menu-avatar {
  width: 56px; height: 56px; flex: none; border-radius: 19px;
  background: linear-gradient(160deg, #4BD6A2, #2FB683);
  color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 var(--green-deep);
}
/* The name is editable in place: looks like a heading, reveals itself on
 * focus. Enter or clicking away saves. */
input.menu-name {
  font-family: 'Baloo 2', cursive; font-size: 20px; font-weight: 800; line-height: 1.1;
  width: 100%; padding: 0 4px; margin-left: -4px;
  border: none; border-bottom: 2px dashed transparent; border-radius: 4px;
  background: transparent; color: var(--ink);
}
input.menu-name:hover { border-bottom-color: #E0D4BC; }
input.menu-name:focus { background: var(--cream); border-bottom-color: var(--select, #E8911B); }
.menu-sub { font-size: 11.5px; font-weight: 800; color: var(--ink-faint); margin-top: 1px; }
.menu-code {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 13px; background: #F4FBF7;
}
.menu-code span { font-size: 10.5px; font-weight: 900; color: #7FB79C; letter-spacing: .08em; }
.menu-code b { font-family: 'Baloo 2', cursive; font-size: 15px; font-weight: 800; letter-spacing: .1em; color: #1E7A57; }
.menu-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.menu-stats > div { padding: 12px 10px; border-radius: 17px; text-align: center; }
.menu-stats b { font-family: 'Baloo 2', cursive; font-size: 22px; font-weight: 800; line-height: 1; display: block; }
.menu-stats small { margin-top: 4px; font-size: 10px; font-weight: 800; line-height: 1.2; display: block; }
#menuList .hint { font-size: 11.5px; font-weight: 800; color: #BFB09A; }

/* ═══════════════════ Desktop (Kotoba Desktop.dc) ═══════════════════ */

body.desk {
  padding: 0;
  background: #DCEAE4;
  display: block;
}
body.desk #shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  border-radius: 0;
  box-shadow: none;
  background: radial-gradient(90% 70% at 50% -10%, #F6FAEC 0%, #E3F1EA 45%, #D6E7EE 100%);
}
body.desk #game { padding: 0 0 26px; }
body.desk #game .content {
  max-width: none;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 4px 28px 26px;
}

/* Header bar */
.dhead { flex: none; display: flex; align-items: center; gap: 20px; padding: 18px 28px 12px; width: 100%; }
.dlogo { display: flex; align-items: flex-end; gap: 3px; flex: none; }
.dlogo b {
  position: relative; width: 26px; height: 26px;
  border-radius: 7px; background: #C9A567; box-shadow: 0 2px 0 #A9863F;
}
.dlogo b i {
  position: absolute; left: 1.5px; right: 1.5px; top: 1.5px; bottom: 2.5px;
  border-radius: 6px; background: linear-gradient(165deg, #FFF6DC, #F0DCA8);
  display: flex; align-items: center; justify-content: center;
  font-style: normal; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 15px; color: #4A3418;
}
.dhead-mid { flex: 1; display: flex; justify-content: center; align-items: center; gap: 12px; min-width: 0; }
.dcard {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 16px 8px 10px; border-radius: 19px;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 2px 0 rgba(160, 140, 110, .22);
  transition: background .25s, box-shadow .25s;
}
.dcard.rev { padding: 8px 10px 8px 16px; }
.dcard.rev .dtext { text-align: right; }
.dcard.active { background: #fff; }
.dcard.me.active { box-shadow: 0 3px 0 rgba(160, 140, 110, .35), 0 0 0 2.5px #9BE3C6; }
.dcard.opp.active { box-shadow: 0 3px 0 rgba(160, 140, 110, .35), 0 0 0 2.5px #FFC3B8; }
.davatar {
  position: relative; width: 34px; height: 34px; flex: none; border-radius: 12px;
  color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.dcard.me .davatar { background: var(--green); }
.dcard.opp .davatar { background: var(--coral); }
.davatar .ring {
  display: none;
  position: absolute; inset: -3px; border-radius: 15px;
  animation: kd-breathe 1.9s ease-out infinite;
}
.dcard.me .ring { border: 2px solid var(--green); }
.dcard.opp .ring { border: 2px solid var(--coral); }
.dcard.active .ring { display: block; }
.dname { font-size: 11px; font-weight: 800; color: #8B7C68; line-height: 1.1; }
.dscore { font-family: 'Baloo 2', cursive; font-size: 21px; font-weight: 800; line-height: 1; color: #3A322A; }
.dturn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 16px;
  color: #fff; font-size: 12px; font-weight: 900; white-space: nowrap;
  transition: background .3s;
}
.dturn.mine { background: linear-gradient(178deg, #41D199, #2FB683); }
.dturn.theirs { background: linear-gradient(178deg, #FF9686, #FF6B5A); }
.dhead-right { flex: none; display: flex; align-items: center; gap: 8px; }
.dbag {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 13px; border-radius: 15px;
  background: rgba(255, 255, 255, .72); box-shadow: 0 2px 0 rgba(160, 140, 110, .28);
  font-size: 12px; font-weight: 900; color: #7E7058;
}
.icon-btn.big { width: 38px; height: 38px; border-radius: 14px; box-shadow: 0 3px 0 #E1D4BC; }
body.desk .badge { box-shadow: 0 0 0 2.5px #E9F2EC; }

/* Board */
body.desk .board-wrap { width: min(74vh, 660px); padding: 0; position: relative; flex: none; }
body.desk .board-frame {
  padding: 14px; border-radius: 26px;
  background: linear-gradient(168deg, #EDB878 0%, #D2933F 52%, #BC7A2C 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), inset 0 -4px 10px rgba(90, 50, 10, .26), 0 8px 0 #A4652A, 0 30px 44px -20px rgba(70, 44, 14, .6);
}
body.desk .board-grid { gap: 2px; padding: 7px; border-radius: 14px; box-shadow: inset 0 3px 9px rgba(40, 20, 4, .45); }
body.desk .sq { border-radius: 5px; }
body.desk .sq span { font-size: min(1.15vh, 10px); }
body.desk .sq.droppable { cursor: pointer; }
body.desk .sq.droppable:hover { background: #FFEFC4; box-shadow: inset 0 0 0 2px #FFB84B; }
body.desk #status {
  position: absolute; left: 0; right: 0; top: 100%;
  padding: 9px 0 0; min-height: 0;
  pointer-events: none;
}

body.desk .sq .stile b { font-size: min(2.4vh, 21px); margin-top: 1px; }
body.desk .sq .stile u { font-size: min(1.1vh, 9px); }

/* Dock: rack + actions in one floating bar */
body.desk .dock {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px; margin-top: 22px;
  border-radius: 24px; background: rgba(255, 255, 255, .82);
  box-shadow: 0 4px 0 rgba(160, 140, 110, .3), 0 20px 30px -22px rgba(70, 50, 20, .55);
  width: fit-content; flex: none;
}
body.desk .rack-tray { background: none; box-shadow: none; padding: 0; }
body.desk #rack { gap: 7px; }
body.desk #rack .slot { width: min(6.6vh, 58px); height: min(6.6vh, 58px); }
body.desk #rack .stile b { font-size: min(3.6vh, 31px); }
body.desk #rack .stile u { font-size: min(1.4vh, 12px); }
.dock-divider { width: 2px; height: 44px; border-radius: 2px; background: rgba(160, 140, 110, .24); }
body.desk .actions { padding: 0; gap: 8px; align-items: center; }
body.desk #playBtn {
  flex: none; flex-direction: row; gap: 9px;
  height: 52px; padding: 0 24px; border-radius: 18px;
}
body.desk #playBtn .t { font-size: 17px; }
#playBtn .chip {
  padding: 3px 9px; border-radius: 10px;
  background: rgba(255, 255, 255, .24);
  font-size: 12px; font-weight: 900; color: #fff;
}
body.desk .actions .act { flex: none; width: 46px; height: 52px; border-radius: 18px; box-shadow: 0 4px 0 #E1D4BC; }

/* Last-move chip, fixed bottom left */
body.desk .log-strip {
  position: fixed; left: 24px; bottom: 20px; z-index: 30;
  margin: 0; width: auto; max-width: 380px;
  padding: 9px 15px 9px 11px; border-radius: 18px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 4px 0 rgba(160, 140, 110, .3), 0 14px 22px -14px rgba(70, 50, 20, .5);
}
body.desk .log-strip:hover { transform: translateY(-2px); }
.log-strip .mini {
  width: 26px; height: 26px; flex: none; border-radius: 9px;
  color: #fff; font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
body.desk .log-strip .txt { max-width: 230px; flex: none; }
body.desk .log-strip .lbl { letter-spacing: .06em; }

/* Right panel slides in as an overlay */
body.desk #drawer { position: fixed; background: transparent !important; }
body.desk #drawer .scrim { display: none; }
body.desk #drawer .panel {
  left: auto; top: 0; right: 0; bottom: 0;
  width: 352px; height: auto;
  border-radius: 0;
  box-shadow: -14px 0 36px -18px rgba(60, 44, 20, .42);
  transform: translateX(100%);
  pointer-events: auto;
}
body.desk #drawer.open .panel { transform: translateX(0); }
body.desk .drawer-handle { display: none; }
body.desk .drawer-tabs { padding: 16px 16px 12px; }
body.desk .drawer-tabs .tab { height: 40px; }

/* Sheets become centered modals */
body.desk #sheet { align-items: center; justify-content: center; }
body.desk #sheet .card {
  width: 440px; max-width: calc(100vw - 48px);
  padding: 24px; border-radius: 28px;
  box-shadow: 0 30px 60px -20px rgba(50, 36, 16, .5);
  transform: translateY(16px) scale(.97); opacity: 0;
  transition: transform .28s cubic-bezier(.32, 1.3, .5, 1), opacity .22s;
}
body.desk #sheet.open .card { transform: translateY(0) scale(1); opacity: 1; }
body.desk #sheet.blank .card { width: 470px; }
body.desk #sheet.menu .card { width: 560px; }
body.desk #blankGrid { grid-template-columns: repeat(9, 1fr); }
body.desk #blankGrid .slot { height: auto; aspect-ratio: 1; }
body.desk #swapRow .slot { width: 54px; height: 54px; }
body.desk #swapRow .stile b { font-size: 28px; }

/* Results as a centered modal */
body.desk #results {
  background: rgba(43, 38, 34, .44);
  align-items: center; justify-content: center;
  padding: 24px;
}
body.desk #results .inner {
  max-width: 440px;
  background: #FFFDF7; border-radius: 28px; padding: 24px;
  box-shadow: 0 30px 60px -20px rgba(50, 36, 16, .5);
}
body.desk #bestWordTiles .slot { width: 42px; height: 42px; }

@keyframes kd-breathe {
  0%, 100% { transform: scale(1); opacity: .55; }
  50% { transform: scale(1.5); opacity: 0; }
}

/* ── Sound toggle & cancel affordances ─────────────────── */

.icon-btn .slash { display: none; }
.icon-btn.muted svg { opacity: .45; }
.icon-btn.muted .wave { display: none; }
.icon-btn.muted .slash { display: block; }

#cancelInviteBtn {
  padding: 8px 13px; border-radius: 14px;
  background: #fff; color: #C25B4A;
  font-size: 11.5px; font-weight: 900;
  box-shadow: 0 3px 0 #EAD6CE;
}
#cancelInviteBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #EAD6CE; }

#ongoingList .gx {
  width: 28px; height: 28px; flex: none;
  border-radius: 10px; background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  color: #B08A80; font-size: 13px; font-weight: 900;
}
#ongoingList .gx:hover { background: #FFF1EE; color: #D8452F; }


/* ═══════════════ Phone (<700px): edge-to-edge, one-screen game ═══════ */

@media (max-width: 699.9px) {
  body { padding: 0; }
  #shell {
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  /* Tighter chrome so board + rack + actions fit without scrolling. */
  #game { padding: 0 0 64px; }
  .game-head { padding: 10px 12px 6px; }
  .players { padding: 2px 12px 6px; gap: 6px; }
  .pcard { padding: 6px 9px; border-radius: 15px; }
  .pcard .pscore { font-size: 17px; }
  .turnbar { padding: 0 12px 8px; }
  .board-wrap { padding: 0 8px; }
  .board-frame { padding: 8px; border-radius: 18px; }
  .board-grid { padding: 5px; border-radius: 11px; gap: 1px; }
  #status { min-height: 30px; padding: 6px 14px 2px; font-size: 12px; }
  .dock { padding: 0 10px; }
  .rack-tray { padding: 7px 8px 9px; border-radius: 16px; }
  .actions { padding: 8px 0 0; gap: 6px; }
  .actions .act, #playBtn { height: 54px; border-radius: 16px; }
  .log-strip { margin: 8px 10px 0; padding: 8px 11px; border-radius: 13px; }
  #nav { padding: 6px 10px 10px; }
  #nav .pill { padding: 5px; border-radius: 18px; }
  #nav button { height: 42px; border-radius: 14px; }

  /* Lobby breathes a little less too. */
  #lobby, #profile { padding: 16px 14px 92px; }

  /* Sheets: full-width bottom cards with a bit less padding. */
  #sheet .card { padding: 16px 14px 20px; }
}

/* Small phones: keep seven rack tiles plus actions comfortably tappable. */
@media (max-width: 389.9px) {
  .game-head { padding: 8px 10px 5px; }
  .icon-btn { width: 34px; height: 34px; }
}
