/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg: #141414;
  --surface: #1F1F1F;
  --panel: #262626;
  --edge: #333333;
  --ink: #F2F2F2;
  --muted: #9A9A9A;
  --mult: #E63946;
  --chip: #3A86FF;
  --gold: #F5B700;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
}

.mono-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 800;
}

.app-root {
  height: 100vh;
  width: 100vw;
  position: relative;
}

.screen {
  height: 100%;
  width: 100%;
}
.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}
button:focus-visible,
.card:focus-visible,
.joker-slot:focus-visible {
  outline: 3px solid var(--chip);
  outline-offset: 2px;
}

.btn {
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: #2f2f2f; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--chip); border-color: var(--chip); color: #0c1220; }
.btn-primary:hover:not(:disabled) { background: #5a9bff; }
.btn-danger { background: var(--mult); border-color: var(--mult); color: #200; }
.btn-danger:hover:not(:disabled) { background: #ef6069; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ── Menu screen ───────────────────────────────────────────────── */
.menu-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(58,134,255,.10), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(230,57,70,.10), transparent 40%),
    var(--bg);
  padding: 24px;
}
.menu-screen.hidden { display: none; }
.menu-card {
  max-width: 560px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
}
.menu-glyphs {
  font-size: 34px;
  letter-spacing: 10px;
  color: var(--muted);
  margin-bottom: 8px;
}
.menu-title {
  font-weight: 800;
  font-size: 34px;
  margin: 0 0 12px;
}
.menu-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 24px;
}
.menu-rules {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  text-align: left;
  display: grid;
  gap: 10px;
}
.menu-rules li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px 14px;
}
.menu-rules i { color: var(--chip); width: 18px; text-align: center; }
#btn-continue-run { margin-top: 10px; }
.menu-best {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Game screen layout ───────────────────────────────────────── */
.game-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.game-screen.hidden { display: none; }

.status-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--edge);
  gap: 16px;
  flex-shrink: 0;
}
.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.status-caption {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.status-blind { line-height: 1.2; }
.blind-label { display: block; font-weight: 800; font-size: 16px; }
.ante-label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.status-target { text-align: left; }
.target-num { display: block; font-size: 22px; color: var(--chip); }
.status-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 160px;
}
.score-num { font-size: 48px; line-height: 1; color: var(--ink); }
.status-money { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 800; font-size: 18px; }
.status-money i { color: var(--gold); }
.status-counters { display: flex; gap: 10px; }
.counter-pill {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 4px 10px;
  text-align: center;
  min-width: 56px;
}
.counter-pill .mono-num { font-size: 16px; display: block; }
.boss-mod {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(230,57,70,.15);
  border: 1px solid var(--mult);
  color: var(--mult);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  max-width: 220px;
}

.play-area {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 16px;
  padding: 16px 24px;
  overflow: hidden;
  min-height: 0;
}
.joker-rail, .deck-rail {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 0;
  align-self: start;
  overflow-y: auto;
}
.rail-title {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.joker-slots { display: flex; flex-direction: column; gap: 10px; }
.joker-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 8px 10px;
}
.joker-slot i { color: var(--gold); font-size: 18px; width: 20px; text-align: center; }
.joker-slot .joker-name { font-size: 13px; font-weight: 600; }
.joker-slot-empty {
  border-style: dashed;
  color: var(--muted);
  justify-content: center;
  font-size: 12px;
}
.deck-stat { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.deck-stat i { width: 16px; text-align: center; }
.deck-stat b { color: var(--ink); }

.play-center {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.example-hint {
  text-align: center;
  color: var(--muted);
  padding: 16px;
}
.example-hint-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.example-hint-cards { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mini-card {
  background: var(--panel);
  border: 1px dashed var(--edge);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
}
.mini-plus, .mini-eq { color: var(--muted); font-weight: 700; }
.mini-combo {
  background: rgba(230,57,70,.15);
  border: 1px solid var(--mult);
  color: var(--mult);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 13px;
}
.example-hint-note { font-size: 12px; }

.played-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 16px; }
.floater-host { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  bottom: 40%;
  font-weight: 800;
  font-size: 22px;
  animation: floatUp .9s ease-out forwards;
}
.floater-chip { color: var(--chip); }
.floater-mult { color: var(--mult); font-size: 16px; letter-spacing: .05em; }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(.8); }
  15% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}
.combo-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--mult);
  color: var(--mult);
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  --lift: 0px;
  width: 92px;
  height: 128px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  cursor: pointer;
  user-select: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  flex-shrink: 0;
}
.card .card-glyph { font-size: 32px; line-height: 1; }
.card .card-label { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; }
.card .card-chips { font-size: 13px; font-weight: 800; color: var(--chip); font-variant-numeric: tabular-nums; }
.card.card-move .card-chips { color: var(--gold); }
.card.card-enhanced { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(245,183,0,.4) inset; }
.card.card-selected {
  border-color: var(--chip);
  box-shadow: 0 8px 18px rgba(58,134,255,.35);
  transform: translateY(-16px);
}
.card:hover:not(.card-selected) { transform: translateY(-6px); border-color: var(--muted); }
.card.card-static { cursor: default; }

