/* ── The Long Game ─────────────────────────────────────────────
   A castle at night. Cards grow like torches catching flame.
   Display: Cinzel · Body: Atkinson Hyperlegible · Mono: Spline Sans Mono
──────────────────────────────────────────────────────────────── */

:root {
  --night: #14172b;
  --night-deep: #0e1020;
  --panel: #1e2240;
  --panel-hi: #262b4f;
  --line: #313762;
  --text: #e9e6f2;
  --muted: #b7b4d4;
  --cream: #f5ebd8;
  --cream-ink: #201d33;
  --ember: #ffb454;
  --ember-deep: #e07b2f;
  --danger: #e86a5e;
  --ok: #7fbf7b;

  --z-kitchen: #e8a33d;
  --z-living: #b08bd6;
  --z-garage: #6fa8c9;
  --z-backyard: #7fbf7b;

  --disp: "Cinzel", "Times New Roman", serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, monospace;

  --r: 14px;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--night);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
/* Castle backdrop: the family seat, dimmed so parchment and text stay readable */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(175deg, rgba(14,16,32,0.78) 0%, rgba(14,16,32,0.9) 55%, rgba(14,16,32,0.96) 100%),
    url('/bg.jpg') center / cover no-repeat;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ── Join ── */
.join { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.join-card { width: min(360px, 100%); }
.wordmark {
  font-family: var(--disp); font-weight: 800; font-size: 50px; line-height: 0.92;
  letter-spacing: -0.02em; text-transform: uppercase;
  background: linear-gradient(160deg, var(--cream) 55%, var(--ember));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 10px;
}
.join-sub { color: var(--muted); margin-bottom: 28px; }
.join label { display: block; margin-bottom: 14px; font-size: 15px; color: var(--muted); }
.join input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); font: 500 16px var(--body); outline: none;
}
.join input:focus { border-color: var(--ember); }
.error { color: var(--danger); font-size: 15px; margin-top: 12px; min-height: 1em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--r); font-weight: 600;
  background: var(--panel-hi); border: 1px solid var(--line);
}
.btn.primary { background: var(--ember); color: var(--night-deep); border-color: transparent; width: 100%; }
.btn.primary:active { background: var(--ember-deep); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:focus-visible, .tab:focus-visible, .card:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ── Chrome ── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(10px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--night-deep) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--disp); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; }
.season-clock { text-align: center; }
.season-clock span { display: block; }
#season-left { font-family: var(--mono); font-size: 15px; color: var(--ember); }
.clock-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.energy { display: flex; gap: 5px; align-items: center; }
.energy .pip {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--panel-hi); border: 1px solid var(--line);
}
.energy .pip.full { background: var(--ember); border-color: var(--ember); box-shadow: 0 0 8px color-mix(in srgb, var(--ember) 60%, transparent); }
.energy .eta { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-left: 3px; }

main { padding: 16px 16px 96px; max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-around;
  padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--night-deep) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 2px; font-size: 12.5px; color: var(--muted); padding: 4px 10px; position: relative; }
