/* The phone. #app is the visual viewport's size (phone.mjs sets --h). */
html, body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
body { background: radial-gradient(ellipse at 50% 0%, var(--field-hi) 0%, var(--field) 60%, var(--deep) 100%); }
#app { position: fixed; left: 0; right: 0; top: 0; height: var(--h, 100dvh); display: flex; flex-direction: column; padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom); }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
[hidden] { display: none !important; }
a { color: var(--ink); }
a.btn { text-align: center; text-decoration: none; }

.btn { display: block; width: 100%; border: 0; border-radius: 16px; padding: 17px; font-size: 22px; font-weight: 700; background: var(--gold); color: var(--tile-ink); cursor: pointer; box-shadow: 0 5px 0 var(--gold-edge); transition: transform 0.07s, box-shadow 0.07s; flex: none; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-edge); }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: 0 5px 0 var(--deep); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--deep); }
.shake { animation: shake 0.32s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.av { width: 30px; height: 30px; line-height: 30px; font-size: 16px; flex: none; }

/* ---- the door ---- */
#join { overflow-y: auto; }
.door { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 18px; min-height: calc(var(--h, 100dvh) - 40px); padding: 24px 0; }
.mark { margin: 0 0 4px; text-align: center; font-size: 46px; }
.lede { margin: 0; text-align: center; font-size: 18px; line-height: 1.4; color: var(--dim); }
#joinForm { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; align-items: center; gap: 12px; background: var(--deep); border: 2px solid var(--line); border-radius: 16px; padding: 0 16px; }
.field:focus-within { border-color: var(--dim); }
.field svg { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--dim); stroke-width: 2; stroke-linecap: round; }
.field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 22px; padding: 16px 0; -webkit-user-select: text; user-select: text; }
.field input::placeholder { color: var(--dim); opacity: 0.7; }
.field.code input { letter-spacing: 0.3em; text-transform: uppercase; font-weight: 700; }
.field.code input::placeholder { letter-spacing: 0; text-transform: none; font-weight: 500; }
.tvline { margin: 0; text-align: center; font-size: 16px; color: var(--dim); }
.shelf { flex: none; padding: 8px 0 4px; }
.foot { flex: none; }
.foot { text-align: center; font-size: 15px; margin: 6px 0 18px; opacity: 0.7; }

/* ---- the room ---- */
#room { padding-top: 8px; min-height: 0; }
.top { display: flex; align-items: center; gap: 10px; height: 44px; flex: none; }
.top .av { width: 34px; height: 34px; line-height: 34px; font-size: 18px; }
.me { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; flex: 1; min-width: 0; }
.score { font-size: 24px; font-weight: 700; color: var(--gold); }
.pane { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 12px; padding: 8px 0 12px; }