/* ── Hand area ─────────────────────────────────────────────────── */
.hand-area {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--edge);
  padding: 14px 24px 18px;
}
.hand-fan {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: -12px;
  min-height: 140px;
  padding: 6px 0 10px;
}
@media (min-width: 768px) {
  .hand-fan .card { margin: 0 -10px; }
  .hand-fan .card:nth-child(1) { transform: rotate(-9deg) translateY(10px); }
  .hand-fan .card:nth-child(2) { transform: rotate(-6deg) translateY(4px); }
  .hand-fan .card:nth-child(3) { transform: rotate(-3deg) translateY(0); }
  .hand-fan .card:nth-child(4) { transform: rotate(0deg) translateY(-4px); }
  .hand-fan .card:nth-child(5) { transform: rotate(3deg) translateY(0); }
  .hand-fan .card:nth-child(6) { transform: rotate(6deg) translateY(4px); }
  .hand-fan .card:nth-child(7) { transform: rotate(9deg) translateY(10px); }
  .hand-fan .card:nth-child(8) { transform: rotate(12deg) translateY(16px); }
  .hand-fan .card.card-selected { transform: translateY(-20px) !important; }
}
.action-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ── Shop ──────────────────────────────────────────────────────── */
.shop-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.shop-screen.hidden, .shop-screen[hidden] { display: none; }
.shop-scene {
  width: min(1000px, 94vw);
  height: min(720px, 92vh);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  border-bottom: 1px solid var(--edge);
}
.shop-title { font-weight: 800; font-size: 24px; }
.shop-reward { color: var(--gold); font-size: 13px; font-weight: 600; margin-top: 2px; }
.shop-money { color: var(--gold); font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.shop-grid {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-content: start;
}
@media (min-width: 1024px) {
  .shop-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 767px) {
  .shop-grid { grid-template-columns: 1fr; }
}
.shop-item {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shop-item-icon { font-size: 26px; color: var(--gold); }
.shop-item-name { font-weight: 700; font-size: 16px; }
.shop-item-desc { font-size: 13px; color: var(--muted); line-height: 1.4; flex: 1; }
.shop-item-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.shop-item-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.shop-item-price { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.shop-footer {
  display: flex;
  justify-content: space-between;
  padding: 18px 26px;
  border-top: 1px solid var(--edge);
}

/* ── End screens ───────────────────────────────────────────────── */
.end-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  animation: fadeIn .3s ease;
}
.end-screen.hidden { display: none; }
.end-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 20px;
  padding: 40px;
}
.end-icon { font-size: 48px; margin-bottom: 12px; }
.end-title { font-weight: 800; font-size: 28px; margin: 0 0 8px; }
.end-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.end-stats { display: grid; gap: 8px; margin-bottom: 24px; text-align: left; }
.end-stats div { display: flex; justify-content: space-between; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.end-stats b { font-variant-numeric: tabular-nums; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-slide-enter { animation: fadeSlideIn .28s ease; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--mult);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  animation: toastIn .18s ease, toastOut .25s ease 2.2s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ── Tooltip ───────────────────────────────────────────────────── */
.tooltip-root {
  position: fixed;
  z-index: 90;
  pointer-events: none;
}
.tooltip-box {
  position: absolute;
  max-width: 220px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(0,0,0,.5);
}
.tooltip-box strong { display: block; margin-bottom: 4px; font-size: 13px; }

/* ── Responsive < 768px ────────────────────────────────────────── */
@media (max-width: 767px) {
  .status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
  }
  .status-left { justify-content: space-between; order: 1; }
  .status-center { order: 2; }
  .status-right { justify-content: space-between; order: 3; }
  .score-num { font-size: 40px; }
  .target-num { font-size: 20px; }

  .play-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    padding: 10px 12px;
    overflow-y: auto;
  }
  .joker-rail, .deck-rail {
    position: static;
    order: 1;
  }
  .joker-slots { flex-direction: row; overflow-x: auto; }
  .joker-slot { flex-shrink: 0; }
  .play-center { order: 2; min-height: 220px; }
  .deck-rail { order: 3; display: flex; gap: 16px; }
  .deck-rail .rail-title { display: none; }
  .deck-stat { margin-bottom: 0; }

  .hand-area {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
  }
  .hand-fan {
    justify-content: flex-start;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 8px;
  }
  .hand-fan .card { transform: none !important; }
  .card { width: 82px; height: 116px; }
  .action-bar { position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
  .btn { padding: 12px 14px; flex: 1; }

  .shop-scene { width: 100vw; height: 100vh; border-radius: 0; }
  .shop-header { padding: 14px 16px; }
  .shop-grid { padding: 14px 16px; }
  .shop-footer { padding: 12px 16px; }
}

/* ── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
