/* Wordlaundering — mobile-first laundromat theme */
:root {
  --bg: #0f1720;
  --bg-2: #162231;
  --card: #1b2a3b;
  --card-2: #223449;
  --line: #2c4259;
  --text: #eaf4f4;
  --muted: #94a9b8;
  --mint: #5ee6c1;
  --mint-dark: #1fae8a;
  --aqua: #63c6ff;
  --warn: #ffcf5c;
  --danger: #ff6b7a;
  --radius: 16px;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgb(99 198 255 / 0.18), transparent 40%),
    radial-gradient(circle at 110% 20%, rgb(94 230 193 / 0.12), transparent 35%),
    var(--bg);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { line-height: 1.2; margin: 0 0 0.6rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--aqua); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center-text { text-align: center; }
.count { color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.ok { color: var(--mint); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }

/* ── Icons (Lucide, inline SVG; colour follows the text) ── */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.btn .icon { margin-right: 0.35em; }
.btn > .icon:only-child { margin-right: 0; }
.icon-check, .icon-circle-check { color: var(--mint); }
.icon-x, .icon-triangle-alert { color: var(--danger); }
.icon-crown, .icon-trophy, .icon-flame { color: var(--warn); }
.btn.ghost .icon-x { color: inherit; } /* "Forget room" stays quiet */

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
  background: rgb(15 23 32 / 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: 0.01em; font-size: 1.1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.45rem; }
.brand-logo { width: 26px; height: 26px; flex: none; }
.version { font-size: 0.72rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; align-self: flex-end; margin-bottom: 0.15rem; }
.chip {
  font: inherit; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em;
  color: var(--bg); background: var(--mint); border: 0; border-radius: 999px; padding: 0.3rem 0.8rem; cursor: pointer;
  white-space: nowrap;
}
.brand { min-width: 0; }
/* Small phones: tighten the top bar so the title, version and room chip stay on one line. */
@media (max-width: 26rem) {
  .topbar { padding-left: 0.75rem; padding-right: 0.75rem; }
  .brand { font-size: 1rem; gap: 0.35rem; }
  .brand-logo { width: 22px; height: 22px; }
  .chip { letter-spacing: 0.04em; padding: 0.3rem 0.65rem; }
}
@media (max-width: 23rem) { .chip-label { display: none; } }
.conn-banner.tappable { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.conn-banner {
  position: sticky; top: 3.2rem; z-index: 9;
  background: var(--warn); color: #222; text-align: center; font-weight: 600; padding: 0.35rem; font-size: 0.9rem;
}

/* ── Layout ── */
main { max-width: 34rem; margin: 0 auto; padding: 1rem; }
.screen { display: flex; flex-direction: column; gap: 1rem; animation: fade 0.2s ease; }
.screen.center { align-items: center; justify-content: center; min-height: 60dvh; text-align: center; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.hero h1 { font-size: 2rem; }
.lede { color: var(--muted); font-size: 1.05rem; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

/* Flat sections: separated by a hairline and spacing instead of boxes */
.section { border-top: 1px solid rgb(44 66 89 / 0.7); padding-top: 1.1rem; }
.screen > .section:first-child, #setup-form > .section:first-child, .doc > .section:first-child,
.card + .section { border-top: 0; padding-top: 0; }
.section > h2, .section > summary, .card > h2, .doc h2 {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
}
.join > h2 { font-size: 1.15rem; text-transform: none; letter-spacing: 0; color: var(--text); }

.row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }
.row.spread { justify-content: space-between; }
.row.spread > .btn { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Buttons ── */
.btn {
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.75rem 1rem; min-height: 44px; cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--aqua); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--mint), var(--mint-dark)); color: #04241b; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.primary.danger { background: var(--danger); color: #2a0007; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: transparent; background: rgb(99 198 255 / 0.06); }
.btn.ghost.danger { color: var(--danger); }
.btn.small { padding: 0.45rem 0.75rem; min-height: 36px; font-size: 0.9rem; }
.btn.back { align-self: flex-start; }
.screen > .btn.primary { width: 100%; padding: 1rem; font-size: 1.1rem; }
.host-only > .btn.primary { width: 100%; padding: 1rem; font-size: 1.1rem; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
.field > span { font-size: 0.9rem; color: var(--muted); font-weight: 600; }
input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.8rem; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--aqua); outline-offset: 1px; border-color: transparent; }
#join-code { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; font-size: 1.2rem; }
.form-error { color: var(--danger); font-weight: 600; }

.toggle { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.5rem 0; cursor: pointer; }
.toggle input { width: 1.3rem; height: 1.3rem; margin-top: 0.15rem; accent-color: var(--mint); flex: none; }
.toggle span { display: flex; flex-direction: column; }
.toggle small { color: var(--muted); }

.segmented { display: flex; gap: 0.4rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.segmented label {
  position: relative; flex: 1; text-align: center; padding: 0.55rem; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font-weight: 600; background: var(--bg);
}
.segmented input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--mint); color: var(--mint); background: rgb(94 230 193 / 0.08); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--aqua); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; text-align: center;
  position: relative;
  padding: 1.25rem; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; margin-bottom: 0.85rem;
}
.dropzone.over, .dropzone:hover { border-color: var(--mint); background: rgb(94 230 193 / 0.05); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone small { color: var(--muted); }

.deck-summary { margin: 0.5rem 0; }
.sample { margin: 0.25rem 0 0.5rem; padding-left: 1.2rem; color: var(--muted); font-style: italic; }

/* ── Rules ── */
.rules summary { cursor: pointer; padding: 0.2rem 0; }
.rules[open] summary { margin-bottom: 0.6rem; }
.rules ol { padding-left: 1.2rem; }
.rules li { margin-bottom: 0.4rem; }
.rules-summary { margin: 0 0 0.75rem; padding-left: 1.1rem; color: var(--muted); }

/* ── Room list ── */
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.room-list li { display: flex; gap: 0.5rem; }
.room-list li > .btn:first-child { flex: 1; text-align: left; }
.room-list strong { letter-spacing: 0.12em; }

/* ── Invite ── */
.invite { text-align: center; display: flex; flex-direction: column; align-items: center; padding: 0.5rem 0 0.25rem; }
.room-code { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.25em; margin: 0 0 0.75rem; color: var(--mint); padding-left: 0.25em; }
.qr { width: 200px; height: 200px; border-radius: 12px; background: #fff; margin-bottom: 0.75rem; image-rendering: pixelated; }
.invite .row { width: 100%; }
.card.invite { padding: 1.25rem 1rem 1rem; }

/* ── Players / scoreboard ── */
.player-list, .scoreboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.player-main {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.65rem 0.15rem; background: none; border: 0; border-bottom: 1px solid rgb(44 66 89 / 0.55);
  font: inherit; color: inherit; text-align: left;
}
.player:last-child .player-main { border-bottom: 0; }
button.player-main { cursor: pointer; }
button.player-main:hover { background: rgb(99 198 255 / 0.06); }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); flex: none; opacity: 0.5; }
.online .dot { background: var(--mint); opacity: 1; box-shadow: 0 0 8px var(--mint); }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 0.8rem; }
.badge.host { display: inline-flex; font-size: 1rem; }
.score-line .lead .icon { margin-left: 0.15em; }
.score-line .caret .icon { width: 1em; height: 1em; vertical-align: -0.15em; }
.badge.you { background: var(--card-2); color: var(--muted); border-radius: 999px; padding: 0 0.5rem; }
.progress { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; flex: none; }
.progress .done { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.progress .left { font-weight: 700; font-size: 0.9rem; color: var(--aqua); white-space: nowrap; }
.take-host { margin-top: 0.6rem; width: 100%; }

/* ── Hand: one card per phrase. Swipe right = laundered, left = busted. ── */
.hand-hint { margin: 0 0 0.5rem; }
.hand-hint .mouse-hint { display: none; }
.hand { list-style: none; margin: 0.25rem 0 0.85rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.phrase-card {
  position: relative; border-radius: 12px; overflow: hidden; touch-action: pan-y;
  transition: height 0.18s ease, opacity 0.18s ease, margin 0.18s ease;
}
.phrase-card:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.phrase-card.enter { animation: rise 0.25s ease; }
.swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; font-weight: 700; background: var(--bg-2); border-radius: 12px;
}
.swipe-bg span { display: inline-flex; align-items: center; gap: 0.4rem; opacity: var(--p, 0); transition: transform 0.12s ease; }
.swipe-bg .icon { color: inherit; width: 1.3em; height: 1.3em; stroke-width: 2.5; }
.swipe-bg .bg-busted { display: none; }
.phrase-card[data-dir="right"] .swipe-bg { background: var(--mint-dark); color: #04241b; }
.phrase-card[data-dir="left"] .swipe-bg { background: var(--danger); color: #2a0007; justify-content: flex-end; }
.phrase-card[data-dir="left"] .bg-laundered { display: none; }
.phrase-card[data-dir="left"] .bg-busted { display: inline-flex; }
.phrase-card.armed .swipe-bg span { transform: scale(1.12); }
.phrase-face {
  position: relative; display: flex; align-items: center; gap: 0.5rem; min-height: 56px;
  padding: 0.7rem 0.9rem; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  font-size: 1.05rem; font-weight: 500; line-height: 1.35;
  transition: transform 0.2s ease;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.phrase-card.dragging .phrase-face { transition: none; }
.phrase-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* Touch screens swipe instead, so the buttons are visually hidden but stay available to screen readers. */
.phrase-actions {
  display: flex; gap: 0.35rem; flex: none;
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.mini {
  font: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer; width: 2.4rem; height: 2.4rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.mini .icon { width: 1.25rem; height: 1.25rem; stroke-width: 2.5; }
.mini.good:hover, .mini.good:focus-visible { border-color: var(--mint); background: rgb(94 230 193 / 0.12); }
.mini.bad:hover, .mini.bad:focus-visible { border-color: var(--danger); background: rgb(255 107 122 / 0.12); }
.hand-extras { flex-wrap: nowrap; }
.hand-extras .btn { flex: 1 1 0; color: var(--muted); padding-left: 0.5rem; padding-right: 0.5rem; white-space: nowrap; }
@media (max-width: 23rem) { .hand-extras { flex-wrap: wrap; } .hand-extras .btn { flex-basis: 100%; } }

/* Mouse/trackpad: show buttons on each card; touch screens swipe instead. */
@media (hover: hover) and (pointer: fine) {
  .phrase-actions { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .phrase-face { -webkit-user-select: text; user-select: text; }
  .hand-hint .touch-hint { display: none; }
  .hand-hint .mouse-hint { display: inline; }
}

/* ── Compact scoreboard ── */
.scorebar { padding: 0 0 0.1rem; border-bottom: 1px solid rgb(44 66 89 / 0.7); }
.score-line {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: none; border: 0; padding: 0.25rem 0; cursor: pointer; line-height: 1.6;
}
.score-line .who { white-space: nowrap; }
.score-line .who strong { color: var(--aqua); }
.score-line .who.me strong { color: var(--mint); }
.score-line .who.offline { opacity: 0.55; }
.score-line .sep, .score-line .caret { color: var(--muted); }
.scorebar .scoreboard { margin: 0.25rem 0 0.5rem; }

/* ── While you were away ── */
.away {
  display: flex; align-items: flex-start; gap: 0.75rem; justify-content: space-between;
  background: rgb(99 198 255 / 0.08); border: 1px solid rgb(99 198 255 / 0.35); border-radius: 12px; padding: 0.6rem 0.8rem;
}
.away p { margin: 0; font-size: 0.95rem; }
.away .link-btn { flex: none; color: var(--aqua); }

/* ── Latest activity line ── */
.latest {
  display: flex; flex-direction: column; gap: 0.15rem; width: 100%; text-align: left;
  font: inherit; font-size: 0.9rem; color: var(--text); cursor: pointer;
  background: none; border: 0; border-top: 1px solid rgb(44 66 89 / 0.7); padding: 0.8rem 0.1rem 0;
}
.latest .latest-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest .latest-msg .icon { margin-right: 0.35em; }
.latest .when { color: var(--muted); font-size: 0.8rem; }

/* ── Top bar menu ── */
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }
.icon-btn {
  font: inherit; font-size: 1.3rem; line-height: 1; color: var(--text); cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; width: 2.4rem; height: 2.1rem;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ── Bottom sheets (menu, log) ── */
dialog.sheet { margin-bottom: max(0.5rem, env(safe-area-inset-bottom)); }
.btn.wide { width: 100%; margin-top: 0.6rem; }
dialog .log { max-height: 60dvh; }

/* ── Log ── */
.log { list-style: none; margin: 0 0 0.25rem; padding: 0; max-height: 18rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem; }
.log li { display: flex; gap: 0.6rem; font-size: 0.92rem; padding: 0.3rem 0; border-bottom: 1px solid rgb(44 66 89 / 0.5); }
.log-msg .icon { margin-right: 0.35em; }
.log .when { color: var(--muted); flex: none; width: 4.8rem; font-size: 0.8rem; padding-top: 0.1rem; }

/* ── Game over ── */
.winner { text-align: center; padding: 1rem 0 0.5rem; }
.trophy { font-size: 3.5rem; line-height: 1; animation: bob 2s ease-in-out infinite; }
.trophy .icon { stroke-width: 1.5; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.standings { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; }
.standings > li { padding: 0.6rem 0; border-bottom: 1px solid rgb(44 66 89 / 0.55); }
.standings > li:last-child { border-bottom: 0; }
.standing-head { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.laundered-list { margin: 0.3rem 0 0; padding-left: 1rem; color: var(--muted); font-size: 0.9rem; font-style: italic; }

/* ── Spinner ── */
.spinner .drum { transform-box: view-box; transform-origin: 32px 38px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ── */
.toasts {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; display: flex; flex-direction: column; gap: 0.5rem; width: min(30rem, calc(100% - 2rem)); pointer-events: none;
}
.toast {
  position: relative; overflow: hidden;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.7rem 0.9rem 0.8rem; box-shadow: var(--shadow); font-weight: 500;
  animation: rise 0.2s ease; transition: opacity 0.4s ease;
}
.toast.error { border-color: rgb(255 107 122 / 0.55); }
/* Countdown: a thin bar along the bottom that empties until the toast goes. */
.toast-timer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--aqua); opacity: 0.8; transform-origin: left center;
  animation: toast-countdown linear forwards;
}
.toast.error .toast-timer { background: var(--danger); }
.toast.with-action .toast-timer { background: var(--mint); }
@keyframes toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast > .icon { margin-right: 0.45em; }
.toast.with-action .toast-msg { flex: 1; }
.toast.with-action > .icon { margin-right: -0.3rem; }
.toast.with-action { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; pointer-events: auto; }
.toast-undo {
  font: inherit; font-weight: 700; color: var(--mint); background: none; border: 0; cursor: pointer;
  padding: 0.35rem 0.5rem; min-height: 36px; flex: none;
}
.toast.out { opacity: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── Dialogs ── */
dialog {
  width: min(28rem, calc(100% - 2rem)); max-height: 85dvh; overflow-y: auto;
  color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(5 10 15 / 0.7); backdrop-filter: blur(3px); }
dialog .row { margin-top: 0.75rem; }
#confirm-text { font-size: 1.05rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .toast-timer { display: none; } /* it couldn't move anyway */
}

@media (min-width: 40rem) {
  main { padding: 1.5rem; }
  .hero h1 { font-size: 2.4rem; }
}

/* Setup form spacing */
#setup-form { display: flex; flex-direction: column; gap: 1rem; }
#setup-form > .btn.primary { width: 100%; padding: 1rem; font-size: 1.1rem; }

/* ── Footer (every screen): About & Privacy + maker credit ── */
.site-footer {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin: 1rem auto calc(1.5rem + env(safe-area-inset-bottom)); padding: 0 1rem;
  font-size: 12px; color: var(--muted); opacity: 0.8; text-align: center;
}
.site-footer > span { display: inline-flex; align-items: center; gap: 5px; }
.site-footer a { color: inherit; }
.site-footer .footer-link { font-weight: 700; text-decoration: none; }
.site-footer .footer-link:hover { color: var(--mint); text-decoration: underline; }
.site-footer .heart { width: 12px; height: 12px; fill: #f85149; }

/* ── About & Privacy page ── */
.doc { display: flex; flex-direction: column; gap: 1.1rem; }

.doc p, .doc li { line-height: 1.55; }
.doc p:last-child { margin-bottom: 0; }
.doc ol, .doc ul { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.doc li { margin-bottom: 0.3rem; }
.doc .updated { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0; }
.doc .back { text-align: center; text-decoration: none; display: block; width: 100%; padding: 1rem; }

/* Join button is the main call to action on the landing page */
.join-btn { width: 100%; padding: 0.9rem; font-size: 1.05rem; }

/* Subtle text-style buttons (e.g. "Create your own room" when arriving via invite) */
.link-btn {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0.25rem 0.1rem;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.link-btn:hover { color: var(--text); }
.alt-links { margin: -0.25rem 0 0; }
