:root {
  --bg: #07090f;
  --bg-2: #0e1320;
  --panel: rgba(18, 24, 38, 0.82);
  --panel-border: rgba(255, 215, 128, 0.14);
  --text: #f3efe4;
  --muted: #9aa3b5;
  --gold: #f4c55b;
  --gold-2: #b8862b;
  --dragon: #e0393e;
  --dragon-dark: #5c0c12;
  --tiger: #2f86ff;
  --tiger-dark: #0a2a5e;
  --tie: #1fbf75;
  --tie-dark: #064a2c;
  --danger: #ff5d5d;
  --ok: #3ddc84;
  --radius: 18px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Cinzel', 'Times New Roman', serif;
  --font-glyph: 'Ma Shan Zheng', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(224, 57, 62, 0.18), transparent 60%),
    radial-gradient(1200px 600px at 85% -10%, rgba(47, 134, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(244, 197, 91, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: rgba(7, 9, 15, 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--dragon) 0 50%, var(--tiger) 50% 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset, 0 6px 18px rgba(0,0,0,0.4);
  font-family: var(--font-glyph); font-size: 22px; line-height: 1;
}
.brand-name { font-family: var(--font-title); font-weight: 700; letter-spacing: 0.12em; font-size: 17px; }
.brand-name span { color: var(--gold); }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 14px; white-space: nowrap;
}
.balance-pill { border-color: rgba(244,197,91,0.35); background: rgba(244,197,91,0.08); font-weight: 700; font-size: 16px; }
.coin {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold) 45%, var(--gold-2) 100%);
  box-shadow: 0 0 0 2px rgba(184,134,43,0.5) inset;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.balance-pill.bump { animation: bump 0.6s ease; }