.tab.active { color: var(--ember); }
.tab-ic { font-size: 17px; line-height: 1; }
.pill { position: absolute; top: -2px; right: -2px; background: var(--ember); color: var(--night-deep); font: 600 10px var(--mono); border-radius: 999px; padding: 1px 5px; }
.dot { position: absolute; top: 0; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* ── Rooms ── */
.room { margin-bottom: 20px; border: 1px solid var(--line); border-radius: calc(var(--r) + 4px); background: var(--panel); overflow: hidden; }
.room-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--zc, var(--line));
}
.room-name { font-family: var(--disp); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: 0.03em; }
.room-meta { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.room-lead { color: var(--zc); }
.room-cards { display: flex; gap: 10px; overflow-x: auto; padding: 14px; min-height: 128px; align-items: stretch; }
.room-empty { color: var(--muted); font-size: 13px; align-self: center; padding: 0 4px; }

/* ── Cards ── */
.card {
  flex: 0 0 auto; width: 110px; min-height: 146px; border-radius: 12px; position: relative;
  display: flex; flex-direction: column; text-align: left; padding: 8px;
}

/* Face-up: cream cardstock in the dark */
.card.up {
  background: var(--cream); color: var(--cream-ink);
  border: 1px solid #d8cbb0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.card.up .c-name { font-family: var(--disp); font-weight: 800; font-size: 13px; line-height: 1.15; }
.card.up .c-power {
  font-family: var(--mono); font-size: 26px; margin-top: auto;
  color: var(--ember-deep);
}
.card.up .c-owner { font-size: 12px; color: #6e6486; margin-top: 2px; }
.card.up.mine { outline: 2px solid var(--ember); outline-offset: 1px; }
.card .c-taunt { position: absolute; top: -8px; right: -6px; font-size: 16px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }

/* Face-down: THE signature — a dark card back whose ring warms with real hours */
.card.down {
  background:
    radial-gradient(60px 60px at 50% 42%, color-mix(in srgb, var(--ember) calc(var(--glow) * 1%), transparent), transparent 70%),
    linear-gradient(170deg, #2a2f57, #181b33);
  border: 1px solid var(--line);
  align-items: center; justify-content: center; gap: 6px;
}
.card.down .ring {
  width: 52px; height: 52px; border-radius: 50%;
  background:
    radial-gradient(closest-side, #181b33 74%, transparent 75% 100%),
    conic-gradient(var(--ember) calc(var(--glow) * 1%), var(--line) 0);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px;
  color: color-mix(in srgb, var(--ember) calc(40% + var(--glow) * 0.6%), var(--muted));
  box-shadow: 0 0 calc(var(--glow) * 0.22px) color-mix(in srgb, var(--ember) 45%, transparent);
}
.card.down .c-owner { font-size: 12px; color: var(--muted); }
.card.down.mine { outline: 2px dashed color-mix(in srgb, var(--ember) 60%, transparent); outline-offset: 1px; }
.card.down.peeked::after { content: "👁"; position: absolute; top: 6px; left: 8px; font-size: 11px; }

/* Hand + draft grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.hand-card, .draft-card {
  background: var(--cream); color: var(--cream-ink); border: 1px solid #d8cbb0;
  border-radius: 12px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 4px;
  min-height: 176px;
}
.hand-card .c-name, .draft-card .c-name { font-family: var(--disp); font-weight: 800; font-size: 14px; line-height: 1.2; }
.c-text { font-size: 12.5px; line-height: 1.35; color: #4c4463; }
.c-flavor { font-size: 11.5px; font-style: italic; color: #8a7f9e; margin-top: auto; }
.c-stats { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; }
.c-cost { color: #2d6fa3; } .c-pow { color: var(--ember-deep); }
.c-zone-tag { align-self: flex-start; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 999px; color: var(--night-deep); background: var(--ztag, #cfc5ad); }
.draft-card.taken { opacity: 0.35; }
.draft-card { position: relative; }
.taken-by { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--disp); font-weight: 800; color: var(--danger); transform: rotate(-12deg); font-size: 15px; }

.section-title { font-family: var(--disp); font-weight: 800; font-size: 20px; text-transform: uppercase; margin: 6px 0 4px; }
.section-sub { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

/* Feed */
.feed-item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.feed-ic { flex: 0 0 auto; }
.feed-time { margin-left: auto; flex: 0 0 auto; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.feed-item b { color: var(--ember); font-weight: 600; }

/* Standings */
.stand-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); margin-bottom: 8px; }
.stand-rank { font-family: var(--disp); font-weight: 800; font-size: 20px; width: 28px; color: var(--muted); }
.stand-row:first-child .stand-rank { color: var(--ember); }
.stand-name { font-weight: 600; }
.stand-pts { margin-left: auto; font-family: var(--mono); }
.stand-pts small { color: var(--muted); }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 9, 20, 0.6); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; max-height: 80dvh; overflow-y: auto;
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet-panel { animation: none; } }
.sheet-title { font-family: var(--disp); font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.sheet-sub { color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.sheet .btn { width: 100%; margin-bottom: 10px; }
.room-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.room-choice .btn { margin: 0; border-left: 4px solid var(--zc); justify-content: flex-start; }
.taunt-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.taunt-row button { font-size: 22px; padding: 6px 8px; border-radius: 10px; background: var(--panel-hi); border: 1px solid var(--line); }
.taunt-row button.sel { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 18%, var(--panel-hi)); }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--cream); color: var(--cream-ink); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  max-width: 90vw; text-align: center;
}
