/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Road palette */
  --bg-dark: #1a1c20;
  --bg-mid: #252830;
  --bg-card: #2d3040;
  --asphalt: #2a2d35;
  --road-line: #f0c040;
  --road-white: #e8e4dc;
  --text: #e8e4dc;
  --text-dim: #8a8d98;
  --text-bright: #ffffff;

  /* Card type colors */
  --distance-bg: #1b5e20;
  --distance-fg: #a5d6a7;
  --distance-accent: #4caf50;
  --hazard-bg: #7f1d1d;
  --hazard-fg: #ffab91;
  --hazard-accent: #ef5350;
  --remedy-bg: #0d47a1;
  --remedy-fg: #90caf9;
  --remedy-accent: #42a5f5;
  --safety-bg: #4a3800;
  --safety-fg: #ffe082;
  --safety-accent: #ffc107;

  /* UI */
  --green: #43a047;
  --red: #e53935;
  --amber: #f0c040;
  --blue: #42a5f5;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 4px 20px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  font-family: 'Source Sans 3', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ───────────────────────────────────────────── */
.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; }

/* ── Lobby ─────────────────────────────────────────────── */
#lobby-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, #2a2f3a 0%, var(--bg-dark) 70%);
}

.lobby-container {
  width: 90%;
  max-width: 420px;
  text-align: center;
}

.logo-area { margin-bottom: 2rem; }

.logo-road-line {
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--road-line) 0, var(--road-line) 30px, transparent 30px, transparent 50px);
  margin: 0.8rem 0;
  border-radius: 2px;
}

.logo-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 3.4rem;
  line-height: 1;
  letter-spacing: 0.15em;
  color: var(--text-bright);
}
.logo-bornes {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 4.2rem;
  color: var(--road-line);
  letter-spacing: 0.08em;
}
.logo-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lobby-form { text-align: left; }

.form-group {
  margin-bottom: 0.9rem;
}
.form-group label {
  display: block;
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg-mid);
  border: 2px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--road-line);
}
.form-group select option { background: var(--bg-mid); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.1); }

.btn-create {
  background: var(--green);
  color: #fff;
  width: 100%;
}
.btn-join {
  background: var(--blue);
  color: #fff;
  width: 100%;
}
.btn-cancel {
  background: #555;
  color: #ccc;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.lobby-actions { margin-top: 0.5rem; }

.create-section, .join-section {
  padding: 0.5rem 0;
}
.create-row {
  display: flex;
  gap: 0.5rem;
}
.create-row .form-group { flex: 1; }

.lobby-divider {
  text-align: center;
  color: var(--text-dim);
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  margin: 0.5rem 0;
  position: relative;
}
.lobby-divider::before,
.lobby-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #444;
}
.lobby-divider::before { left: 0; }
.lobby-divider::after { right: 0; }

/* ── Waiting Room ──────────────────────────────────────── */
#waiting-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #2a2f3a 0%, var(--bg-dark) 70%);
}

.waiting-container {
  text-align: center;
  width: 90%;
  max-width: 400px;
}
.waiting-container h2 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.game-code-display {
  background: var(--bg-mid);
  padding: 1rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.2rem;
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  color: var(--text-dim);
}
.game-code-display span {
  font-size: 2rem;
  color: var(--road-line);
  letter-spacing: 0.2em;
  font-weight: 700;
  display: block;
  margin-top: 0.3rem;
}

.player-list {
  margin-bottom: 1.2rem;
}
.player-list-item {
  background: var(--bg-card);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.player-list-item .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.waiting-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 1rem;
}

