:root {
  --bg-top: #2A2830;
  --bg: #141317;
  --surface: #2E2C35;
  --line: #3A3842;
  --panel: rgba(255, 255, 255, 0.03);
  --accent: #D4B483;
  --accent-hi: #E8CFA3;
  --text: #F3EEE4;
  --text-2: #B9B3A8;
  --label: #A39D93;
  --card: #F7F4EC;
  --red: #B8322A;
  --black: #1C1B1F;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
}
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 24px);
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-top) 0%, var(--bg) 70%);
}
.screen[hidden] { display: none; }
.grow { flex-grow: 1; min-height: 16px; }

/* shared bits */
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; color: var(--label); }
.label.wide { letter-spacing: 0.18em; font-size: 12px; }
.accent { color: var(--accent) !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.wordmark { font-family: var(--serif); font-weight: 600; color: var(--accent); margin: 0; }
.wordmark.big { font-size: clamp(48px, 15vw, 64px); letter-spacing: 0.08em; line-height: 1; margin-top: 20px; }
.wordmark.small-mark { font-size: 24px; letter-spacing: 0.12em; }

.topbar { display: flex; align-items: center; justify-content: space-between; }
.topbar.end { justify-content: flex-end; width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line);
  background: transparent; color: var(--text-2); display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); }

