/* ═══════════════════════════════════════════════════════════════════
   DUORDLE — Main Stylesheet
   Dark mode, Mobile-first, Animations Wordle-style
   ═══════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ───────────────────────────────────────────────── */
:root {
  /* Palette Wordle dark */
  --color-bg:        #121213;
  --color-surface:   #1a1a1b;
  --color-border:    #3a3a3c;
  --color-border-active: #565758;
  --color-text:      #ffffff;
  --color-text-muted:#818384;
  --color-correct:   #6aaa64;
  --color-present:   #c9b458;
  --color-absent:    #3a3a3c;
  --color-key-bg:    #818384;
  --color-key-text:  #ffffff;

  /* UI */
  --color-accent:    #6aaa64;
  --color-accent-hover: #5a9a54;
  --color-danger:    #e74c3c;
  --color-warning:   #c9b458;

  /* Spacing */
  --tile-size:       clamp(48px, 11vw, 62px);
  --tile-gap:        5px;
  --key-height:      58px;
  --header-height:   50px;

  /* Typography */
  --font-display:    'Space Mono', monospace;
  --font-body:       'DM Sans', sans-serif;

  /* Transitions */
  --flip-duration:   500ms;
  --shake-duration:  600ms;
  --bounce-duration: 100ms;
}

/* ─── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.hidden { display: none !important; }

/* ─── Header ──────────────────────────────────────────────────────── */
.site-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 500px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0;
}
.logo-d  { color: var(--color-correct); }
.logo-uo { color: var(--color-text); }
.logo-r  { color: var(--color-present); }
.logo-d2 { color: var(--color-correct); }
.logo-le { color: var(--color-text); }

.header-nav { display: flex; gap: 4px; }
.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--color-text);
  transition: background 0.2s;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { background: var(--color-surface); }