/* ── Game Screen Layout ────────────────────────────────── */
#game-screen {
  flex-direction: column;
  background: var(--bg-dark);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  background: var(--bg-mid);
  border-bottom: 2px solid #333;
  min-height: 44px;
  flex-shrink: 0;
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.game-id-tag {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}
.game-id-tag span { color: var(--road-line); font-weight: 700; }
.deck-info {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.deck-info span { color: var(--text); font-weight: 600; }

.round-info {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.round-info span { color: var(--road-line); font-weight: 700; }

.turn-indicator {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--road-line);
  text-align: center;
}

.btn-icon {
  background: none;
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.btn-icon:hover { border-color: #666; background: rgba(255,255,255,0.05); }
.btn-icon.active-chat { border-color: var(--road-line); background: rgba(240,192,64,0.12); }
.btn-icon.active-events { border-color: #9c6ade; background: rgba(156,106,222,0.12); }

/* ── Opponents Area ────────────────────────────────────── */
.opponents-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  overflow-x: auto;
  flex-shrink: 0;
}

.opponent-tableau {
  flex: 1;
  min-width: 140px;
  background: var(--bg-mid);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.6rem;
  border: 2px solid #333;
  transition: border-color 0.3s;
  overflow: visible;
}
.opponent-tableau.is-current-turn {
  border-color: var(--road-line);
}
.opponent-tableau.disconnected { opacity: 0.5; }

.opp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.opp-name {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opp-miles {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--distance-accent);
}

.opp-status {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.status-badge {
  font-size: 0.65rem;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.badge-rolling { background: var(--green); color: #fff; }
.badge-stopped { background: #555; color: #ccc; }
.badge-hazard { background: var(--hazard-accent); color: #fff; }
.badge-speed-limit { background: #e65100; color: #fff; }
.badge-safety { background: var(--safety-accent); color: #000; }
.badge-cards { background: rgba(255,255,255,0.08); color: var(--text-dim); }

/* ── Center Area ───────────────────────────────────────── */
.center-area {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.3rem;
  flex-shrink: 0;
}

.discard-pile {
  text-align: center;
}
.pile-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  margin-bottom: 0.2rem;
}

/* ── My Tableau ────────────────────────────────────────── */
.my-tableau {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 0.4rem 0.8rem;
  flex-shrink: 0;
}

.my-miles-display {
  text-align: center;
}
.my-miles-number {
  font-family: 'Oswald', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--distance-accent);
  line-height: 1;
}
.my-miles-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.15em;
}

.my-status-area {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  align-items: center;
}

.my-safeties {
  display: flex;
  gap: 0.3rem;
}

.safety-token {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--safety-accent);
  color: #000;
  border: 2px solid #b8860b;
  font-family: 'Oswald', sans-serif;
}
.safety-token.cf { border-color: #ff4444; box-shadow: 0 0 8px rgba(255,68,68,0.5); }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  width: 72px;
  height: 102px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Oswald', sans-serif;
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  border: 2.5px solid;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5);
}
.card-small {
  width: 52px;
  height: 72px;
}

/* ── Small card overrides ────────────────────── */
.card-small .corner-tl,
.card-small .corner-br { display: none; }
.card-small .road-stripe { width: 2px; }
.card-small .road-stripe.left { left: 5px; }
.card-small .road-stripe.right { right: 5px; }
.card-small .dist-value { font-size: 1.3rem; }
.card-small .dist-unit { font-size: 0.35rem; }
.card-small .dist-unit-fr { display: none; }
.card-small .mile-marker { display: none; }

.card-small .hazard-triangle {
  border-left-width: 13px;
  border-right-width: 13px;
  border-bottom-width: 23px;
}
.card-small .hazard-triangle .tri-inner {
  top: 4px; left: -8px;
  border-left-width: 8px;
  border-right-width: 8px;
  border-bottom-width: 14px;
}
.card-small .hazard-triangle .tri-symbol { font-size: 0.55rem; top: 7px; }
.card-small .hazard-octagon { width: 26px; height: 26px; }
.card-small .hazard-octagon span { font-size: 0.4rem; }
.card-small .hazard-speed-circle { width: 26px; height: 26px; border-width: 2px; }
.card-small .hazard-speed-circle span { font-size: 0.75rem; }
.card-small .hazard-label { font-size: 0.38rem; margin-top: 3px; }
.card-small .hazard-label-fr { display: none; }

.card-small .remedy-icon { width: 26px !important; height: 26px !important; }
.card-small .remedy-icon span { font-size: 0.8rem !important; }
.card-small .remedy-roll .arrow { font-size: 0.9rem !important; }
.card-small .remedy-end-limit span { font-size: 0.7rem !important; }
.card-small .remedy-end-limit::after { height: 18px !important; width: 2px !important; }
.card-small .remedy-label { font-size: 0.38rem; margin-top: 3px; }
.card-small .remedy-label-fr { display: none; }

.card-small .inner-border { display: none; }
.card-small .star-deco { display: none; }
.card-small .safety-shield { width: 24px !important; height: 28px !important; }
.card-small .shield-text { font-size: 0.35rem !important; }
.card-small .safety-label { font-size: 0.36rem; margin-top: 2px; }
.card-small .safety-label-fr { display: none; }

.card-facedown {
  background: linear-gradient(135deg, #3a3d4a, #2a2d35);
  border: 2px dashed #555;
}
.card-facedown::after {
  content: '🛣️';
  font-size: 1.2rem;
}
.card-small.card-facedown::after { font-size: 0.9rem; }

.card-empty {
  border: 2px dashed #444;
  background: transparent;
}

/* Corner badges */
.card .corner-tl,
.card .corner-br {
  position: absolute;
  font-family: 'Oswald', sans-serif;
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
  line-height: 1;
}
.corner-tl { top: 4px; left: 5px; }
.corner-br { bottom: 4px; right: 5px; transform: rotate(180deg); }

/* ── DISTANCE CARDS ──────────────────────────── */
.card-distance {
  background: linear-gradient(160deg, #1a5c1f 0%, #2a7d32 50%, #1e6b25 100%);
  border-color: #4caf50;
}
.card-distance .road-stripe {
  position: absolute;
  top: 0; bottom: 0;
  width: 3px;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,0.12) 0, rgba(255,255,255,0.12) 6px,
    transparent 6px, transparent 12px
  );
}
.card-distance .road-stripe.left { left: 8px; }
.card-distance .road-stripe.right { right: 8px; }

.card-distance .dist-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
  z-index: 1;
}
.card-distance .dist-unit {
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  margin-top: 1px;
  z-index: 1;
  line-height: 1;
}
.card-distance .dist-unit-fr {
  font-size: 0.4rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.4);
  z-index: 1;
  line-height: 1;
}
.card-distance .mile-marker {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

/* 200 special treatment */
.card-distance.d200 {
  background: linear-gradient(160deg, #145018 0%, #1b6b22 40%, #228b2e 100%);
  border-color: #66bb6a;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5), inset 0 0 20px rgba(102,187,106,0.12);
}
.card-distance.d200 .dist-value {
  font-size: 2.1rem;
  color: #a5d6a7;
  text-shadow: 0 0 12px rgba(102,187,106,0.4);
}

/* ── HAZARD CARDS ────────────────────────────── */
.card-hazard {
  background: linear-gradient(160deg, #6b1a1a 0%, #a82020 50%, #7f1d1d 100%);
  border-color: #ef5350;
}
.card-hazard::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent, transparent 10px,
    rgba(0,0,0,0.07) 10px, rgba(0,0,0,0.07) 12px
  );
  pointer-events: none;
}
.card-hazard .hazard-shape {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Triangle warning sign */
.hazard-triangle {
  width: 0; height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 36px solid #ffcc02;
  position: relative;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
.hazard-triangle .tri-inner {
  position: absolute;
  top: 6px; left: -13px;
  width: 0; height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 24px solid #a82020;
}
.hazard-triangle .tri-symbol {
  position: absolute;
  top: 11px; left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #ffcc02;
  font-weight: 700;
  line-height: 1;
}

/* Octagon for Stop */
.hazard-octagon {
  width: 38px; height: 38px;
  background: #cc0000;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
.hazard-octagon span {
  font-family: 'Oswald', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
}

/* Circle for Speed Limit */
.hazard-speed-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid #cc0000;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
.hazard-speed-circle span {
  font-family: 'Oswald', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #222;
}

.card-hazard .hazard-label {
  font-size: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,200,180,0.8);
  margin-top: 5px;
  z-index: 1;
  line-height: 1.1;
}
.card-hazard .hazard-label-fr {
  font-size: 0.4rem;
  font-weight: 400;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255,200,180,0.5);
  z-index: 1;
  line-height: 1;
}

/* ── REMEDY CARDS ────────────────────────────── */
.card-remedy {
  background: linear-gradient(160deg, #0c3d8a 0%, #1565c0 50%, #0d47a1 100%);
  border-color: #42a5f5;
}
.card-remedy .remedy-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
.card-remedy .remedy-label {
  font-size: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(180,210,255,0.8);
  margin-top: 5px;
  z-index: 1;
  line-height: 1.1;
}
.card-remedy .remedy-label-fr {
  font-size: 0.4rem;
  font-weight: 400;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(180,210,255,0.5);
  z-index: 1;
  line-height: 1;
}

.remedy-roll {
  background: radial-gradient(circle, #43a047, #2e7d32);
  border: 2.5px solid #66bb6a;
}
.remedy-roll .arrow { font-size: 1.2rem; color: #fff; line-height: 1; }

.remedy-repairs {
  background: radial-gradient(circle, #546e7a, #37474f);
  border: 2.5px solid #78909c;
}
.remedy-repairs span { font-size: 1.05rem; color: #fff; }

.remedy-gasoline {
  background: radial-gradient(circle, #e65100, #bf360c);
  border: 2.5px solid #ff8a65;
}
.remedy-gasoline span { font-size: 1.05rem; color: #fff; }

.remedy-spare {
  background: radial-gradient(circle, #424242, #212121);
  border: 2.5px solid #757575;
}
.remedy-spare span { font-size: 1.05rem; color: #fff; }

.remedy-end-limit {
  background: radial-gradient(circle, #2e7d32, #1b5e20);
  border: 2.5px solid #66bb6a;
  position: relative;
}
.remedy-end-limit span {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.remedy-end-limit::after {
  content: '';
  position: absolute;
  width: 2.5px;
  height: 26px;
  background: #66bb6a;
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* ── SAFETY CARDS ────────────────────────────── */
.card-safety {
  background: linear-gradient(160deg, #5c4200 0%, #7d5a00 30%, #6d4c00 100%);
  border-color: #ffc107;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 12px rgba(255,193,7,0.15);
}
.card-safety .inner-border {
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255,193,7,0.2);
  border-radius: 7px;
  pointer-events: none;
}

.card-safety .safety-shield {
  width: 36px; height: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.safety-shield svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.safety-shield .shield-text {
  position: relative;
  z-index: 2;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  font-size: 0.5rem;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.1;
}

.card-safety .safety-label {
  font-size: 0.48rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffe082;
  margin-top: 3px;
  z-index: 1;
  line-height: 1.1;
}
.card-safety .safety-label-fr {
  font-size: 0.38rem;
  font-weight: 400;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255,224,130,0.5);
  z-index: 1;
  line-height: 1;
}

.card-safety .star-deco {
  position: absolute;
  font-size: 0.45rem;
  color: rgba(255,193,7,0.2);
}
.star-deco.s1 { top: 5px; right: 7px; }
.star-deco.s2 { bottom: 7px; left: 7px; }
.star-deco.s3 { top: 16px; left: 5px; }

/* ── Target Highlighting ─────────────────────── */
.opponent-tableau.valid-target {
  border-color: var(--hazard-accent) !important;
  box-shadow: 0 0 12px rgba(239,83,80,0.4);
  cursor: pointer;
  animation: targetPulse 1.2s ease infinite;
}
.opponent-tableau.valid-target:hover {
  box-shadow: 0 0 20px rgba(239,83,80,0.6);
  background: rgba(239,83,80,0.08);
}

@keyframes targetPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(239,83,80,0.3); }
  50% { box-shadow: 0 0 20px rgba(239,83,80,0.55); }
}

.opponent-tableau .target-hint {
  display: none;
  text-align: center;
  margin-top: 0.3rem;
  font-family: 'Oswald', sans-serif;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hazard-accent);
}
.opponent-tableau.valid-target .target-hint {
  display: block;
}

/* ── Hand Area ─────────────────────────────────────────── */
.hand-area {
  background: var(--bg-mid);
  border-top: 3px solid var(--road-line);
  padding: 0.5rem;
  flex-shrink: 0;
}

.hand-cards {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0.2rem 0;
}

.hand-card {
  cursor: pointer;
  flex-shrink: 0;
}
.hand-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
.hand-card.selected {
  transform: translateY(-10px);
  box-shadow: 0 8px 25px rgba(240,192,64,0.4);
  border-color: var(--road-line) !important;
}
.hand-card.playable {
  cursor: pointer;
}
.hand-card.not-playable {
  opacity: 0.5;
}
.hand-card.discard-mode {
  border-color: var(--red) !important;
  opacity: 0.7;
}
.hand-card.discard-mode:hover {
  opacity: 1;
}

/* Action buttons under hand */
.hand-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.hand-actions .btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

/* ── Side Panels (Chat / Events) ───────────────────────── */
.side-panel {
  position: fixed;
  right: 0;
  top: 44px;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--bg-mid);
  border-left: 2px solid #333;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.side-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 2px solid #333;
  font-family: 'Oswald', sans-serif;
  font-size: 0.9rem;
  background: rgba(240,192,64,0.08);
}
.panel-header-events { background: rgba(156,106,222,0.08); }
.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
}
.btn-close:hover { color: var(--text); }

.panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.panel-messages .msg {
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
}
.msg-event { color: var(--text-dim); border-left: 2px solid #555; }
.msg-event.coup-fourre { color: var(--safety-fg); border-left-color: var(--safety-accent); }
.msg-chat .msg-sender { font-weight: 700; color: var(--road-line); }

.panel-input {
  display: flex;
  padding: 0.5rem;
  gap: 0.3rem;
  border-top: 1px solid #333;
}
.panel-input input {
  flex: 1;
  background: var(--bg-dark);
  border: 1px solid #444;
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}
.panel-input input:focus { border-color: var(--road-line); }
.btn-send {
  background: var(--road-line);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0 0.7rem;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── Overlays ──────────────────────────────────────────── */
.target-overlay,
.coup-fourre-overlay,
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.hidden { display: none !important; }

.target-panel,
.coup-fourre-panel,
.gameover-panel {
  background: var(--bg-mid);
  border: 2px solid #444;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow);
}

.target-panel h3,
.gameover-panel h2 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 1rem;
}

.target-panel .btn {
  margin: 0.3rem;
  min-width: 120px;
}

.cf-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: var(--safety-accent);
  margin-bottom: 0.8rem;
}
.cf-message {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: 0.95rem;
}
.cf-buttons {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}
.cf-timer {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.gameover-scores {
  margin: 1rem 0;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.3rem;
  background: var(--bg-card);
  border-radius: var(--radius);
}
.score-row.winner {
  border: 2px solid var(--road-line);
  background: rgba(240,192,64,0.1);
}
.score-name {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
}
.score-detail {
  text-align: right;
  font-family: 'Oswald', sans-serif;
}
.score-miles { font-size: 0.8rem; color: var(--text-dim); }
.score-points { font-size: 1.2rem; color: var(--road-line); font-weight: 700; }

/* ── Mileage Bar ───────────────────────────────────────── */
.mile-bar-container {
  width: 100%;
  height: 6px;
  background: #333;
  border-radius: 3px;
  margin-top: 0.3rem;
  overflow: hidden;
}
.mile-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--distance-accent), var(--road-line));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Animations ────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.turn-pulse { animation: pulse 1.5s ease infinite; }

@keyframes cfFlash {
  0%, 100% { background: rgba(255,193,7,0.1); }
  50% { background: rgba(255,193,7,0.25); }
}
.coup-fourre-panel { animation: cfFlash 1s ease infinite; }

/* Toast notifications */
.toast {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-mid);
  border: 1px solid #555;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 300;
  animation: slideUp 0.3s ease;
  pointer-events: none;
}
.toast-error { border-color: var(--red); color: var(--hazard-fg); }

/* ── Animation Layer (flying cards) ────────────────────── */
.anim-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}
.anim-card {
  position: absolute;
  transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 151;
  pointer-events: none;
}
.anim-card.arrived {
  opacity: 0;
  transform: scale(0.6);
}

/* ── Distance Pile Chips ───────────────────────────────── */
.dist-pile {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.dist-chip {
  font-family: 'Oswald', sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(76,175,80,0.2);
  color: var(--distance-fg);
  border: 1px solid rgba(76,175,80,0.3);
  line-height: 1.3;
}
.dist-chip.d200 {
  background: rgba(102,187,106,0.25);
  color: #a5d6a7;
  border-color: rgba(102,187,106,0.4);
}

.my-dist-pile {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: center;
}
.my-dist-pile .dist-chip {
  font-size: 0.6rem;
  padding: 2px 5px;
}

/* ── Help Overlay ──────────────────────────────────────── */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  backdrop-filter: blur(4px);
}

.help-panel {
  background: var(--bg-mid);
  border: 2px solid #444;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 2px solid #333;
}
.help-header h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.help-content {
  overflow-y: auto;
  padding: 0.8rem 1rem;
}

.help-section {
  margin-bottom: 1rem;
}
.help-section:last-child { margin-bottom: 0; }

.help-section-title {
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
}
.distance-title { background: rgba(76,175,80,0.2); color: var(--distance-fg); }
.hazard-title { background: rgba(239,83,80,0.2); color: var(--hazard-fg); }
.remedy-title { background: rgba(66,165,245,0.2); color: var(--remedy-fg); }
.safety-title { background: rgba(255,193,7,0.2); color: var(--safety-fg); }
.cf-title-help { background: rgba(255,193,7,0.15); color: var(--safety-accent); }
.scoring-title { background: rgba(255,255,255,0.08); color: var(--text); }

.help-section p {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
}
.help-section p b {
  color: var(--text-bright);
}

/* ── Auto-Discard Banner ───────────────────────────────── */
.auto-discard-banner {
  text-align: center;
  padding: 0.3rem 0.5rem;
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--road-line);
  background: rgba(240,192,64,0.08);
  border-radius: var(--radius);
  margin-bottom: 0.3rem;
  animation: pulse 1.5s ease infinite;
}

/* ── Cumulative Score Badge (opponents) ────────────────── */
.opp-cumulative {
  font-family: 'Oswald', sans-serif;
  font-size: 0.6rem;
  color: var(--road-line);
  opacity: 0.7;
}

/* ── Round Progress Bar ────────────────────────────────── */
.round-progress {
  margin: 0.8rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.round-progress-label {
  display: flex;
  justify-content: space-between;
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}
.round-progress-bar {
  width: 100%;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.round-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.progress-p0 { background: var(--road-line); }
.progress-p1 { background: var(--remedy-accent); }
.progress-p2 { background: var(--hazard-accent); }
.progress-p3 { background: var(--safety-accent); }

.round-progress-tracks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progress-track {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.progress-track-name {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  width: 70px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.progress-track-bar {
  flex: 1;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}
.progress-track-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-track-score {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  color: var(--text-dim);
  width: 45px;
  text-align: right;
}

/* ── Score row with round + cumulative ─────────────────── */
.score-round-pts { font-size: 0.75rem; color: var(--text-dim); }
.score-cumulative { font-size: 1.1rem; color: var(--road-line); font-weight: 700; }

/* ── Mobile Layout ─────────────────────────────────────── */
/* ── Responsive: tablets / fold inner screen (~600-900px) ── */
@media (max-width: 900px) {
  /* Opponent tableaux: prevent dist-pile clipping on fold inner */
  .opponents-area {
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
  }
  .opponent-tableau {
    min-width: 160px;
    padding: 0.4rem 0.5rem;
  }
  .dist-pile {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .dist-pile::-webkit-scrollbar { display: none; }
  .opp-cumulative { font-size: 0.55rem; }
}

/* ── Responsive: phones ≤600px ─────────────────────────── */
@media (max-width: 600px) {
  .card { width: 58px; height: 84px; }
  .card .dist-value { font-size: 1.6rem; }
  .card .dist-unit { font-size: 0.4rem; }
  .card-small { width: 42px; height: 58px; }
  .hazard-triangle { border-left-width: 15px; border-right-width: 15px; border-bottom-width: 26px; }
  .hazard-triangle .tri-inner { top: 5px; left: -10px; border-left-width: 10px; border-right-width: 10px; border-bottom-width: 17px; }
  .hazard-triangle .tri-symbol { font-size: 0.6rem; top: 8px; }
  .hazard-octagon { width: 28px; height: 28px; }
  .hazard-octagon span { font-size: 0.42rem; }
  .hazard-speed-circle { width: 28px; height: 28px; border-width: 2.5px; }
  .hazard-speed-circle span { font-size: 0.8rem; }
  .hazard-label, .remedy-label { font-size: 0.42rem !important; margin-top: 3px !important; }
  .hazard-label-fr, .remedy-label-fr, .safety-label-fr { font-size: 0.35rem !important; }
  .dist-unit-fr { font-size: 0.3rem !important; }
  .remedy-icon { width: 28px !important; height: 28px !important; }
  .remedy-icon span { font-size: 0.85rem !important; }
  .remedy-roll .arrow { font-size: 0.95rem !important; }
  .remedy-end-limit span { font-size: 0.8rem !important; }
  .remedy-end-limit::after { height: 20px !important; width: 2px !important; }
  .safety-shield { width: 28px !important; height: 32px !important; }
  .shield-text { font-size: 0.38rem !important; }
  .safety-label { font-size: 0.4rem !important; }
  .corner-tl, .corner-br { font-size: 0.4rem !important; }

  .game-header {
    padding: 0.25rem 0.5rem;
    min-height: 38px;
    gap: 0.3rem;
  }
  .header-left { gap: 0.35rem; }
  .game-id-tag { font-size: 0.6rem; }
  .deck-info { font-size: 0.6rem; }
  .round-info { font-size: 0.6rem; }
  .turn-indicator { font-size: 0.75rem; }
  .btn-icon { padding: 0.2rem 0.35rem; font-size: 0.85rem; }

  .opponents-area {
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
  }
  .opponent-tableau {
    padding: 0.3rem 0.4rem;
    border-radius: 10px;
    min-width: 120px;
  }
  .opp-name { font-size: 0.72rem; }
  .opp-miles { font-size: 0.95rem; }
  .opp-status { gap: 0.2rem; }
  .status-badge { font-size: 0.55rem; padding: 0.1rem 0.3rem; }
  .mile-bar-container { height: 4px; }
  .dist-pile { gap: 1px; }
  .dist-chip { font-size: 0.45rem; padding: 0px 3px; }

  .center-area { padding: 0.15rem; }

  .my-tableau {
    padding: 0.3rem 0.5rem;
    gap: 0.5rem;
  }
  .my-miles-number { font-size: 1.7rem; }
  .my-miles-label { font-size: 0.5rem; }
  .safety-token { width: 26px; height: 26px; font-size: 0.6rem; }

  .hand-area {
    padding: 0.35rem 0.25rem;
    border-top-width: 2px;
  }
  .hand-cards {
    gap: 0.2rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  .hand-card {
    scroll-snap-align: center;
    flex-shrink: 0;
  }
  .hand-actions { gap: 0.3rem; margin-top: 0.3rem; }
  .hand-actions .btn { font-size: 0.72rem; padding: 0.35rem 0.6rem; }

  .side-panel { width: 260px; top: 38px; }

  .my-dist-pile .dist-chip { font-size: 0.5rem; padding: 1px 4px; }

  .target-hint { font-size: 0.55rem !important; }
  .auto-discard-banner { font-size: 0.65rem; padding: 0.2rem 0.4rem; }

  .gameover-panel, .help-panel { max-width: 95vw; }
  .help-content { font-size: 0.78rem; }
}

/* ── Narrow phones / Fold cover screen (~320-420px) ────── */
@media (max-width: 420px) {
  .card { width: 46px; height: 68px; }
  .card .dist-value { font-size: 1.2rem; }
  .card .dist-unit { font-size: 0.35rem; }
  .card .dist-unit-fr { display: none !important; }
  .card-small { width: 34px; height: 48px; }

  /* French labels hidden — too small */
  .hazard-label-fr, .remedy-label-fr, .safety-label-fr { display: none !important; }

  /* Shrink card internals */
  .hazard-triangle { border-left-width: 12px; border-right-width: 12px; border-bottom-width: 21px; }
  .hazard-triangle .tri-inner { top: 4px; left: -8px; border-left-width: 8px; border-right-width: 8px; border-bottom-width: 13px; }
  .hazard-triangle .tri-symbol { font-size: 0.5rem; top: 6px; }
  .hazard-octagon { width: 24px; height: 24px; }
  .hazard-octagon span { font-size: 0.38rem; }
  .hazard-speed-circle { width: 24px; height: 24px; border-width: 2px; }
  .hazard-speed-circle span { font-size: 0.7rem; }
  .hazard-label, .remedy-label { font-size: 0.38rem !important; }
  .remedy-icon { width: 24px !important; height: 24px !important; }
  .remedy-icon span { font-size: 0.75rem !important; }
  .remedy-roll .arrow { font-size: 0.85rem !important; }
  .remedy-end-limit span { font-size: 0.65rem !important; }
  .remedy-end-limit::after { height: 16px !important; width: 2px !important; }
  .safety-shield { width: 24px !important; height: 28px !important; }
  .shield-text { font-size: 0.33rem !important; }
  .safety-label { font-size: 0.36rem !important; }
  .corner-tl, .corner-br { display: none !important; }

  /* Hand: allow cards to shrink so 7 fit without scrolling */
  .hand-cards {
    justify-content: space-evenly;
    gap: 0.12rem;
    overflow-x: visible;
  }
  .hand-card {
    flex-shrink: 1;
    min-width: 40px;
  }
  .hand-area {
    padding: 0.25rem 0.15rem;
  }
  .hand-actions { gap: 0.2rem; }
  .hand-actions .btn { font-size: 0.65rem; padding: 0.3rem 0.5rem; }

  /* Game header: ultra-compact */
  .game-header {
    padding: 0.2rem 0.4rem;
    min-height: 34px;
  }
  .header-left { gap: 0.25rem; }
  .game-id-tag { font-size: 0.55rem; }
  .deck-info { font-size: 0.55rem; }
  .round-info { font-size: 0.55rem; }
  .turn-indicator { font-size: 0.68rem; }
  .btn-icon { padding: 0.15rem 0.3rem; font-size: 0.8rem; }

  /* Opponents: stack vertically on very narrow screens */
  .opponents-area {
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.2rem 0.3rem;
    max-height: 130px;
    overflow-y: auto;
  }
  .opponent-tableau {
    min-width: unset;
    padding: 0.25rem 0.35rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
  }
  .opp-header {
    margin-bottom: 0;
    min-width: 0;
    flex: 1;
  }
  .opp-name { font-size: 0.65rem; }
  .opp-miles { font-size: 0.85rem; }
  .opp-cumulative { font-size: 0.5rem; }
  .mile-bar-container { display: none; }
  .opp-status { gap: 0.15rem; }
  .status-badge { font-size: 0.5rem; padding: 0.08rem 0.25rem; }
  .dist-pile {
    gap: 1px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .dist-chip { font-size: 0.42rem; padding: 0px 2px; }
  .target-hint { font-size: 0.5rem !important; margin-top: 0.15rem; }

  /* My tableau: compact */
  .my-tableau {
    padding: 0.2rem 0.4rem;
    gap: 0.4rem;
  }
  .my-miles-number { font-size: 1.3rem; }
  .my-miles-label { font-size: 0.45rem; }
  .safety-token { width: 22px; height: 22px; font-size: 0.5rem; }
  .my-dist-pile .dist-chip { font-size: 0.45rem; padding: 1px 3px; }
  .opp-cumulative { font-size: 0.48rem; }

  .center-area { padding: 0.1rem; }
  .pile-label { font-size: 0.5rem; }

  .auto-discard-banner { font-size: 0.6rem; padding: 0.15rem 0.3rem; }

  .side-panel { width: 85vw; top: 34px; }

  .logo-title { font-size: 2.6rem; }
  .logo-bornes { font-size: 3.2rem; }
}

/* Tall phones — keep hand visible */
@media (max-height: 700px) {
  .opponents-area { max-height: 100px; overflow-y: auto; }
  .center-area { padding: 0.1rem; }
  .my-tableau { padding: 0.2rem 0.5rem; }
  .my-miles-number { font-size: 1.5rem; }
}