.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.btn {
  height: 52px; border-radius: 26px; border: 1px solid var(--line); background: transparent;
  font-size: 15px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.gold {
  height: 58px; border-radius: 29px; border: none; background: var(--accent); color: #17161A;
  font-size: 17px; font-weight: 700; letter-spacing: 0.12em;
}
.btn.gold:hover { background: var(--accent-hi); }
.btn.gold.icon { font-size: 16px; letter-spacing: 0.06em; }
.btn.outline:hover { border-color: #55525e; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 600; padding: 8px 0; min-height: 32px; }
.link-btn.center { align-self: center; color: var(--text-2); font-weight: 500; }

.stats3 { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; margin-top: 28px; }
.stats3 > div { display: flex; flex-direction: column; gap: 2px; }
.stats3 span { font-size: 20px; font-weight: 600; }
.stats3 small { font-size: 11px; letter-spacing: 0.08em; color: var(--label); }
.stats3.boxed { margin-top: 28px; }
.stats3.boxed > div { border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; gap: 4px; }
.stats3.boxed span { font-size: 18px; }

/* HOME */
.home { align-items: center; padding-left: 24px; padding-right: 24px; background: radial-gradient(120% 70% at 50% 0%, var(--bg-top) 0%, var(--bg) 70%); }
.fan { position: relative; width: 220px; height: 150px; margin-top: 8px; }
.fan-card {
  position: absolute; top: 18px; width: 78px; height: 108px; border-radius: 10px; background: var(--card);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45); font-family: var(--serif);
}
.fan-card.black { color: var(--black); }
.fan-card.red { color: var(--red); }
.fan-card.left { left: 30px; transform: rotate(-14deg); }
.fan-card.right { left: 112px; transform: rotate(14deg); }
.fan-card.mid { left: 71px; top: 4px; box-shadow: 0 16px 36px rgba(0,0,0,0.5); }
.fan-card b { position: absolute; top: 6px; left: 8px; font-size: 22px; line-height: 1; }
.fan-card i { position: absolute; top: 28px; left: 9px; font-size: 14px; line-height: 1; font-style: normal; }
.fan-card em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; font-style: normal; }
.tagline { margin: 14px 0 0; font-size: 15px; line-height: 1.5; color: var(--text-2); text-align: center; }
.daily {
  width: 100%; margin-top: 36px; padding: 18px 20px; border-radius: 20px;
  display: flex; align-items: center; justify-content: space-between; text-align: left;
}
.daily:hover { border-color: #55525e; }
.daily-text { display: flex; flex-direction: column; gap: 4px; }
.daily-title { font-size: 17px; font-weight: 600; }
.round-go { width: 44px; height: 44px; border-radius: 22px; background: var(--surface); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.round-go svg { stroke-width: 2; }

/* GAME */
.scorebox { margin-top: 18px; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.score-row { display: flex; justify-content: space-between; align-items: flex-end; }
.score-col { display: flex; flex-direction: column; gap: 2px; }
.score-col.right { align-items: flex-end; }
.score-num { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.deal-tag { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 2px; }
.tier { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--surface); color: var(--text-2); }
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--surface); }
.bar-fill { height: 6px; border-radius: 3px; background: var(--accent); width: 0; transition: width .25s ease; }
.tick { position: absolute; top: -2px; width: 2px; height: 10px; border-radius: 1px; background: #5b5866; }
.score-foot { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }

.board {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1fr);
  gap: 6px 5px;
  container-type: inline-size;
}
.card {
  aspect-ratio: 54 / 76; border-radius: 8px; background: var(--card); position: relative; border: none; padding: 0;
  font-family: var(--serif); box-shadow: 0 4px 10px rgba(0,0,0,0.35);
  transition: transform .12s ease, outline-color .12s ease;
  outline: 3px solid transparent; outline-offset: 2px;
  touch-action: manipulation;
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card .r { position: absolute; top: 5%; left: 11%; font-size: 5.4cqw; font-weight: 700; line-height: 1; }
.card .s1 { position: absolute; top: 30%; left: 13%; font-size: 3.4cqw; line-height: 1; }
.card .s2 { position: absolute; right: 11%; bottom: 5%; font-size: 7.4cqw; line-height: 1; }
.card.sel { outline-color: var(--accent); transform: translateY(-4px); }
.card.locked::after {
  content: ''; position: absolute; inset: 0; border-radius: 8px; box-shadow: inset 0 0 0 2px var(--accent); opacity: .7;
}
.card.locked { cursor: default; }
.card.flash { animation: flash .5s ease; }
@keyframes flash { 50% { transform: scale(1.06); } }

.pill {
  border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--surface); color: var(--accent); text-align: center; min-width: 0;
}
.pill.row { aspect-ratio: 54 / 76; margin-left: 3px; }
.pill.col { height: 46px; }
.pill b { font-size: 5.6cqw; line-height: 1; }
.pill.col b { font-size: 4.8cqw; }
.pill span { font-size: 2.7cqw; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap; }
.pill.zero { background: transparent; border: 1px dashed #4A4752; color: #8C877E; }
.pill.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

.hint-line { margin: 14px 0 0; font-size: 13px; color: var(--label); text-align: center; min-height: 18px; }
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.action {
  height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  font-size: 12px; font-weight: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.action svg { width: 22px; height: 22px; }
.action:hover { border-color: #55525e; }
.action:disabled { opacity: .4; cursor: default; }

/* RESULT */
.result {
  align-items: center; text-align: center; padding-top: calc(env(safe-area-inset-top) + 72px);
  padding-left: 24px; padding-right: 24px;
  background: radial-gradient(110% 60% at 50% 30%, #3A3226 0%, var(--bg) 72%);
}
.headline { margin: 16px 0 0; font-family: var(--serif); font-weight: 600; font-size: 60px; line-height: 1; }
.subhead { margin: 12px 0 0; font-size: 16px; line-height: 1.5; color: #CFC9BE; }
.ring {
  margin-top: 36px; width: 200px; height: 200px; border-radius: 100px; border: 2px solid var(--accent);
  box-shadow: 0 0 60px rgba(212,180,131,0.25); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.ring-num { font-family: var(--serif); font-size: 84px; font-weight: 600; line-height: 1; color: var(--accent); font-variant-numeric: lining-nums; }
.ring-of { font-size: 13px; letter-spacing: 0.1em; color: var(--text-2); }
.stars { display: flex; gap: 14px; margin-top: 24px; }
.star { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; letter-spacing: .08em; color: var(--label); }
.star svg { width: 28px; height: 28px; stroke-width: 1.5; }
.star.on.bronze svg { fill: #B08257; stroke: #B08257; }
.star.on.silver svg { fill: #C9C6C0; stroke: #C9C6C0; }
.star.on.gold svg { fill: var(--accent); stroke: var(--accent); }

/* MODAL + TOAST */
.modal {
  position: fixed; inset: 0; background: rgba(10, 9, 12, 0.7); display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.modal[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 430px; background: #1D1C21; border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 85dvh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 12px; font-family: var(--serif); font-size: 30px; font-weight: 600; color: var(--accent); }
.sheet p, .sheet li { color: var(--text-2); font-size: 14px; line-height: 1.55; }
.sheet ul { padding-left: 18px; margin: 0 0 8px; }
.sheet .stack { margin-top: 16px; }
.chart { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart td { padding: 9px 2px; border-bottom: 1px solid var(--line); }
.chart td:last-child { text-align: right; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translate(-50%, 20px);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 20px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
