:root {
  --bg: #0b1015;
  --bg-2: #141b23;
  --line: #26313d;
  --ink: #eef3f8;
  --ink-dim: #8b9bab;
  --accent: #f0b429;
  --win: #2ecc71;
  --lose: #ff5c5c;
  --card-red: #d92b3a;
  --card-black: #1a1a1a;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% 0%, #16222e 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 720px;
  padding: clamp(0.9rem, 3vw, 1.75rem);
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3.5vh, 2rem);
}

/* ── header ─────────────────────────────────────────────── */

.top { text-align: center; }

h1 {
  font-size: clamp(1.5rem, 7vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.deck-info {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.deck-info span { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }

.link-btn {
  background: none;
  border: 0;
  color: var(--ink-dim);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0.4rem;
}
.link-btn:hover { color: var(--accent); }

/* ── plateau ────────────────────────────────────────────── */

.board {
  display: flex;
  gap: clamp(0.3rem, 1.6vw, 0.75rem);
  justify-content: center;
}

.slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 122px;
  container-type: inline-size;
  perspective: 900px;
  border-radius: var(--radius);
  transition: transform 0.2s;
}

/* étape en cours */
.slot.active {
  transform: translateY(-6px);
}
.slot.active .card {
  box-shadow: 0 0 0 2px var(--accent), 0 10px 24px -8px rgba(240, 180, 41, 0.5);
}

.card {
  position: relative;
  aspect-ratio: 5 / 7;
  border-radius: var(--radius);
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 1.2, 0.5, 1), box-shadow 0.2s;
  box-shadow: 0 6px 16px -8px #000;
}

.slot.revealed .card { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  line-height: 1;
  overflow: hidden;
}

.back {
  background:
    repeating-linear-gradient(45deg, #1e2b3a 0 6px, #17222e 6px 12px);
  border: 1px solid var(--line);
}
.back::after {
  content: "";
  position: absolute;
  inset: 14%;
  border: 1px solid rgba(240, 180, 41, 0.25);
  border-radius: 6px;
}

.front {
  background: linear-gradient(170deg, #fff, #e8ecf1);
  border: 1px solid #cfd6de;
  transform: rotateY(180deg);
  gap: 2cqw;
}

.front .rank {
  font-size: 40cqw;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.front .suit { font-size: 34cqw; }

.front.red { color: var(--card-red); }
.front.black { color: var(--card-black); }

/* ── panneau de jeu ─────────────────────────────────────── */

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
  text-align: center;
}

.prompt {
  font-size: clamp(1.05rem, 4.4vw, 1.35rem);
  font-weight: 600;
  min-height: 1.6em;
}

body.state-win .prompt { color: var(--win); }
body.state-lose .prompt { color: var(--lose); }

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  width: 100%;
}

.choices button {
  flex: 1 1 8.5rem;
  max-width: 16rem;
  min-height: 3.25rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.choices button:hover { border-color: var(--accent); }
.choices button:active { transform: scale(0.97); }

.choices button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #14181d;
}

.choices button .sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.65;
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}

.hint {
  font-size: 0.85rem;
  color: var(--ink-dim);
  min-height: 1.2em;
}

/* ── très petits écrans : 3 cartes puis 2 ───────────────── */

@media (max-width: 340px) {
  .board { flex-wrap: wrap; }
  .slot { flex: 0 0 calc(33.333% - 0.34rem); }
}

@media (prefers-reduced-motion: reduce) {
  .card, .slot { transition: none; }
}
