/* ==========================================================================
   Wordplay fit-to-screen layout
   Every screen fills exactly the phone's height: the top bar stays put and
   the screen below it fits the rest. Long lists scroll inside their own box;
   the page itself never scrolls. (main can still scroll as a last resort on
   unusually small screens, so nothing is ever cut off.)
   ========================================================================== */

/* Only these screens use the fixed-height frame; the rest keep their layout. */
html { height: 100%; }
body.fit[data-screen="friends"], body.fit[data-screen="room"] {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
body.fit[data-screen="friends"] .topbar, body.fit[data-screen="room"] .topbar { flex: none; position: relative; }
body.fit[data-screen="friends"] main, body.fit[data-screen="room"] main {
  flex: 1 1 auto; min-height: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 16px 14px;
  display: flex; flex-direction: column;
}
body.fit[data-screen="friends"] main > .screen:not([hidden]), body.fit[data-screen="room"] main > .screen:not([hidden]) { flex: 1 1 auto; min-height: 0; width: 100%; }

/* A box whose list scrolls inside it, never the page. */
.fill { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.scroll-in { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.scroll-in::-webkit-scrollbar { width: 0; height: 0; }

/* Bottom sheet used by the room boxes, settings and lists */
.panel-sheet { position: fixed; inset: 0; z-index: 45; background: rgba(14, 14, 17, 0.38); display: flex; align-items: flex-end; justify-content: center; }
.panel-sheet[hidden] { display: none; }
.panel-sheet .sheet-panel { max-width: 560px; max-height: min(82dvh, 640px); grid-template-rows: auto minmax(0, 1fr); }
.panel-sheet .sheet-body { min-height: 0; overflow-y: auto; display: grid; gap: 12px; align-content: start; padding-bottom: 4px; }
@media (min-width: 700px) { .panel-sheet { align-items: center; } .panel-sheet .sheet-panel { border-radius: 20px; } }

/* --------------------------------------------------------------------------
   Settings
   -------------------------------------------------------------------------- */
.settings-modal { align-items: end; }
@media (min-width: 600px) { .settings-modal { align-items: center; } }
.settings-card { width: min(440px, 100%); max-height: 92dvh; overflow-y: auto; display: grid; gap: 8px; text-align: left; padding: 18px 16px 16px; animation: sheet-up 0.28s var(--ease-out); }
.set-head { display: flex; align-items: center; justify-content: space-between; }
.set-head h2 { margin: 0; font-size: 1.25rem; }
.set-profile { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 16px; background: linear-gradient(120deg, #fff6dc, #fdeacc); text-align: left; transition: transform 0.15s; }
.set-profile:active { transform: scale(0.99); }
.set-profile .avatar { width: 46px; height: 46px; font-size: 1.1rem; }
.set-who { display: grid; flex: 1; min-width: 0; }
.set-who b { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-who small { color: var(--muted); font-size: 0.78rem; }
.set-edit { font-size: 0.8125rem; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--surface); }
.set-label { margin: 6px 4px 0; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.set-group { background: var(--cream); border-radius: 16px; overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; text-align: left; font-weight: 600; font-size: 0.9375rem; color: var(--ink); background: none; cursor: pointer; }
.set-row + .set-row { border-top: 1px solid var(--line); }
button.set-row:hover, label.set-row:hover { background: rgba(255, 255, 255, 0.55); }
.set-row[hidden] { display: none; }
.set-text { flex: 1; min-width: 0; display: grid; }
.set-text small { font-size: 0.72rem; font-weight: 500; color: var(--muted); }
.set-row .switch { margin: 0; }
.set-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; }
.set-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.c-violet { background: #7c6cf0; } .c-amber { background: #e0a200; } .c-red { background: #e0634a; }
.c-mint { background: #3f8f7c; } .c-blue { background: #3d7fc4; } .c-danger { background: #fde2d4; color: var(--danger); }
.set-chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.set-row.is-danger { color: var(--danger); }
#push-btn[disabled] { background: #dcfce7; color: var(--ok); border-color: transparent; }

/* Notifications */
.notif-card { width: min(440px, 100%); max-height: 86dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 12px; text-align: left; }
.notif-card .set-head h2 { font-size: 1.25rem; }
.notif-card .ann-list { max-height: none; min-height: 0; overflow-y: auto; }
.notif-card > div:nth-of-type(3) { min-height: 0; display: flex; flex-direction: column; }
.notif-empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 18px 8px !important; background: none !important; }
.notif-empty .daily-mini { display: flex; }
.notif-empty b { color: var(--ink); font-size: 0.95rem; }

/* --------------------------------------------------------------------------
   Play with friends
   -------------------------------------------------------------------------- */
.screen.friends:not([hidden]) { display: flex; flex-direction: column; gap: 10px; }
.screen.friends > * { flex: none; }
.screen.friends > .fill { flex: 1 1 0; }
.friends-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 22px;
  background:
    radial-gradient(rgba(14, 14, 17, 0.05) 1.2px, transparent 1.4px) 0 0 / 20px 20px,
    linear-gradient(120deg, #fff6dc 0%, #fdeacc 100%);
  animation: sheet-up 0.4s var(--ease-out);
}
.fh-art { width: 100%; max-width: 200px; height: auto; display: block; }
.fh-pop { transform-box: fill-box; transform-origin: 50% 100%; animation: fh-bob 3s ease-in-out infinite; }
.fh-pop.p2 { animation-delay: 0.6s; }
@keyframes fh-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.fh-tile { transform-box: fill-box; transform-origin: 50% 100%; animation: w-bounce 2.4s cubic-bezier(.3, .7, .4, 1) infinite; }
.fh-tile.t2 { animation-delay: 0.15s; }
.fh-actions { display: grid; gap: 8px; }
.fh-actions .btn { padding: 11px 16px; white-space: nowrap; }

.seg-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg-tabs button { padding: 9px 6px; border-radius: 999px; font-weight: 700; font-size: 0.875rem; color: var(--muted); display: inline-flex; justify-content: center; align-items: center; gap: 6px; transition: background 0.2s, color 0.2s; }
.seg-tabs button.is-active { background: var(--ink); color: var(--on-ink); }
.seg-tabs .count { font-size: 0.7rem; font-weight: 800; background: var(--cream); color: var(--ink); padding: 1px 7px; border-radius: 999px; }
.seg-tabs .count:empty { display: none; }
.seg-tabs button.is-active .count { background: rgba(255, 255, 255, 0.18); color: var(--on-ink); }

.friends-panel { padding: 12px; gap: 10px; animation: sheet-up 0.25s var(--ease-out); }
.friends-panel[hidden] { display: none; }
.friends-panel .search { flex: none; }
.friends-panel .list li { animation: sheet-up 0.3s var(--ease-out) both; }
.friends-panel .list li:nth-child(2) { animation-delay: 0.04s; } .friends-panel .list li:nth-child(3) { animation-delay: 0.08s; }
.friends-panel .list li:nth-child(4) { animation-delay: 0.12s; } .friends-panel .list li:nth-child(5) { animation-delay: 0.16s; }
.friends-panel .hint { margin: 0; font-size: 0.8125rem; }
.tourney-card .tourney-actions { flex: none; }
.friends-panel .empty { text-align: center; padding: 20px 8px; }
@media (max-width: 360px) { .fh-art { max-width: 150px; } }

/* --------------------------------------------------------------------------
   Room (waiting room): code, seats, five boxes that open sheets, Start
   -------------------------------------------------------------------------- */
.screen.room:not([hidden]) { display: flex; flex-direction: column; gap: 10px; }
.screen.room > * { flex: none; }
.room-top { padding: 14px; gap: 10px; animation: sheet-up 0.35s var(--ease-out); }
.room-code-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-code-row .eyebrow { margin: 0; text-align: left; }
.room-top .big-code { font-size: clamp(1.8rem, 9vw, 2.4rem); text-align: left; line-height: 1.1; }
.room-count { font-size: 0.8125rem; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); white-space: nowrap; }
.room-top .invite { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.room-top .invite input { min-width: 0; font-size: 0.8125rem; padding: 9px 12px; }
.room-top .invite .btn { padding: 9px 12px; font-size: 0.8125rem; }
.room-top #share-link-btn { display: none; }

.screen.room .seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.screen.room .seats li { padding: 8px 10px; min-height: 0; animation: sheet-up 0.3s var(--ease-out) both; }
.screen.room .seats li:nth-child(2) { animation-delay: 0.05s; } .screen.room .seats li:nth-child(3) { animation-delay: 0.1s; } .screen.room .seats li:nth-child(4) { animation-delay: 0.15s; }
.screen.room .seats .empty-seat { padding: 14px 10px; }

.room-boxes { flex: 1 1 auto !important; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; gap: 8px; align-content: start; }
.room-box {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 12px; min-height: 62px; min-width: 0;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  text-align: left; transition: transform 0.15s var(--ease-out), box-shadow 0.2s;
  animation: sheet-up 0.35s var(--ease-out) both;
}
.room-box:nth-child(2) { animation-delay: 0.04s; } .room-box:nth-child(3) { animation-delay: 0.08s; }
.room-box:nth-child(4) { animation-delay: 0.12s; } .room-box:nth-child(5) { animation-delay: 0.16s; }
.room-box:hover { box-shadow: var(--shadow); }
.room-box:active { transform: scale(0.97); }
.room-box:last-child:nth-child(odd) { grid-column: 1 / -1; }
.rb-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; }
.rb-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rb-text { display: grid; min-width: 0; }
.rb-text b { font-size: 0.875rem; }
.rb-text small { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-box .badge { position: absolute; top: 6px; right: 8px; }

.room-foot { display: grid; gap: 2px; }
.room-foot .hint { margin: 2px 0 0; text-align: center; font-size: 0.78rem; }
.room-foot .host-only { gap: 4px; }
.room-wait { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.room-wait .dots-loader { gap: 4px; }
.room-foot #leave-room-btn { padding: 6px; font-size: 0.8125rem; }

/* Sheets opened from the boxes */
.panel-sheet .sheet-body > div { border-top: 0 !important; padding-top: 0 !important; }
.panel-sheet .sheet-sub { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.panel-sheet .room-chat .chat-list { max-height: 42dvh; }
.panel-sheet .room-players, .panel-sheet #room-players { max-height: 40dvh; overflow-y: auto; }
.panel-sheet .dict-row { justify-self: center; }
@media (max-height: 640px) {
  .room-top .big-code { font-size: 1.7rem; }
  .screen.room .seats li { padding: 6px 8px; }
}
@media (max-height: 700px) {
  .settings-card { gap: 6px; padding: 14px 14px 12px; }
  .settings-card .set-row { padding: 9px 12px; }
  .settings-card .set-profile { padding: 10px 12px; }
  .settings-card .set-label { margin-top: 4px; }
}

/* Lists keep their natural row height instead of stretching to fill the card */
.list { align-content: start; }
.friends-list li { padding: 10px 12px; border-radius: 14px; }
.friends-list .avatar { width: 42px; height: 42px; font-size: 1rem; }
.friends-list .who b { font-size: 0.95rem; }

/* Sign-up email check: while it shows, the other sign-in options step aside */
.auth-card.is-verifying #google-btn, .auth-card.is-verifying .or, .auth-card.is-verifying .seg,
.auth-card.is-verifying #auth-form, .auth-card.is-verifying #auth-howto, .auth-card.is-verifying #auth-lede { display: none; }
.verify-form[hidden] { display: none; }
.verify-head { display: grid; justify-items: center; gap: 4px; text-align: center; }
.verify-head h2 { margin: 4px 0 0; font-size: 1.2rem; }
.verify-head p { margin: 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.verify-head p b { color: var(--ink); }
.verify-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: #0e0e11; }
.verify-ic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#verify-code { text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: 0.5em; padding-left: 0.5em; font-variant-numeric: tabular-nums; }
.verify-links { display: flex; justify-content: space-between; gap: 8px; }
.verify-links .btn-link { padding: 6px 2px; font-size: 0.85rem; }
.verify-links .btn-link:disabled { opacity: 0.55; cursor: default; }

/* ---------- Quick match ---------- */
.quick-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: 22px; text-align: left; color: #0e0e11;
  background: #ffb800; box-shadow: var(--shadow-sm), inset 0 -4px 0 #e0a200;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow), inset 0 -4px 0 #e0a200; }
.quick-card:focus-visible { outline: 3px solid #0e0e11; outline-offset: 2px; }
.quick-mini { display: flex; gap: 3px; }
.quick-mini i { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: #0e0e11; color: #ffb800; font-style: normal; font-weight: 800; font-size: 0.8rem; }
.quick-mini i:last-child { animation: daily-wave 3.2s ease-in-out infinite 0.2s; }
.quick-text { display: grid; gap: 2px; min-width: 0; }
.quick-text b { font-size: 1.05rem; }
.quick-text span { font-size: 0.8125rem; color: rgba(14, 14, 17, 0.72); }
.quick-go { width: 22px; height: 22px; fill: none; stroke: #0e0e11; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 400px) { .quick-mini { display: none; } .quick-card { grid-template-columns: minmax(0, 1fr) auto; } }

.quick-modal-card { position: relative; width: min(360px, 100%); padding: 22px 20px 20px; animation: sheet-up 0.3s var(--ease-out); }
.quick-pick, .quick-wait { display: grid; gap: 10px; }
.quick-pick[hidden], .quick-wait[hidden] { display: none; }
.quick-pick h2, .quick-wait h2 { font-size: 1.25rem; margin: 2px 0 0; }
.quick-pick .hint, .quick-wait .hint { margin: 0; }
.quick-opt { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--cream); border: 2px solid transparent; text-align: left; color: var(--ink); }
.quick-opt:hover, .quick-opt:focus-visible { border-color: #ffb800; outline: none; }
.qo-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #0e0e11; color: #ffb800; }
.quick-opt[data-pace="live"] .qo-ic { background: #ffb800; color: #0e0e11; }
.qo-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.quick-opt[data-pace="live"] .qo-ic svg { fill: currentColor; stroke: none; }
.qo-text { display: grid; gap: 2px; }
.qo-text small { color: var(--muted); font-size: 0.8125rem; }
.quick-words { justify-self: center; }
.quick-wait { text-align: center; justify-items: stretch; }
.quick-search { display: flex; justify-content: center; gap: 6px; margin: 4px 0 2px; }
.quick-search i { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--tile); color: #0e0e11; font-style: normal; font-weight: 800; box-shadow: inset 0 -3px 0 var(--tile-edge); animation: quick-hop 1.2s ease-in-out infinite; }
.quick-search i:nth-child(2) { animation-delay: 0.15s; } .quick-search i:nth-child(3) { animation-delay: 0.3s; } .quick-search i:nth-child(4) { animation-delay: 0.45s; }
@keyframes quick-hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .quick-search i, .quick-mini i { animation: none; } }
:root[data-theme="dark"] .quick-opt { background: var(--cream-deep); }
.quick-card[hidden], .timer-chips button[hidden], #timer-slow-hint[hidden] { display: none; }
