/* Rack Duel — same palette as the Android app (Theme.kt). */
:root {
  --ink: #1f2a2e;
  --teal: #0072A3;
  --teal-light: #D5EAF4;
  --paper: #f7f1e3;
  --card: #fffcf5;
  --gold: #e9b949;
  --muted: #7a8487;

  --cell: #e9e2cf;
  --grid: #d4cbb3;
  --dl: #bfdce4;
  --tl: #4a90a4;
  --dw: #f2c2ae;
  --tw: #d5654f;

  --tile: #f6d58e;
  --tile-edge: #c79a3c;
  --tile-new: #ffe07a;
  --pending: #fff1c2;
  --ghost: rgba(185, 199, 203, 0.6);

  --win: #2e7d4f;
  --lose: #9a3b2e;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); min-height: 100vh; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.centered {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; max-width: 420px; margin: 0 auto; text-align: center;
}

/* ---------- type & helpers */
/* Logo: the round R/D badge with "Rack Duel" curved under it, in the same embossed
   black slab lettering as the tiles on the badge. */
@font-face {
  font-family: "Roboto Slab Black";
  src: url("../fonts/roboto-slab-black.ttf") format("truetype");
  font-display: swap;
}
.logo { display: flex; justify-content: center; margin: 0; padding: 4px 0 2px; }
.logo svg { width: 200px; max-width: 70vw; height: auto; display: block; overflow: visible; }
.logo-text { font: 400 27px "Roboto Slab Black", Georgia, serif; letter-spacing: 0.06em; }
.logo-light { fill: #FFFFFF; }
.logo-dark { fill: #8A6A3E; opacity: 0.75; }
.logo-ink { fill: #1F2A2E; }

.tagline { margin: 0 0 12px; }
.home-tagline { text-align: center; margin: 2px 0 4px; color: var(--ink); }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 12px 0 4px; }
small { display: block; font-size: 12px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.teal { color: var(--teal); }
.win { color: var(--win); }
.lose { color: var(--lose); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.15em; text-transform: uppercase; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.end { justify-content: flex-end; gap: 4px; margin-top: 8px; }
.center { text-align: center; }
.pad { padding: 16px 4px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- controls */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; background: transparent;
  font-weight: 600; min-height: 44px;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.outline { border: 1.5px solid var(--teal); color: var(--teal); }
.btn.text { color: var(--teal); padding: 8px 10px; }
.btn.text.lose { color: var(--lose); }
.btn.text.small { font-size: 13px; padding: 4px 0; min-height: 0; text-align: left; }
.btn.on-dark { color: #fff; border: 1.5px solid rgba(255,255,255,0.6); }
.btn.icon { font-size: 22px; padding: 6px 10px; display: inline-flex; align-items: center; }
.btn.wide { width: 100%; }
.btn.big { min-height: 52px; font-size: 17px; }
.btn:focus-visible, .cell:focus-visible, .rack-slot:focus-visible, .chip:focus-visible, .mode:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid #c9c1ab; background: #fff; font-size: 16px; /* 16px stops iOS zooming */
}
input:focus { outline: none; border-color: var(--teal); }
.field { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--teal); }

/* ---------- cards */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.home-head { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.home-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code-strip {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border-radius: 999px; padding: 6px 14px; font-size: 14px; align-self: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.code-strip .mono { font: 700 17px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.12em; color: var(--teal); }
.code-card { background: var(--teal); color: #fff; display: flex; align-items: center; gap: 12px; }
.code-card > div { flex: 1; }
.code-label { font-size: 13px; opacity: 0.8; }
.code { color: #fff; font: 700 30px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.15em; }
.label { font-size: 13px; color: var(--teal); font-weight: 600; margin: 10px 0 4px; }

.mode {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 8px; padding: 8px 6px; margin-bottom: 4px;
}
.mode.on { background: var(--teal-light); }
.mode small { color: var(--teal); }
.radio { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--teal); margin-top: 2px; position: relative; }
.mode.on .radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--teal); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.chip-label { width: 64px; font-size: 13px; }
.chip { border: 1.5px solid #c9c1ab; background: #fff; border-radius: 8px; padding: 6px 12px; min-height: 36px; font-size: 14px; }
.chip.on { background: var(--teal-light); border-color: var(--teal); color: var(--teal); font-weight: 700; }
.card .row.gap { margin-top: 10px; }

.section-title { font-size: 12px; font-weight: 700; color: var(--teal); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 8px; }
.game-row { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--tile); display: grid; place-items: center; font-weight: 700; }
.score { font-weight: 700; white-space: nowrap; }

.rules { background: var(--teal-light); }
.rules ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.45; }

/* ---------- game */
.topbar { display: flex; align-items: center; gap: 4px; font-size: 18px; }
.scores { display: flex; gap: 8px; }
.chip-score { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-width: 0; }
.chip-score .teal { font-size: 13px; }
.big-num { font-size: 26px; font-weight: 900; }
.round-line { font-size: 12px; color: var(--teal); padding-left: 4px; }
.bingo-hint { font-size: 13px; font-weight: 600; color: var(--win); padding-left: 4px; }
.banner { border-radius: var(--radius); padding: 12px; text-align: center; color: #fff; }
.banner b { font-size: 22px; font-weight: 900; display: block; }
.banner.win { background: var(--win); } .banner.lose { background: var(--lose); } .banner.teal { background: var(--teal); }
.banner small { opacity: 0.85; font-size: 13px; }

.reveal { background: var(--teal-light); display: flex; flex-direction: column; gap: 4px; }
.reveal-row { display: flex; gap: 8px; font-size: 14px; }
.reveal-row .who { width: 96px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reveal-row.stayed .who { font-weight: 700; }

/* Board: 15x15 grid; letters scale with the board's width via container units. */
.board-wrap { width: 100%; }
/* The game board zooms with pinch/spread; the wrap is a square window onto it. */
.board-wrap.zoomable { aspect-ratio: 1; overflow: hidden; touch-action: none; border-radius: 6px; overscroll-behavior: contain; }
.board {
  container-type: inline-size;
  display: grid; grid-template-columns: repeat(15, 1fr); gap: 1px;
  background: var(--grid); padding: 2px; border-radius: 6px; aspect-ratio: 1;
  width: 100%;
}
.board-wrap.zoomable .board { width: calc(100% * var(--z, 1)); }
.cell { border: 0; padding: 0; background: transparent; aspect-ratio: 1; display: block; min-width: 0; }
.sq {
  width: 100%; height: 100%; display: grid; place-items: center; border-radius: 2px;
  background: var(--cell); font-weight: 700; font-size: calc(100cqw / 15 * 0.3);
}
.sq.p-T { background: var(--tw); color: #fff; }
.sq.p-D { background: var(--dw); }
.sq.p-t { background: var(--tl); color: #fff; }
.sq.p-d { background: var(--dl); }
.tile {
  width: 100%; height: 100%; position: relative; display: grid; place-items: center;
  background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 3px;
}
.tile b { font-size: calc(100cqw / 15 * 0.56); line-height: 1; }
.tile i { position: absolute; right: 1px; bottom: 0; font-style: normal; font-size: calc(100cqw / 15 * 0.24); line-height: 1.1; }
.tile.blank b { color: var(--teal); }
.tile.new { background: var(--tile-new); }
.tile.pending { background: var(--pending); border-color: var(--teal); }
.tile.ghost { background: var(--ghost); border-color: transparent; }

.rack {
  display: flex; justify-content: center; gap: 6px; padding: 10px 6px;
  background: var(--teal); border-radius: 10px; container-type: inline-size;
}
.rack-slot {
  width: min(46px, 12cqw); aspect-ratio: 1; padding: 0; border: 0; background: transparent; border-radius: 5px;
  container-type: inline-size;
}
.rack-slot .tile b { font-size: 55cqw; }
.rack-slot .tile i { font-size: 24cqw; right: 2px; }
.rack-slot.sel { outline: 3px solid var(--gold); outline-offset: 2px; }
.rack-slot.empty { background: rgba(255,255,255,0.12); }
.status { margin: 0; text-align: center; font-size: 14px; min-height: 1.4em; }

/* ---------- dialogs, toast, spinner */
.scrim {
  position: fixed; inset: 0; background: rgba(20, 30, 33, 0.45); display: grid; place-items: center;
  padding: 16px; z-index: 10;
}
.dialog { background: var(--card); border-radius: 16px; padding: 18px; width: min(360px, 100%); max-height: 90vh; overflow: auto; }
.dialog.wide { width: min(520px, 100%); }
.dialog p { margin: 0 0 4px; }
.letters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.letter { aspect-ratio: 1; border: 0; border-radius: 6px; background: var(--tile); font-weight: 700; color: var(--teal); font-size: 18px; }
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; max-width: calc(100% - 32px);
  font-size: 14px; z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--teal-light); border-top-color: var(--teal); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- groups */
.mt { margin-top: 10px; }
.avatar.group { background: var(--teal); color: #fff; }
.avatar.sm { width: 30px; height: 30px; font-size: 14px; }
.avatar.avatar-letter { color: #fff; }
.avatar.emoji { background: var(--teal-light); font-size: 22px; line-height: 1; font-weight: 400; }
.avatar.sm.emoji { font-size: 17px; }
/* "Hi, Gentry" opens the profile editor */
.me-line { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.profile-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px 4px 0;
  color: var(--ink); font: inherit; min-height: 44px; cursor: pointer;
}
.profile-btn .edit-pen { color: var(--teal); font-size: 15px; }
.profile-preview { display: flex; align-items: center; gap: 12px; margin: 4px 0 10px; font-size: 18px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin: 4px 0 8px; }
.avatar-pick {
  display: grid; place-items: center; border: 2px solid transparent; border-radius: 12px; background: #fff;
  min-height: 44px; padding: 4px; cursor: pointer;
}
.avatar-pick.on { border-color: var(--teal); background: var(--teal-light); }
.leaderboard { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; min-height: 36px; }
.lb-row.me { background: var(--teal-light); }
.lb-row.gone { opacity: 0.5; }
.lb-row .rank { width: 20px; text-align: center; font-weight: 700; color: var(--teal); }
.lb-row small { white-space: nowrap; }
.lb-score { font-size: 18px; min-width: 40px; text-align: right; }
.game-row .score small { text-align: right; font-weight: 400; }
.board-blurb { margin: 2px 0 4px; }

/* ---------- drag and drop */
[data-drag] { touch-action: none; -webkit-user-select: none; user-select: none; cursor: grab; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none;
  container-type: inline-size; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.3));
}
.drag-ghost .tile { border-radius: 6px; }
.drag-ghost .tile b { font-size: 55cqw; }
.drag-ghost .tile i { font-size: 24cqw; right: 3px; }
.drag-source { opacity: 0.35; }
.cell.drop-over .sq, .cell.drop-over .tile { outline: 3px solid var(--gold); outline-offset: -1px; }
/* typing cursor: gold box with an arrow showing which way the word goes */
.cell { position: relative; }
.cell.cursor .sq, .cell.cursor .tile { outline: 3px solid var(--gold); outline-offset: -2px; }
.cursor-arrow {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: var(--teal); font-weight: 900; font-size: calc(100cqw / 15 * 0.62); line-height: 1;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}
.cell.cursor .tile + .cursor-arrow { opacity: 0.55; }
.rack-slot.drop-before { box-shadow: -5px 0 0 var(--gold); }
.rack-slot.drop-after { box-shadow: 5px 0 0 var(--gold); }
.rack.drop-over { outline: 3px solid var(--gold); }
.row.wrap { flex-wrap: wrap; }

/* ---------- round result */
.outcome { display: flex; gap: 10px; align-items: center; border-radius: 10px; padding: 10px 12px; color: #fff; margin-bottom: 4px; }
.outcome b { display: block; font-size: 17px; }
.outcome small { color: rgba(255,255,255,0.9); font-size: 13px; }
.outcome.win { background: var(--win); }
.outcome.lose { background: var(--lose); }
.outcome.neutral { background: var(--teal); }
.outcome-icon { font-size: 28px; }
.result-dialog { text-align: center; padding: 0; overflow: hidden; }
.result { padding: 22px 18px 12px; color: #fff; }
.result.win { background: var(--win); }
.result.lose { background: var(--lose); }
.result.neutral { background: var(--teal); }
.result h2 { font-size: 24px; margin: 6px 0; }
.result p { margin: 6px 0; }
.result .muted, .result .win { color: rgba(255,255,255,0.85); }
.result-icon { font-size: 52px; line-height: 1; }
.result-dialog > .btn { margin: 12px 18px 18px; width: calc(100% - 36px); }

/* ---------- friends */
.hint { margin-top: 4px; }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.friend-name { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 6px 2px; text-align: left; min-width: 0; min-height: 44px; }
.friend-name small { display: block; }
.small-btn { min-height: 38px; padding: 6px 14px; }
.code-input { width: 7.5em; flex: none; }
.friend-id { min-width: 0; }
.mt-s { margin-top: 6px; }
.ellipsis { display: block; }
.game-row .grow, .friend-name .grow { overflow: hidden; }

/* ---------- sign in */
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; border: 1.5px solid #c9c1ab; color: var(--ink); min-height: 52px; font-size: 16px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--teal); text-decoration: underline; font: inherit; cursor: pointer; }

/* Bingo Hunt: step through every bingo that was on last round's board */
.bingo-step { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; text-align: center; }
.bingo-step .btn { min-width: 48px; font-size: 22px; padding: 4px 12px; }
.bingo-step span { flex: 1; color: var(--teal); }