#lobbyPane { justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; flex: 1; overflow: auto; min-height: 0; }
.chip { flex: none; max-width: 100%; display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--deep); border: 2px solid transparent; }
.chip.me { border-color: currentColor; }
.chip small { font-size: 13px; color: var(--dim); font-weight: 500; }
.host { display: flex; flex-direction: column; gap: 10px; }
.botrow { display: flex; align-items: center; gap: 10px; }
.botrow .lab { flex: 1; font-size: 20px; font-weight: 700; }
.step { width: 50px; height: 50px; border-radius: 14px; border: 0; background: var(--tile); color: var(--tile-ink); font-size: 30px; font-weight: 700; box-shadow: 0 4px 0 var(--tile-edge); cursor: pointer; }
.step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-edge); }
.step:disabled { opacity: 0.35; }
.botn { width: 34px; text-align: center; font-size: 26px; font-weight: 700; }
.seg { display: flex; gap: 6px; background: var(--deep); padding: 5px; border-radius: 14px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 11px 4px; font-size: 17px; font-weight: 700; color: var(--dim); cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.seg.off { opacity: 0.4; }
.wait { margin: 0; text-align: center; color: var(--dim); font-size: 18px; }

/* ---- typing ---- */
#playPane { gap: 8px; }
.con { flex: none; text-align: center; }
.ctag { font-size: 14px; color: var(--dim); font-weight: 700; letter-spacing: 0.04em; }
.ctiles { font-size: 30px; margin: 6px 0 4px; }
.clabel { font-size: 17px; font-weight: 700; }
.clock { height: 8px; margin-top: 8px; border-radius: 4px; background: var(--deep); overflow: hidden; }
.clock i { display: block; height: 8px; background: var(--gold); transform-origin: 0 50%; border-radius: 4px; }
.clock.late i { background: var(--bad); }
.stagebox { flex: 1; min-height: 64px; display: flex; align-items: center; justify-content: center; position: relative; }
.ready { display: flex; flex-direction: column; align-items: center; color: var(--dim); font-size: 20px; font-weight: 700; }
.ready b { font-size: 64px; color: var(--gold); line-height: 1.1; }
.typed { font-size: 40px; text-align: center; min-height: 1.2em; }
.typed .tile { animation: tap 0.14s ease-out; }
@keyframes tap { from { transform: translateY(-0.18em) scale(1.12); } }
.typed .caret { display: inline-block; width: 3px; height: 0.9em; vertical-align: middle; background: var(--tile); margin-left: 4px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.typed.ok { animation: okup 0.28s ease-in forwards; }
@keyframes okup { to { transform: translateY(-40px); opacity: 0; } }
.over { font-size: 40px; font-weight: 700; color: var(--dim); }
.mine { flex: none; display: flex; align-items: center; gap: 10px; height: 36px; overflow: hidden; white-space: nowrap; }
.mine b { flex: none; min-width: 36px; height: 36px; line-height: 36px; padding: 0 8px; border-radius: 18px; background: var(--gold); color: var(--tile-ink); text-align: center; font-size: 20px; }
.mine b.bump { animation: bump 0.3s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { from { transform: scale(1.5); } }
.mine span { font-size: 16px; color: var(--dim); overflow: hidden; text-overflow: clip; direction: rtl; text-align: left; }

/* the keyboard: a tile a key */
.kb { flex: none; display: flex; flex-direction: column; gap: 9px; padding-bottom: 4px; }
.kb .r { display: flex; gap: 5px; justify-content: center; }
.kb button { flex: 1; max-width: 44px; height: 50px; border: 0; border-radius: 8px; background: var(--tile); color: var(--tile-ink); font-size: 22px; font-weight: 700; box-shadow: 0 4px 0 var(--tile-edge); padding: 0; cursor: pointer; touch-action: manipulation; }
.kb button.wide { max-width: 68px; flex: 1.5; font-size: 15px; background: var(--panel); color: var(--ink); box-shadow: 0 4px 0 var(--deep); }
.kb button.enter { background: var(--gold); color: var(--tile-ink); box-shadow: 0 4px 0 var(--gold-edge); }
.kb button.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-edge); }
.kb.locked button { opacity: 0.35; }
.kb button svg { width: 24px; height: 24px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the reveal: words to challenge ---- */
.rhead { flex: none; display: flex; align-items: baseline; gap: 10px; }
#rtag { font-size: 14px; color: var(--dim); font-weight: 700; flex: none; }
.rlabel { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.win { flex: none; height: 6px; border-radius: 3px; background: var(--deep); overflow: hidden; }
.win i { display: block; height: 6px; background: var(--gold); transform-origin: 0 50%; width: 100%; }
.hint { flex: none; margin: 0; font-size: 15px; color: var(--dim); }
.list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.rw { flex: none; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 6px 12px 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--deep); text-align: left; font-size: 21px; font-weight: 700; animation: rise 0.25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(-10px); } }
.rw .wd { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rw .pt { flex: none; font-size: 17px; color: var(--gold); }
.rw .by { flex: none; }
.rw.can { border-color: var(--tile); background: var(--panel); cursor: pointer; }
.rw.can:active { transform: scale(0.97); }
.rw.own, .rw.shared { border-color: transparent; background: rgba(42, 4, 17, 0.5); }
.rw.own .wd::after { content: " \00b7 yours"; font-weight: 500; font-size: 14px; color: var(--dim); }
.rw.shared .wd { text-decoration: line-through; color: var(--dim); }
.rw.shared .pt { color: var(--dim); }
.rw.called { border-color: var(--gold); animation: throb 0.5s ease-in-out infinite alternate; }
@keyframes throb { to { background: var(--panel); } }
.rw.fake { border-color: var(--bad); }
.rw.fake .wd { text-decoration: line-through; text-decoration-color: var(--bad); text-decoration-thickness: 3px; }
.rw.fake .pt { color: var(--bad); }
.rw.real { border-color: var(--ok); }
.rw.real .pt { color: var(--ok); }
.rw.closed { cursor: default; }

/* ---- scores ---- */
#scoresPane { justify-content: center; align-items: stretch; text-align: center; gap: 10px; overflow-y: auto; }
.crown { width: 80px; height: 50px; align-self: center; flex: none; }
.crown path { fill: var(--gold); }
.winner { font-size: 40px; font-weight: 700; overflow-wrap: anywhere; }
.place { font-size: 22px; color: var(--dim); font-weight: 700; }
.total { font-size: 76px; font-weight: 700; line-height: 1; }
.gain { font-size: 24px; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.gain.neg { color: var(--bad); }
.endbox:empty { display: none; }

#down { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); opacity: 0.6; }
#down svg { width: 22px; height: 22px; fill: none; stroke: var(--dim); stroke-width: 2; stroke-linecap: round; }

/* short phones: the keyboard and the word give a little */
@media (max-height: 640px) {
  .kb button { height: 44px; }
  .kb { gap: 7px; }
  .ctiles { font-size: 24px; margin: 3px 0 2px; }
  .typed { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) { .typed .tile, .rw, .rw.called { animation: none; } }

/* a phone on its side: everything tighter, so the keyboard stays on screen */
@media (max-height: 460px) and (orientation: landscape) {
  .top { height: 34px; }
  .pane { gap: 6px; padding: 4px 0 6px; }
  .ctag { display: none; }
  .ctiles { font-size: 20px; margin: 0 0 2px; }
  .clabel { font-size: 14px; }
  .clock { margin-top: 4px; }
  .stagebox { min-height: 40px; }
  .typed { font-size: 28px; }
  .ready { font-size: 16px; }
  .ready b { font-size: 36px; }
  .mine { height: 26px; }
  .mine b { height: 26px; line-height: 26px; min-width: 26px; font-size: 15px; }
  .kb { gap: 5px; }
  .kb button { height: 34px; font-size: 17px; max-width: 58px; }
  .kb button.wide { max-width: 84px; }
  .total { font-size: 48px; }
  .crown { height: 34px; }
  .winner { font-size: 28px; }
}