@keyframes bump { 30% { transform: scale(1.12); box-shadow: 0 0 24px rgba(244,197,91,0.5); } }

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1fr) 340px;
  max-width: 1400px; margin: 0 auto; padding: 20px;
}
@media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel h3 {
  margin: 0 0 12px; font-family: var(--font-title); font-size: 14px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------------------------------------------------------------- table */
.table {
  position: relative; overflow: hidden;
  border-radius: 28px;
  padding: 22px 22px 18px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.08), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,0.5), transparent 60%),
    linear-gradient(180deg, #0f3d2f, #08271e 70%, #061b15);
  border: 2px solid rgba(244,197,91,0.45);
  box-shadow: 0 0 0 8px #1a1208, 0 0 0 10px rgba(244,197,91,0.35), var(--shadow), inset 0 0 80px rgba(0,0,0,0.5);
}
.table::before { /* felt texture */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 4px 4px;
}
.table-head {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.round-tag { font-size: 13px; color: rgba(255,255,255,0.7); letter-spacing: 0.08em; text-transform: uppercase; }
.round-tag b { color: var(--gold); }
.status-banner {
  font-family: var(--font-title); font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  font-size: clamp(14px, 2vw, 20px); text-align: center;
  padding: 8px 22px; border-radius: 999px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(244,197,91,0.35);
  color: var(--gold); text-shadow: 0 0 14px rgba(244,197,91,0.45);
  transition: color 0.3s, border-color 0.3s;
}
.status-banner.closed { color: #ffb4a8; border-color: rgba(255,120,100,0.4); text-shadow: none; }
.status-banner.win-dragon { color: #fff; background: var(--dragon); border-color: #ff8b8e; }
.status-banner.win-tiger { color: #fff; background: var(--tiger); border-color: #8cbcff; }
.status-banner.win-tie { color: #fff; background: var(--tie); border-color: #8ff0c0; }

.timer { position: relative; width: 70px; height: 70px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .track { stroke: rgba(255,255,255,0.12); }
.timer .bar { stroke: var(--gold); transition: stroke 0.3s; stroke-linecap: round; }
.timer.low .bar { stroke: var(--danger); }
.timer .label {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-weight: 800; font-size: 22px; line-height: 1;
}
.timer .label small { display: block; font-size: 9px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); margin-top: 2px; }
.timer.low .label { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.zones {
  position: relative;
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.55fr) minmax(0, 1fr);
}

.zone {
  position: relative; min-width: 0;
  border-radius: 22px; padding: 16px 14px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  border: 2px solid rgba(255,255,255,0.12);
  transition: transform 0.15s ease, box-shadow 0.3s ease, border-color 0.3s, filter 0.4s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.zone.dragon { background: linear-gradient(165deg, rgba(224,57,62,0.55), rgba(92,12,18,0.85)); }
.zone.tiger  { background: linear-gradient(195deg, rgba(47,134,255,0.55), rgba(10,42,94,0.85)); }
.zone.tie    { background: linear-gradient(180deg, rgba(31,191,117,0.4), rgba(6,74,44,0.85)); justify-content: center; }
.zone::after { /* pattern overlay */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0.18;
  mix-blend-mode: overlay;
}
.zone.dragon::after { background: radial-gradient(circle at 0 0, transparent 9px, rgba(255,255,255,0.6) 10px, transparent 11px) 0 0 / 20px 20px; }
.zone.tiger::after { background: repeating-linear-gradient(115deg, transparent 0 14px, rgba(0,0,0,0.9) 14px 20px, transparent 20px 34px); }
.interactive .zone { cursor: pointer; }
@media (hover: hover) { .interactive.betting .zone:hover { transform: translateY(-3px); border-color: rgba(244,197,91,0.7); box-shadow: 0 0 30px rgba(244,197,91,0.25); } }
.interactive.betting .zone:active { transform: translateY(0) scale(0.99); }
.zone.winner { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,197,91,0.4), 0 0 50px rgba(244,197,91,0.45); animation: winglow 1.2s ease-in-out infinite alternate; }
.zone.loser { filter: grayscale(0.75) brightness(0.55); }
@keyframes winglow { to { box-shadow: 0 0 0 3px rgba(244,197,91,0.7), 0 0 80px rgba(244,197,91,0.7); } }

.zone-title { display: flex; align-items: baseline; gap: 8px; position: relative; z-index: 1; }
.zone-title .name { font-family: var(--font-title); font-weight: 800; letter-spacing: 0.14em; font-size: clamp(15px, 2vw, 22px); }
.zone-title .odds { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,0.35); color: var(--gold); }

.zone-body { display: flex; align-items: center; justify-content: center; gap: 14px; position: relative; z-index: 1; }
.zone.tiger .zone-body { flex-direction: row-reverse; }


/* medallions */
.medallion {
  --c: var(--dragon);
  width: clamp(70px, 9vw, 104px); aspect-ratio: 1; flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.35), transparent 45%),
    radial-gradient(circle, var(--c) 0 56%, #1a0d05 57% 60%, var(--gold) 61% 66%, #5a3a10 67% 70%, var(--gold-2) 71% 100%);
  box-shadow: 0 10px 24px rgba(0,0,0,0.5), inset 0 -6px 14px rgba(0,0,0,0.35);
}
.medallion::before { /* dotted ornament ring */
  content: ''; position: absolute; inset: 7%; border-radius: 50%;
  border: 2px dotted rgba(255, 240, 200, 0.7);
}
.medallion .glyph {
  font-family: var(--font-glyph); font-size: clamp(36px, 4.8vw, 56px); line-height: 1; color: #fff4d6;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4), 0 0 18px rgba(255, 220, 140, 0.7);
  transform: translateY(2px);
}
.medallion.tiger { --c: var(--tiger); }
.medallion.tie { --c: var(--tie); width: clamp(58px, 6vw, 76px); }
.medallion.tie .glyph { font-size: clamp(28px, 3.2vw, 40px); }
.zone.winner .medallion { animation: spin-glow 2.4s ease-in-out infinite; }
@keyframes spin-glow { 50% { transform: scale(1.06) rotate(-4deg); } }

/* cards */
.card-slot {
  width: clamp(70px, 8.4vw, 104px); aspect-ratio: 5 / 7; flex: none; position: relative;
  border-radius: 10px; border: 2px dashed rgba(255,255,255,0.25);
  perspective: 900px;
}
.card {
  position: absolute; inset: -2px; transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.3, 1.4, 0.5, 1);
  opacity: 0;
}
.card.dealt { opacity: 1; }
.card.anim-deal { animation: deal 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) backwards; }
.card.no-trans { transition: none !important; }
.card.flipped { transform: rotateY(180deg); }
@keyframes deal {
  from { transform: translate(var(--from-x, 0), -160px) rotate(-25deg) scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.card .face {
  position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}
.card .back {
  background:
    radial-gradient(circle at 50% 50%, rgba(244,197,91,0.9) 0 10%, transparent 11%),
    repeating-linear-gradient(45deg, rgba(244,197,91,0.35) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(244,197,91,0.35) 0 2px, transparent 2px 9px),
    linear-gradient(135deg, #6b0f1a, #2a0509);
  border: 4px solid #f7f1e3; outline: 1px solid rgba(0,0,0,0.25);
}
.card .front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #ffffff, #f1ece0);
  color: #15151a; display: grid; place-items: center;
  border: 1px solid rgba(0,0,0,0.15);
}
.card .front.red { color: #c8102e; }
.card .corner {
  position: absolute; font-weight: 800; line-height: 0.95; text-align: center;
  font-size: clamp(13px, 1.5vw, 18px);
}
.card .corner.tl { top: 6px; left: 7px; }
.card .corner.br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .corner span { display: block; font-size: 0.85em; }
.card .pip { font-size: clamp(32px, 4vw, 48px); line-height: 1; }
.card .pip.face-card { font-family: var(--font-title); font-weight: 800; font-size: clamp(30px, 3.6vw, 44px); display: flex; flex-direction: column; align-items: center; }
.card .pip.face-card small { font-size: 0.5em; }
.card-value {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  min-width: 30px; padding: 2px 8px; border-radius: 999px; text-align: center;
  background: #111; border: 1px solid var(--gold); color: var(--gold); font-weight: 800; font-size: 12px;
  opacity: 0; transition: opacity 0.3s 0.5s; z-index: 2;
}
.card.flipped + .card-value { opacity: 1; }
.vs { font-family: var(--font-title); font-weight: 800; color: rgba(255,255,255,0.4); letter-spacing: 0.2em; font-size: 13px; }

.zone-stats {
  width: 100%; position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.zone.tie .zone-stats { grid-template-columns: 1fr; }
.stat { background: rgba(0,0,0,0.3); border-radius: 12px; padding: 7px 10px; min-width: 0; }
.stat .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.6); }
.stat .v { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.mine .v { color: var(--gold); }
.pool-bar { height: 6px; border-radius: 6px; background: rgba(0,0,0,0.35); overflow: hidden; width: 100%; position: relative; z-index: 1; }
.pool-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width 0.5s ease; }

/* chip stack shown inside a zone */
.stack { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; flex-direction: column-reverse; align-items: center; }
.zone.tiger .stack { right: auto; left: 10px; }
.stack .chip { width: 34px; height: 34px; margin-top: -26px; font-size: 0; box-shadow: 0 3px 0 rgba(0,0,0,0.4); cursor: default; }
.stack .chip:last-child { font-size: 9px; }

/* chips */
.chip-tray {
  position: relative; margin-top: 18px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px;
  padding: 12px; border-radius: 18px; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.06);
}
.chip {
  --c: #888;
  width: 58px; height: 58px; border-radius: 50%; border: none; padding: 0;
  display: grid; place-items: center; position: relative;
  font-weight: 900; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  background:
    radial-gradient(circle, var(--c) 0 52%, #fff 53% 56%, transparent 57%),
    repeating-conic-gradient(var(--c) 0 22.5deg, #fff 22.5deg 45deg);
  box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 8px 16px rgba(0,0,0,0.35), inset 0 0 0 3px rgba(0,0,0,0.2);
  transition: transform 0.15s ease, box-shadow 0.2s;
}
.chip:hover { transform: translateY(-4px); }
.chip.selected { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(244,197,91,0.6), 0 10px 18px rgba(0,0,0,0.4); }
.chip[data-v="10"] { --c: #6b7280; }
.chip[data-v="50"] { --c: #d9363e; }
.chip[data-v="100"] { --c: #2563eb; }
.chip[data-v="500"] { --c: #16a34a; }
.chip[data-v="1000"] { --c: #111827; }
.chip[data-v="5000"] { --c: #9333ea; }
.chip.flying { position: fixed; z-index: 100; pointer-events: none; margin: 0; }
.tray-hint { width: 100%; text-align: center; font-size: 12px; color: rgba(255,255,255,0.55); }

/* ---------------------------------------------------------------- road / history */
.road {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(6, 26px); grid-auto-columns: 26px; gap: 4px;
  overflow-x: auto; padding: 8px; border-radius: 12px;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 30px), rgba(0,0,0,0.25);
}
.bead {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-glyph); font-size: 15px; color: #fff; line-height: 1;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.35);
}
.bead.dragon { background: var(--dragon); }
.bead.tiger { background: var(--tiger); }
.bead.tie { background: var(--tie); }
.bead.new { animation: pop 0.5s ease; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.25); } }
.ratio { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-top: 10px; font-size: 11px; font-weight: 800; }
.ratio div { display: grid; place-items: center; min-width: 0; transition: flex-grow 0.6s; overflow: hidden; white-space: nowrap; }
.ratio .d { background: var(--dragon); } .ratio .t { background: var(--tiger); } .ratio .e { background: var(--tie); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.feed li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,0.04); font-size: 13px;
  animation: slidein 0.35s ease;
}
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.feed .who { flex: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .amt { font-weight: 800; }
.feed .empty { justify-content: center; color: var(--muted); background: none; animation: none; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.tag.dragon, .dot.dragon { background: var(--dragon); }
.tag.tiger, .dot.tiger { background: var(--tiger); }
.tag.tie, .dot.tie { background: var(--tie); }
.win { color: var(--ok); } .lose { color: var(--danger); }

/* ---------------------------------------------------------------- overlay + toasts */
.result-pop {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none;
}
.result-pop .inner {
  text-align: center; padding: 22px 40px; border-radius: 24px;
  background: rgba(0,0,0,0.78); border: 2px solid var(--gold); box-shadow: 0 0 60px rgba(244,197,91,0.4);
  animation: popin 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.result-pop .big { font-family: var(--font-title); font-size: clamp(26px, 4vw, 44px); font-weight: 900; letter-spacing: 0.1em; }
.result-pop .sub { margin-top: 6px; font-size: 20px; font-weight: 800; }
@keyframes popin { from { transform: scale(0.4); opacity: 0; } }
.result-pop.out .inner { animation: popout 0.4s ease forwards; }
@keyframes popout { to { transform: scale(0.8); opacity: 0; } }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 18px; border-radius: 12px; background: #1b2233; border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow); font-weight: 600; font-size: 14px; animation: toastin 0.3s ease;
}
.toast.error { border-color: rgba(255,93,93,0.5); color: #ffc2c2; }
.toast.success { border-color: rgba(61,220,132,0.5); color: #c6ffde; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; }

/* ---------------------------------------------------------------- forms / buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06); font-weight: 700; transition: background 0.2s, transform 0.1s;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #ffd978, var(--gold-2)); color: #221405; border: none; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.dragon { background: var(--dragon); border: none; }
.btn.tiger { background: var(--tiger); border: none; }
.btn.tie { background: var(--tie); border: none; }
.btn.active { box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(244,197,91,0.4); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12); outline: none;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,197,91,0.18); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- login page */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 26px; padding: 34px 28px;
  box-shadow: var(--shadow);
}
.login-hero { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-hero .vs { font-size: 16px; color: var(--gold); }
.login-card h1 { font-family: var(--font-title); letter-spacing: 0.14em; margin: 0 0 6px; font-size: 28px; }
.login-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
/* "+91" prefix and the number share one field so they always fit the width */
.phone-row {
  display: flex; align-items: center; width: 100%; min-width: 0;
  border-radius: 12px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.phone-row:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,197,91,0.18); }
.phone-row .cc {
  flex: none; padding: 0 12px 0 14px; align-self: stretch; display: flex; align-items: center;
  color: var(--text); font-weight: 700; font-size: 17px; border-right: 1px solid rgba(255,255,255,0.12);
}
.phone-row .input {
  flex: 1; min-width: 0; width: auto; border: none; background: none; box-shadow: none;
  font-size: 18px; font-weight: 600; letter-spacing: 0.06em; padding: 14px 12px;
}
.phone-row .input:focus { box-shadow: none; }
.phone-row .input::placeholder { letter-spacing: 0.02em; font-weight: 400; }
.input { font-size: 16px; color: var(--text); } /* 16px+ stops iPhone Safari from zooming into the field */
@media (max-width: 480px) {
  .login-wrap { padding: 16px 12px; align-items: start; padding-top: max(24px, 6vh); }
  .login-card { padding: 26px 18px; border-radius: 22px; }
  .login-card h1 { font-size: 23px; letter-spacing: 0.1em; }
  .login-card p { margin-bottom: 18px; }
  .login-hero .medallion { width: 72px; }
  .login-hero .medallion .glyph { font-size: 38px; }
}
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.disclaimer {
  margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 1.5;
  padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px dashed rgba(255,255,255,0.12);
}
.footer-note { text-align: center; font-size: 12px; color: var(--muted); padding: 10px 20px 30px; }

/* ---------------------------------------------------------------- shared small bits */
.badge-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ok); letter-spacing: 0.1em; }
.badge-live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 1.4s infinite; }
.mini-card { display: inline-grid; place-items: center; width: 30px; height: 40px; border-radius: 5px; background: #fff; color: #111; font-weight: 800; font-size: 12px; line-height: 1; vertical-align: middle; }
.mini-card.red { color: #c8102e; }
.card-value:empty { display: none; }
.t-glyph { display: none; font-family: var(--font-glyph); }
.table:not(.interactive) .stat.mine, .table:not(.interactive) .stack { display: none; }
.table:not(.interactive) .zone-stats { grid-template-columns: 1fr; }

/* ---------------------------------------------------------------- admin */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); }
.tabs button { padding: 8px 16px; border-radius: 10px; background: none; border: none; font-weight: 700; font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.tabs button.on { background: rgba(244,197,91,0.15); color: var(--gold); }
.tabs button .ico { font-size: 16px; }
.view { max-width: 1400px; margin: 0 auto; padding: 20px; }
.live-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); grid-template-areas: "table ctl" "extra ctl"; align-items: start; }
.live-grid > .ctl { align-self: start; position: sticky; top: 76px; }
.stack-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.two-col { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.admin-table .table { padding: 16px; }

.ctl { display: flex; flex-direction: column; gap: 18px; }
.ctl-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.ctl-label em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--gold); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.06); }
.seg button { padding: 10px 6px; border-radius: 10px; border: none; background: none; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; transition: background 0.2s, color 0.2s; }
.seg button.on { background: rgba(255,255,255,0.12); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.seg button.on.dragon { background: var(--dragon); }
.seg button.on.tiger { background: var(--tiger); }
.seg button.on.tie { background: var(--tie); }
.seg button.on.gold { background: linear-gradient(135deg, #ffd978, var(--gold-2)); color: #221405; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.outcomes { display: grid; gap: 6px; }
.outcome { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,0.3); border: 1px solid transparent; font-size: 14px; }
.outcome .sub { font-size: 12px; color: var(--muted); }
.outcome .pnl { font-weight: 800; font-size: 16px; text-align: right; }
.outcome.pick { border-color: var(--gold); background: rgba(244,197,91,0.08); }
.outcome.pick .flag { color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; margin-left: 6px; }
.secret { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,93,93,0.08); border: 1px dashed rgba(255,93,93,0.35); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { flex: 1 1 220px; }
.ulist { display: flex; flex-direction: column; gap: 8px; }
.urow {
  display: grid; grid-template-columns: minmax(150px, 1.3fr) repeat(3, minmax(90px, 1fr)) auto; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.urow:hover { border-color: rgba(244,197,91,0.4); background: rgba(244,197,91,0.05); }
.urow .ph { font-weight: 700; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.urow .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.urow .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.urow .meta { font-size: 12px; color: var(--muted); font-weight: 400; }
.odot { width: 8px; height: 8px; border-radius: 50%; background: #475066; flex: none; }
.odot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

.sheet-bg { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: fadein 0.2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: #111726; border: 1px solid var(--panel-border); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); animation: sheetin 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes sheetin { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.big-bal { display: flex; align-items: center; gap: 10px; font-size: 32px; font-weight: 900; margin: 4px 0 14px; }
.big-bal .coin { width: 28px; height: 28px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.amt-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 16px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.mini-stats > div { background: rgba(0,0,0,0.3); border-radius: 12px; padding: 8px 10px; }
.mini-stats .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.mini-stats .v { font-weight: 800; font-size: 14px; margin-top: 2px; }
.sheet h4 { margin: 14px 0 8px; font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.1em; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.06); border-radius: 14px; padding: 12px 14px; }
.kpi .k { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 800; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.06); white-space: nowrap; }
.data-table th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; position: sticky; top: 0; background: #121826; }
.data-table td.r, .data-table th.r { text-align: right; }
.table-scroll { overflow: auto; max-height: 420px; border-radius: 12px; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.dist { display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 64px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.dist-bar { height: 12px; border-radius: 6px; background: rgba(255,255,255,0.06); position: relative; overflow: hidden; }
.dist-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; transition: width 0.5s; }
.dist-bar b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; opacity: 0.8; }
details.explain { font-size: 14px; line-height: 1.65; color: #d9d6cc; }
details.explain summary { cursor: pointer; list-style: none; font-family: var(--font-title); font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); display: flex; justify-content: space-between; align-items: center; }
details.explain summary::-webkit-details-marker { display: none; }
details.explain summary::after { content: '＋'; font-family: var(--font-ui); }
details.explain[open] summary::after { content: '－'; }
.explain h4 { margin: 18px 0 6px; color: var(--gold); font-size: 14px; letter-spacing: 0.04em; }
.explain .formula { background: rgba(0,0,0,0.35); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 8px; margin: 8px 0; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tablet / phone */
@media (max-width: 1000px) {
  .live-grid { grid-template-columns: 1fr; grid-template-areas: "table" "ctl" "extra"; gap: 14px; }
  .live-grid > .ctl { position: static; }
}
@media (max-width: 760px) {
  /* no backdrop-filter here: it would trap the fixed bottom tab bar inside the header */
  .topbar { padding: 8px 12px; gap: 8px; backdrop-filter: none; background: rgba(7,9,15,0.96); }
  .topbar .brand-name, .topbar #phone, .topbar #conn { display: none; }
  .layout, .view { padding: 12px; gap: 14px; }
  .side, .stack-col { gap: 14px; }
  .panel { padding: 14px; border-radius: 16px; }
  /* admin: tabs become a bottom navigation bar */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-radius: 0; border: none;
    border-top: 1px solid var(--panel-border); background: rgba(7,9,15,0.94); backdrop-filter: blur(14px);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; }
  .tabs button .ico { font-size: 20px; }
  body.admin { padding-bottom: 76px; }
  .urow { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .urow .c-hide { display: none; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .sheet-bg { place-items: end center; padding: 0; }
  .sheet { max-width: none; border-radius: 22px 22px 0 0; max-height: 90vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .kpi .v { font-size: 18px; }
}

/* player table on phones: everything fits in one screen, chips pinned to the bottom */
@media (max-width: 640px) {
  body.game { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .table { padding: 12px 8px 10px; border-radius: 18px; box-shadow: 0 0 0 4px #1a1208, 0 0 0 5px rgba(244,197,91,0.35), var(--shadow); }
  .table-head { flex-wrap: wrap; margin-bottom: 10px; gap: 8px; }
  .round-tag { font-size: 11px; }
  .status-banner { order: 3; width: 100%; font-size: 13px; padding: 6px 12px; }
  .timer { width: 54px; height: 54px; }
  .timer .label { font-size: 18px; }
  .zones { grid-template-columns: 1fr 0.78fr 1fr; gap: 6px; }
  .zone { padding: 10px 6px 8px; gap: 8px; border-radius: 16px; }
  .zone-title { flex-direction: column; align-items: center; gap: 3px; }
  .zone-title .name { font-size: 13px; letter-spacing: 0.08em; display: flex; align-items: center; gap: 4px; }
  .zone-title .odds { font-size: 10px; padding: 1px 6px; }
  .t-glyph { display: inline; font-size: 16px; color: #fff4d6; }
  .zone-body .medallion { display: none; }
  .zone.tie .medallion.tie { width: 46px; }
  .zone.tie .medallion.tie .glyph { font-size: 26px; }
  .zone.tie .vs { font-size: 10px; }
  .card-slot { width: min(64px, 18vw); border-radius: 8px; }
  .card .face { border-radius: 7px; }
  .card .corner { font-size: 11px; }
  .card .corner.tl { top: 3px; left: 4px; } .card .corner.br { bottom: 3px; right: 4px; }
  .card .pip { font-size: 26px; } .card .pip.face-card { font-size: 22px; }
  .card .back { border-width: 3px; }
  .card-value { font-size: 10px; min-width: 22px; padding: 1px 5px; bottom: -8px; }
  .pool-bar { height: 4px; }
  .zone-stats, .zone.tie .zone-stats { grid-template-columns: 1fr; gap: 4px; }
  .stat { padding: 4px 6px; border-radius: 8px; text-align: center; }
  .stat .k { font-size: 9px; letter-spacing: 0.04em; }
  .stat .v { font-size: 13px; }
  .stack { top: 6px; right: 6px; }
  .zone.tiger .stack { left: 6px; }
  .stack .chip { width: 22px; height: 22px; margin-top: -17px; box-shadow: 0 2px 0 rgba(0,0,0,0.4); }
  .stack .chip:last-child { font-size: 7px; }
  .chip-tray {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0; border-radius: 18px 18px 0 0;
    flex-wrap: nowrap; justify-content: space-evenly; gap: 4px;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    background: rgba(8,20,16,0.95); backdrop-filter: blur(12px); border: none; border-top: 1px solid rgba(244,197,91,0.35);
  }
  .chip { width: 48px; height: 48px; font-size: 12px; flex: none; }
  .tray-hint { display: none; }
  .result-pop .inner { padding: 14px 20px; border-radius: 18px; margin: 0 10px; }
  .result-pop .big { font-size: 22px; }
  .result-pop .sub { font-size: 16px; }
  .feed { max-height: 240px; }
  .road { grid-template-rows: repeat(6, 22px); grid-auto-columns: 22px; gap: 3px; }
  .bead { width: 22px; height: 22px; font-size: 13px; }
  .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { text-align: center; }
  .seg button { font-size: 13px; padding: 9px 4px; }
}
@media (max-width: 370px) {
  .chip { width: 42px; height: 42px; font-size: 11px; }
}