.btn-icon-help {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

/* ─── Main / Screens ─────────────────────────────────────────────── */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  padding: 20px 16px;
  animation: fadeIn 0.2s ease;
}
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─── Home Screen ────────────────────────────────────────────────── */
.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 420px;
  width: 100%;
  padding-top: 24px;
}
.hero-tiles {
  display: flex;
  gap: clamp(3px, 1vw, 6px);
  margin-bottom: 4px;
}
.hero-tiles .tile {
  width: clamp(30px, 9vw, 42px);
  height: clamp(30px, 9vw, 42px);
  font-size: clamp(0.95rem, 3.1vw, 1.2rem);
  animation: heroReveal 0.4s ease both;
}
.hero-tiles .tile:nth-child(1) { animation-delay: 0.05s; }
.hero-tiles .tile:nth-child(2) { animation-delay: 0.1s; }
.hero-tiles .tile:nth-child(3) { animation-delay: 0.15s; }
.hero-tiles .tile:nth-child(4) { animation-delay: 0.2s; }
.hero-tiles .tile:nth-child(5) { animation-delay: 0.25s; }
.hero-tiles .tile:nth-child(6) { animation-delay: 0.3s; }
.hero-tiles .tile:nth-child(7) { animation-delay: 0.35s; }
@keyframes heroReveal {
  from { opacity: 0; transform: scale(0.6) rotate(-5deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
.home-tagline {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  text-align: center;
  letter-spacing: 0.01em;
}
.home-quote {
  width: 100%;
  background: rgba(26,26,27,0.78);
  border: 1px solid rgba(106,170,100,0.18);
  border-radius: 14px;
  padding: 12px 14px 10px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.16);
  animation: quoteRise 260ms ease both;
}
.home-quote-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
  font-style: italic;
  text-wrap: pretty;
}
.home-quote-author {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
}

.home-quote-link {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.home-quote-link:hover {
  color: var(--color-text);
  text-decoration-color: var(--color-accent);
}

@keyframes quoteRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.home-pseudo-wrap { width: 100%; }
.input-pseudo {
  width: 100%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
  letter-spacing: 0.02em;
}
.input-pseudo:focus { border-color: var(--color-accent); }
.input-pseudo::placeholder { color: var(--color-text-muted); }

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.home-mode-picker {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.home-mode-btn {
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  color: var(--color-text-muted);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  text-align: left;
}

.home-mode-btn:hover {
  border-color: var(--color-border-active);
  color: var(--color-text);
}

.home-mode-btn.active {
  border-color: var(--color-accent);
  background: rgba(106,170,100,0.12);
  color: var(--color-text);
}

.home-mode-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.home-mode-desc {
  font-size: 0.78rem;
  line-height: 1.25;
}

.home-mode-note {
  width: 100%;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  letter-spacing: 0.02em;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.97); }
.btn--primary  { background: var(--color-surface); color: var(--color-text); border: 2px solid var(--color-border); }
.btn--primary:hover  { background: #2a2a2b; border-color: var(--color-border-active); }
.btn--accent   { background: var(--color-correct); color: #fff; }
.btn--accent:hover   { background: var(--color-accent-hover); box-shadow: 0 4px 16px rgba(106,170,100,0.3); }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border: 2px solid var(--color-border); }
.btn--secondary:hover { background: #232324; }
.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { color: var(--color-text); }
.btn--large { padding: 16px 24px; font-size: 1.05rem; }
.btn--full  { width: 100%; }

/* ─── Modal Card ─────────────────────────────────────────────────── */
.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  position: relative;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}
.btn-back {
  position: absolute;
  top: 16px; left: 16px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-back svg { width: 20px; height: 20px; }
.btn-back:hover { background: var(--color-border); color: var(--color-text); }
.modal-title { padding-left: 36px; }

/* ─── Form ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.input-code {
  width: 100%;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  padding: 12px 16px;
  outline: none;
  text-align: center;
  letter-spacing: 0.3em;
  transition: border-color 0.2s;
}
.input-code:focus { border-color: var(--color-accent); }

/* ─── Mode Tabs ──────────────────────────────────────────────────── */
.mode-tabs { display: flex; gap: 8px; }
.mode-tab {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-body);
  transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.mode-tab.active {
  border-color: var(--color-accent);
  background: rgba(106,170,100,0.1);
  color: var(--color-text);
}
.mode-icon { font-size: 1.4rem; }

/* ─── Toggle ────────────────────────────────────────────────────── */
.options-panel { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 10px;
  gap: 12px;
}
.toggle-label { display: flex; flex-direction: column; gap: 2px; }
.toggle-label strong { font-size: 0.9rem; }
.toggle-label small { font-size: 0.78rem; color: var(--color-text-muted); }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--color-border);
  border-radius: 24px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--color-accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── Join Error ─────────────────────────────────────────────────── */
.join-error {
  color: var(--color-danger);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 12px;
}

/* ─── Lobby ──────────────────────────────────────────────────────── */
.lobby-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 400px;
  width: 100%;
}
.lobby-header { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lobby-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.room-code-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 16px;
}
.room-code-label { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.room-code { font-family: var(--font-display); font-size: clamp(1.1rem, 4.5vw, 1.5rem); font-weight: 700; letter-spacing: clamp(0.08em, 0.5vw, 0.2em); color: var(--color-accent); }
.btn-copy { color: var(--color-text-muted); }
.btn-copy:hover { color: var(--color-text); }
.players-list { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.player-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}
.player-name { font-weight: 600; flex: 1; }
.player-badge { font-size: 0.75rem; color: var(--color-text-muted); }
.player-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}
.lobby-hint { color: var(--color-text-muted); font-size: 0.9rem; text-align: center; }

/* ─── Game Timer ─────────────────────────────────────────────────── */
.game-timer {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  padding: 8px 0 0;
}

/* ─── Opponents Grid (miniatures) ────────────────────────────────── */
.opponents-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
  width: 100%;
  max-width: 500px;
}
.opponent-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 90px;
}
.opponent-name { font-size: 0.7rem; font-weight: 600; color: var(--color-text-muted); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 80px; }
.mini-grid { display: flex; flex-direction: column; gap: 2px; }
.mini-row { display: flex; gap: 2px; }
.mini-tile {
  width: 10px; height: 10px; border-radius: 1px;
  background: var(--color-border);
}
.mini-tile--G { background: var(--color-correct); }
.mini-tile--Y { background: var(--color-present); }
.mini-tile--B { background: var(--color-absent); }

/* ─── Game Grid ──────────────────────────────────────────────────── */
.main-game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.game-grid {
  display: flex;
  flex-direction: column;
  gap: var(--tile-gap);
}
.grid-row {
  display: flex;
  gap: var(--tile-gap);
}

/* ─── Tiles ──────────────────────────────────────────────────────── */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 700;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  transition: border-color 0.1s;
  user-select: none;
  text-transform: uppercase;
  /* 3D flip support */
  perspective: 250px;
  transform-style: preserve-3d;
}

/* État: lettre tapée, pas encore soumise */
.tile--filled {
  border-color: var(--color-border-active);
  animation: tilePop var(--bounce-duration) ease;
}
@keyframes tilePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Animation flip révélation */
.tile--flip {
  animation: tileFlip var(--flip-duration) ease forwards;
}
@keyframes tileFlip {
  0%   { transform: rotateX(0deg); }
  49%  { transform: rotateX(-90deg); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}

/* États post-flip */
.tile--correct { background: var(--color-correct); border-color: var(--color-correct); color: #fff; }
.tile--present { background: var(--color-present); border-color: var(--color-present); color: #fff; }
.tile--absent  { background: var(--color-absent);  border-color: var(--color-absent);  color: #fff; }
.tile--empty   { border-color: var(--color-border); }

/* Animation bounce victoire */
.tile--bounce {
  animation: tileBounce 500ms ease forwards;
}
@keyframes tileBounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-20px); }
  60%  { transform: translateY(-12px); }
  80%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* Secousse rangée — mot invalide */
.grid-row--shake {
  animation: rowShake var(--shake-duration) ease;
}
@keyframes rowShake {
  0%,100% { transform: translateX(0); }
  10%,50%,90% { transform: translateX(-4px); }
  30%,70%     { transform: translateX(4px); }
}

/* ─── Notification in-game ───────────────────────────────────────── */
.game-notification {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  animation: notifAppear 0.15s ease;
}
@keyframes notifAppear {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* ─── Keyboard ───────────────────────────────────────────────────── */
.keyboard {
  width: 100%;
  max-width: 500px;
  padding: 8px 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: clamp(3px, 1.2vw, 6px);
}
.key {
  height: var(--key-height);
  min-width: clamp(28px, 8vw, 43px);
  padding: 0;
  flex: 1;
  max-width: 43px;
  border-radius: 6px;
  background: var(--color-key-bg);
  color: var(--color-key-text);
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.05s;
  user-select: none;
}
.key:active { transform: scale(0.93); }
.key--action { min-width: clamp(42px, 12vw, 65px); max-width: 65px; font-size: 1rem; }
.key--correct { background: var(--color-correct); }
.key--present { background: var(--color-present); }
.key--absent  { background: var(--color-absent); color: #555; }

/* ─── Game Over ──────────────────────────────────────────────────── */
.game-over-card { text-align: center; }
.game-over-result {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.game-over-result--win  { color: var(--color-correct); }
.game-over-result--lose { color: var(--color-text-muted); }
.game-over-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
}
.word-label { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.word-reveal { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: 0.1em; color: var(--color-accent); }
.game-over-scoreboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  width: 100%;
}
.scoreboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--color-bg);
  border-radius: 8px;
}
.scoreboard-rank { font-family: var(--font-display); font-size: 0.9rem; font-weight: 700; width: 24px; color: var(--color-text-muted); }
.scoreboard-rank--1 { color: #ffd700; }
.scoreboard-rank--2 { color: #c0c0c0; }
.scoreboard-rank--3 { color: #cd7f32; }
.scoreboard-name { flex: 1; font-weight: 600; }
.scoreboard-guesses { font-size: 0.85rem; color: var(--color-text-muted); }
.game-over-actions { display: flex; flex-direction: column; gap: 8px; }

/* ─── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px 20px 12px 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80dvh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s ease;
}
.modal-box--large { max-height: 90dvh; }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--color-border);
  color: var(--color-text);
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--color-border-active); }
.modal-box h2 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 16px; }
.modal-box h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin: 16px 0 6px; }
.modal-box p { font-size: 0.9rem; line-height: 1.6; color: var(--color-text-muted); margin-bottom: 8px; }
.modal-box ul { padding-left: 18px; }
.modal-box li { font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 4px; }
.modal-box code { font-family: var(--font-display); font-size: 0.8rem; background: var(--color-bg); padding: 2px 6px; border-radius: 4px; }
.modal-divider { border: none; border-top: 1px solid var(--color-border); margin: 16px 0; }

/* Help examples */
.help-examples { display: flex; flex-direction: column; gap: 16px; margin: 12px 0; }
.help-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.help-row .tile { width: 40px; height: 40px; font-size: 1rem; }
.help-row p { font-size: 0.85rem; color: var(--color-text-muted); flex: 1; min-width: 160px; }
.color-correct { color: var(--color-correct); font-weight: 700; }
.color-present { color: var(--color-present); font-weight: 700; }
.color-absent  { color: var(--color-text-muted); font-weight: 700; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; background: var(--color-bg); border-radius: 8px; }
.stat-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--color-text-muted); text-align: center; }

/* ─── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  animation: toastIn 0.2s ease, toastOut 0.2s ease 2s forwards;
  white-space: normal;
  max-width: calc(100vw - 24px);
  text-align: center;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ─── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 16px;
}
.footer-inner {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.footer-link { font-size: 0.8rem; color: var(--color-text-muted); }
.footer-link:hover { color: var(--color-text); }
.footer-copy { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; }

@media (max-width: 420px) {
  .screen {
    padding: 16px 10px;
  }

  .header-inner {
    padding: 0 10px;
  }

  .modal-card,
  .modal-box {
    padding: 18px 14px;
  }

  .btn--large {
    font-size: 0.98rem;
    padding: 14px 16px;
  }

  .help-row .tile {
    width: 34px;
    height: 34px;
  }
}

/* ─── Responsive tablet+ ──────────────────────────────────────────── */
@media (min-width: 600px) {
  .opponents-grid {
    flex-wrap: nowrap;
  }
  .opponent-card { min-width: 110px; }
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 16px; }
}

@media (min-width: 900px) {
  #screen-game {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    align-items: start;
    justify-items: center;
  }
  .game-timer {
    grid-column: 2;
    grid-row: 1;
  }
  .opponents-grid {
    grid-column: 1;
    grid-row: 1 / 3;
    flex-direction: column;
    flex-wrap: wrap;
    max-height: 480px;
  }
  .main-game-area {
    grid-column: 2;
    grid-row: 2;
  }
  .keyboard {
    grid-column: 1 / 4;
    grid-row: 3;
  }
}
