:root {
  --bg:           #0f0f23;
  --surface:      #0d1520;
  --card:         #111e2e;
  --card-hi:      #182638;
  --ink:          #dde5f5;
  --ink-soft:     #aab8d4;
  --muted:        #6b7ea0;
  --line:         #1e2d40;
  --accent:       #7c3aed;
  --accent-dark:  #6d28d9;
  --accent-ink:   #ffffff;
  --cta:          #d946ef;
  --cta-dark:     #c026d3;

  --ok:           #4ade80;
  --ok-bg:        rgba(74,222,128,.10);
  --ok-line:      rgba(74,222,128,.30);
  --warn:         #fbbf24;
  --warn-bg:      rgba(251,191,36,.10);
  --warn-line:    rgba(251,191,36,.30);
  --bad:          #f87171;
  --bad-bg:       rgba(248,113,113,.10);
  --bad-line:     rgba(248,113,113,.30);

  --cell-bg:      #162035;
  --cell-line:    #2a3d5c;
  --correct-bg:   #1b5e3a;
  --correct-line: #2d8c57;
  --present-bg:   #7a5500;
  --present-line: #b07d00;
  --absent-bg:    #1e2b3f;
  --absent-line:  #2e3f5a;
}

*, *::before, *::after { box-sizing: border-box; }

/* ─── CRT SCANLINES ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.04) 3px,
    rgba(0, 0, 0, 0.04) 4px
  );
}

@media (prefers-reduced-motion: no-preference) {
  body::before { animation: none; }
}

body {
  margin: 0;
  font-family: 'Chakra Petch', "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 160% 60% at 50% -5%, #0b2244 0%, transparent 68%),
    radial-gradient(ellipse 70% 45% at 90% 100%, rgba(124,58,237,.06) 0%, transparent 60%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: grid;
  gap: 22px;
}

/* ─── TOPBAR ─── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
}

.logo-icon { flex-shrink: 0; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  border-radius: 7px;
  width: auto;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lang-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}
.lang-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.mute-btn {
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.support-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar h1 {
  margin: 0;
  font-family: 'Russo One', sans-serif;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #ddd6fe 0%, #a78bfa 40%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

/* ─── FLASH ─── */
.flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid;
  white-space: nowrap;
  box-shadow: 0 6px 28px rgba(0,0,0,.55);
}

.flash.ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.flash.bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad); }
.flash:not(.hidden) { animation: flash-in 0.2s ease-out; }
.hidden     { display: none !important; }

/* ─── CARD ─── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 28px;
}

@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card.screen-entering {
  animation: screen-fade-in 0.22s ease-out;
}

/* ─── HEADINGS ─── */
h2 {
  margin: 0 0 16px;
  font-family: 'Russo One', sans-serif;
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #ddd6fe 0%, #a78bfa 40%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
h3 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

/* ─── FORM ELEMENTS ─── */
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }

label span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input, select {
  font: inherit;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7ea0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.22);
}

/* ─── BUTTONS ─── */
button {
  font: inherit;
  border: 0;
  border-radius: 9px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  /* inside a .stack grid, buttons must fill their cell */
  width: 100%;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 4px 20px rgba(124,58,237,.45);
  transform: translateY(-1px);
}

button:focus-visible,
.kb-key:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button:active:not(:disabled) { transform: scale(0.97) translateY(0); }

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.secondary {
  background: var(--card-hi);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  box-shadow: none;
  /* secondary buttons (Quitter, etc.) keep natural inline width */
  width: auto;
}

button.secondary:hover:not(:disabled) {
  background: var(--surface);
  box-shadow: none;
}

button.btn-cta {
  background: var(--cta);
}

button.btn-cta:hover:not(:disabled) {
  background: var(--cta-dark);
  box-shadow: 0 4px 20px rgba(217,70,239,.45);
}

/* Start-match button fills full width in lobby */
#start-match-btn {
  width: 100%;
  margin-top: 8px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ─── HOW TO PLAY ─── */
.how-to-play {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.how-to-play > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  user-select: none;
}

.how-to-play > summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s;
  color: var(--accent);
}

.how-to-play[open] > summary::before { transform: rotate(90deg); }

.rules-body {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.rules-body p { margin: 0; }

.rules-colors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.rules-colors li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rc {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
  border: 2px solid;
}

.rc.correct { background: var(--correct-bg); border-color: var(--correct-line); color: #fff; }
.rc.present { background: var(--present-bg); border-color: var(--present-line); color: #fff; }
.rc.absent  { background: var(--absent-bg);  border-color: var(--absent-line);  color: var(--muted); }

.rules-score-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  align-items: center;
}

.rs-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  justify-self: start;
  min-width: 42px;
  text-align: center;
}

/* ─── HOME DEMO TILES ─── */
.home-demo-tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 0 22px;
}

.demo-tile {
  width: 36px;
  height: 40px;
  border-radius: 7px;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.demo-tile.correct { background: var(--correct-bg); border-color: var(--correct-line); }
.demo-tile.present { background: var(--present-bg); border-color: var(--present-line); }
.demo-tile.absent  { background: var(--absent-bg);  border-color: var(--absent-line);  color: var(--muted); }

@keyframes demo-tile-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.demo-tile-entering {
  animation: demo-tile-fade-up 0.35s ease-out backwards;
}

/* ─── HOME FOOTER ─── */
.home-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-social-link {
  color: var(--muted);
  opacity: 0.45;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}

.footer-social-link:hover { opacity: 0.8; }

.app-version {
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  opacity: 0.45;
  letter-spacing: 0.05em;
}

/* ─── HOME TABS ─── */
.home-tabs { margin-top: 16px; }

.home-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  gap: 4px;
}

.home-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 0;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  width: auto;
}

.home-tab:hover { color: var(--ink); }

.home-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.home-tab svg { flex-shrink: 0; }

.home-tab-panel.hidden { display: none; }


/* ─── HOME SCREEN ─── */
.home-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.home-cols > div {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-cols > div h2 { margin: 0; }

/* vertical separator between the two panels */
.home-cols > div:first-child {
  padding-right: 28px;
  border-right: 1px solid var(--line);
}

/* ─── LOBBY ─── */
.lobby-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.lobby-head h2 { margin: 0; }

.room-code-copy {
  cursor: pointer;
  border-bottom: 1px dashed var(--accent);
  transition: color 0.15s, border-color 0.15s;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
}
.room-code-copy:hover { color: var(--accent); }

.list-block { margin: 4px 0 16px; }

.player-list, .score-list, .progress-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.player-list li, .score-list li, .progress-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.score-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.score-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-item.is-leader .score-bar-fill { background: var(--cta); }

.progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 20px;
  flex-shrink: 0;
}

.score-name, .progress-name {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-item.is-me .score-name,
.progress-item.is-me .progress-name { color: var(--accent); }

.score-pts {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.score-item.is-me .score-pts { color: var(--accent); }

.progress-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.badge-found {
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  color: var(--ok);
}

.badge-done {
  background: var(--bad-bg);
  border: 1px solid var(--bad-line);
  color: var(--bad);
}

.badge-tries {
  background: var(--card-hi);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* ─── GAME SCREEN ─── */
#screen-game {
  display: flex;
  flex-direction: column;
  gap: 13px;
  position: relative; /* ancrage pour l'input caché */
}

/* Input caché : capture le clavier physique sur mobile (inputmode=none empêche le clavier natif) */
#game-input-capture {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  padding: 0; border: 0; margin: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.game-title-block { display: grid; gap: 2px; }

.game-round-badge {
  font-family: 'Russo One', sans-serif;
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.round-number { color: var(--cta); }

.game-subtitle-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.game-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.meta-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}

/* ─── CHAT ─── */

/* Délimitation du chat dans le lobby : card distincte */
#lobby-chat-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 2px solid rgba(124, 58, 237, 0.30);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 0;
}

.chat-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-messages {
  list-style: none;
  padding: 6px 6px;
  margin: 0;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.chat-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 10px 0;
  font-style: italic;
  align-self: center;
}

/* Bulle de message */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  gap: 2px;
  animation: chat-slide-in 0.16s ease-out;
}

@keyframes chat-slide-in {
  from { opacity: 0; transform: translateY(5px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.chat-msg-other { align-self: flex-start; align-items: flex-start; }
.chat-msg-own   { align-self: flex-end;   align-items: flex-end; text-align: right; }

.chat-nickname {
  color: var(--cta);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 6px;
}

.chat-bubble {
  padding: 7px 11px;
  font-size: 0.8rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg-other .chat-bubble {
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: 4px 12px 12px 12px;
  color: var(--ink);
}

.chat-msg-own .chat-bubble {
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.38);
  border-radius: 12px 4px 12px 12px;
  color: var(--ink);
}

.chat-time {
  font-size: 0.62rem;
  color: var(--muted);
  padding: 0 6px;
}

/* Input + bouton */
.chat-input-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-input-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.chat-input-wrap input {
  width: 100%;
  font-size: 0.82rem;
  padding: 7px 36px 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.chat-input-wrap input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
  box-shadow: none;
}

.chat-char-counter {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.62rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s;
  line-height: 1;
}

.chat-char-counter.near-limit { color: var(--warn); }
.chat-char-counter.at-limit   { color: var(--bad); }

.chat-send-btn {
  width: auto;
  flex-shrink: 0;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.08);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(124, 58, 237, 0.6);
  color: #c4b5fd;
  box-shadow: none;
  transform: none;
}

/* ─── ALL BOARDS (split-screen) ─── */
.all-boards {
  display: grid;
  gap: 12px;
  --cell-size: 36px;
}

.player-board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.player-board-col.is-me-col {
  border-color: rgba(124,58,237,.5);
  box-shadow: 0 0 0 1px rgba(124,58,237,.18), 0 0 28px rgba(124,58,237,.09), inset 0 0 30px rgba(124,58,237,.05);
}

.player-board-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-board-name.is-me {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}

/* ─── BOARD ─── */
.board {
  display: grid;
  gap: 8px;
}

.board-row {
  display: grid;
  gap: 8px;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 2px solid var(--cell-line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: calc(var(--cell-size) * 0.42);
  text-transform: uppercase;
  background: var(--cell-bg);
  color: var(--ink);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  user-select: none;
}

.cell.correct {
  background: var(--correct-bg);
  border-color: var(--correct-line);
  color: #fff;
  box-shadow: 0 0 12px rgba(74,222,128,.35), inset 0 0 8px rgba(74,222,128,.08);
}

.cell.present {
  background: var(--present-bg);
  border-color: var(--present-line);
  color: #fff;
  box-shadow: 0 0 12px rgba(251,191,36,.3), inset 0 0 8px rgba(251,191,36,.07);
}

.cell.absent {
  background: var(--absent-bg);
  border-color: var(--absent-line);
  color: var(--muted);
}

/* Opponent cells: color only, no letter */
.cell.opp { font-size: 0; border-radius: 5px; }

/* ─── MOBILE SPLIT LAYOUT (2+ joueurs) ─── */
.opp-boards-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Reveal animation on newly submitted row */
@keyframes pop-in {
  0%   { transform: scale(0.6);  opacity: 0.2; }
  55%  { transform: scale(1.12); opacity: 1;   }
  78%  { transform: scale(0.96);              }
  100% { transform: scale(1);                 }
}

@keyframes flash-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0)     scale(1);    }
}

.board-row.reveal .cell                { animation: pop-in 0.22s ease-out both; }
.board-row.reveal .cell:nth-child(2)   { animation-delay: 50ms; }
.board-row.reveal .cell:nth-child(3)   { animation-delay: 100ms; }
.board-row.reveal .cell:nth-child(4)   { animation-delay: 150ms; }
.board-row.reveal .cell:nth-child(5)   { animation-delay: 200ms; }
.board-row.reveal .cell:nth-child(6)   { animation-delay: 250ms; }

@media (prefers-reduced-motion: reduce) {
  .board-row.reveal .cell              { animation: none; }
  .flash:not(.hidden)                  { animation: none; }
  button, .cell, .guess-tile, .kb-key  { transition: none; }
  .kb-key:active                       { transform: none; }
  .round-overlay-inner                 { animation: none; }
  .demo-tile-entering                  { animation: none; opacity: 1; transform: none; }
  .card.screen-entering                { animation: none; }
  .guess-tiles.shake                   { animation: none; }
  .guess-tile.pop                      { animation: none; }
}

/* ─── GUESS TILES ─── */
@keyframes tile-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.guess-tile.pop {
  animation: tile-pop 0.12s ease-out;
}

@keyframes guess-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-7px); }
  30%      { transform: translateX( 7px); }
  45%      { transform: translateX(-5px); }
  60%      { transform: translateX( 5px); }
  75%      { transform: translateX(-3px); }
  90%      { transform: translateX( 2px); }
}

.guess-tiles.shake {
  animation: guess-shake 0.38s ease-in-out;
}

.guess-tiles {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.guess-tile {
  width: 46px;
  height: 52px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--cell-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s, color 0.12s;
  user-select: none;
}

.guess-tile.has-letter {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 14px rgba(124,58,237,.32);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 680px) {
  /* Shell & cards */
  .app-shell  { padding: 12px 12px 32px; gap: 14px; }
  .card       { padding: 16px; }

  /* Topbar */
  .topbar        { flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
  .topbar-brand  { flex: 1 1 100%; }
  .topbar h1     { font-size: 1.55rem; }
  .topbar-tagline { display: none; }

  /* Flash — évite le débordement hors écran */
  .flash {
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: center;
    font-size: 0.82rem;
    padding: 8px 16px;
  }

  /* Home — séparateur vertical → horizontal */
  .home-cols { grid-template-columns: 1fr; gap: 20px; }
  .home-cols > div:first-child {
    padding-right: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 20px;
  }

  /* Game meta */
  .game-meta   { grid-template-columns: 1fr; gap: 10px; }
  .meta-block  { padding: 10px 12px; }
  #game-chat-block .chat-messages { max-height: 120px; }

  /* Boards : layout split 2fr/1fr sur mobile avec 2+ joueurs */
  .all-boards {
    --cell-size: 23px;
    gap: 8px;
  }
  .all-boards.mobile-split {
    grid-template-columns: 2fr 1fr;
  }
  .player-board-col { padding: 9px 6px 8px; gap: 6px; }

  /* Strip adversaires : boards compacts empilés */
  .opp-boards-strip .player-board-col {
    padding: 5px 4px;
    gap: 4px;
    border-radius: 8px;
  }
  .opp-boards-strip .player-board-name {
    font-size: 0.58rem;
    padding: 2px 7px;
    max-width: 90%;
  }

  /* Guess tiles */
  .guess-tiles { gap: 6px; }
  .guess-tile  { width: 38px; height: 44px; font-size: 1.15rem; }

  /* Keyboard */
  .keyboard { gap: 8px; }
  #screen-game { gap: 10px; }
  .kb-row   { gap: 6px; }
  .kb-key   { height: 44px; min-width: 28px; padding: 0 7px; font-size: 0.73rem; }
}

/* ─── KEYBOARD ─── */
.keyboard {
  display: flex; flex-direction: column; gap: 10px;
  align-items: center;
  width: 100%;
}
.kb-row { display: flex; gap: 7px; justify-content: center; }
.kb-key {
  height: 52px; min-width: 36px; padding: 0 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem; font-weight: 700; border-radius: 8px;
  background: var(--card-hi); color: var(--ink-soft);
  border: 1px solid var(--line); cursor: pointer; width: auto;
  transition: background 0.13s, color 0.13s, opacity 0.13s;
  user-select: none;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.kb-key:hover:not([data-state="absent"]) {
  background: var(--accent); color: #fff; box-shadow: none;
}
.kb-key:active:not([data-state="absent"]) {
  background: var(--accent); color: #fff;
  transform: scale(0.90);
  transition: transform 0.06s, background 0.06s;
}
.kb-wide { padding: 0 18px; font-size: 1.05rem; }
.kb-key[data-state="absent"]  { background: var(--absent-bg);  border-color: transparent; color: var(--muted); opacity: 0.4; }
.kb-key[data-state="present"] { background: var(--present-bg); border-color: var(--present-line); color: #fff; }
.kb-key[data-state="correct"] { background: var(--correct-bg); border-color: var(--correct-line); color: #fff; }

/* Très petits écrans (≤ 380px — iPhone SE, vieux Android) */
@media (max-width: 380px) {
  .topbar h1  { font-size: 1.3rem; }
  .kb-key      { height: 38px; min-width: 24px; padding: 0 4px; font-size: 0.65rem; }
  .kb-row      { gap: 4px; }
  .all-boards  { --cell-size: 22px; }
  .card        { padding: 12px; }
  .guess-tiles { gap: 4px; }
  .guess-tile  { width: 31px; height: 37px; font-size: 0.9rem; }
  #screen-game { gap: 8px; }
  .opp-boards-strip .player-board-name { font-size: 0.52rem; padding: 1px 5px; }
}

/* ─── ROUND TRANSITION OVERLAY ─── */
.round-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 15, 35, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.round-overlay-inner {
  text-align: center;
  display: grid;
  gap: 10px;
  padding: 40px 60px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 18px;
  box-shadow: 0 0 80px rgba(124,58,237,.22), 0 24px 60px rgba(0,0,0,.6);
  cursor: default;
  animation: overlay-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes overlay-in {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.round-overlay-label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}

.round-overlay-word {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--cta);
  text-shadow: 0 0 20px rgba(217,70,239,.4);
}

.round-overlay-winner {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ok);
  letter-spacing: 0.03em;
}

.round-overlay-next {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.round-overlay-countdown {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--ink);
  min-width: 1.2em;
  text-align: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.round-overlay-countdown.tick {
  transform: scale(1.4);
  opacity: 0.6;
}

/* ─── SHARE RESULT BUTTON ─── */
.share-result-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  font-size: 0.82rem;
  padding: 8px 18px;
  border-radius: 9px;
  letter-spacing: 0.02em;
}

/* Dans le round overlay : centré */
#round-share-btn {
  margin: 0 auto;
}

/* Dans le match overlay : pleine largeur comme le bouton quit */
#match-share-btn {
  width: 100%;
}

/* ─── SCORE LEADER ─── */
.score-item.is-leader {
  border-color: rgba(217,70,239,.3);
}

.score-item.is-leader .score-rank { color: var(--cta); }
.score-item.is-leader .score-pts  { color: var(--cta); }

/* ─── ADS & PREMIUM ─── */
.ad-slot {
  width: 100%;
  min-height: 90px;
  margin-top: 10px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--card-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.support-btn {
  font-size: 0.78rem;
  padding: 6px 11px;
  border-radius: 8px;
  white-space: nowrap;
  text-decoration: none;
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.30);
  background: rgba(251, 146, 60, 0.07);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.support-btn:hover {
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(251, 146, 60, 0.60);
  color: #fdba74;
  box-shadow: 0 4px 16px rgba(251, 146, 60, 0.22);
}

/* ─── CONFIRM QUIT DIALOG ─── */
.confirm-quit {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-quit-inner {
  background: var(--card);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  display: grid;
  gap: 10px;
  box-shadow: 0 0 60px rgba(248, 113, 113, 0.10), 0 20px 40px rgba(0,0,0,.55);
  animation: overlay-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-quit-title {
  margin: 0;
  font-family: 'Russo One', sans-serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.confirm-quit-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.confirm-quit-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.confirm-quit-actions button { width: auto; }

button.btn-danger {
  background: rgba(248, 113, 113, 0.10);
  color: var(--bad);
  border: 1px solid rgba(248, 113, 113, 0.40);
}

button.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.22);
  border-color: var(--bad);
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.20);
  transform: translateY(-1px);
}

/* ─── CONFETTIS ─── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 650;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0)     translateX(0)          rotate(0deg);        opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(110vh) translateX(var(--drift)) rotate(var(--spin)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece { animation: none !important; }
}

/* ─── MATCH RESULT OVERLAY ─── */
.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(15, 15, 35, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-overlay-inner {
  text-align: center;
  display: grid;
  gap: 16px;
  padding: 44px 56px;
  background: var(--card);
  border: 1px solid var(--cta);
  border-radius: 20px;
  box-shadow: 0 0 100px rgba(217,70,239,.22), 0 24px 60px rgba(0,0,0,.65);
  animation: overlay-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
  max-width: min(480px, calc(100vw - 32px));
}

.match-overlay-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.match-overlay-title {
  margin: 0;
  font-family: 'Russo One', sans-serif;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, #fde68a 0%, var(--cta) 80%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.25;
}

.lobby-share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lobby-share-row p { margin: 0; flex: 1; }

/* ─── BOUTON INVITER ─── */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 18px;
  white-space: nowrap;
  border-radius: 9px;
  width: auto;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  /* glass accent */
  background: rgba(124, 58, 237, 0.13);
  color: #c4b5fd;
  border: 1px solid rgba(124, 58, 237, 0.42);
  box-shadow: inset 0 1px 0 rgba(196, 181, 253, 0.08);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.share-btn:hover:not(:disabled) {
  background: rgba(124, 58, 237, 0.28);
  border-color: rgba(124, 58, 237, 0.75);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.share-btn:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

/* ─── BOUTONS QUITTER ─── */
#leave-lobby-btn,
#leave-game-btn,
#leave-solo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.82rem;
  padding: 9px 18px;
  background: transparent;
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.30);
}

#leave-lobby-btn:hover:not(:disabled),
#leave-game-btn:hover:not(:disabled),
#leave-solo-btn:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.60);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.10);
  transform: translateY(-1px);
}


.match-overlay-scores {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  text-align: left;
}

.match-score-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.88rem;
}

.match-score-item.is-winner {
  border-color: rgba(217,70,239,.45);
  background: rgba(217,70,239,.06);
}

.match-score-item.is-me .score-name { color: var(--accent); }
.match-score-item.is-winner .score-pts { color: var(--cta); font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  .match-overlay-inner  { animation: none; }
  .confirm-quit-inner   { animation: none; }
  .score-bar-fill       { transition: none; }
}

/* ─── HOME SOLO ROW ─── */
.home-solo-row { margin-top: 18px; }

.home-solo-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.home-solo-divider::before,
.home-solo-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.home-solo-content {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.home-solo-content > div { flex: 1; min-width: 160px; }
.home-solo-content > div h2 { margin: 0 0 4px; }

.home-solo-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.solo-form-inline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.solo-length-field { min-width: 140px; }

.solo-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  width: auto !important;
  flex-shrink: 0;
}

/* ─── SOLO SCREEN ─── */
#screen-solo {
  display: flex;
  flex-direction: column;
  gap: 13px;
  position: relative;
}

#solo-input-capture {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  padding: 0; border: 0; margin: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ─── SOLO STATS BAR ─── */
.solo-stats-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.solo-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 20px;
  min-width: 72px;
}

.solo-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.solo-stat-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

/* ─── SOLO BOARD ─── */
.solo-board-wrap {
  display: flex;
  justify-content: center;
  --cell-size: 52px;
}

/* ─── SOLO RESULT OVERLAY ─── */
.round-overlay.solo-result { cursor: default; }

.solo-result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  width: 100%;
}

.solo-result-actions .btn-cta  { width: 100%; }
.solo-result-actions .secondary { width: auto; }

/* ─── RESPONSIVE SOLO ─── */
@media (max-width: 680px) {
  .home-solo-content { flex-direction: column; align-items: flex-start; gap: 12px; }
  .solo-form-inline  { width: 100%; }
  .solo-length-field { flex: 1; }
  .solo-start-btn    { flex: 1; justify-content: center; }
  .solo-board-wrap   { --cell-size: 44px; }
  .solo-stats-bar    { gap: 5px; }
  .solo-stat         { padding: 6px 14px; min-width: 60px; }
  .solo-stat-value   { font-size: 1.1rem; }
}

@media (max-width: 380px) {
  .solo-board-wrap { --cell-size: 38px; }
  .solo-stat       { padding: 5px 10px; min-width: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .solo-result-actions button { transition: none; }
}

/* ─── STATS MULTIJOUEUR ───────────────────────────────────────── */
.multi-stats-block {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin: 12px 0 4px;
}
.multi-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ms-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Russo One', sans-serif;
}
.ms-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

/* ─── LOBBY PUBLIC ────────────────────────────────────────────── */
.home-public-rooms { margin-top: 18px; }
.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.rooms-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.rooms-refresh-btn {
  padding: 4px 8px !important;
  font-size: 0.75rem !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
}
.rooms-refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.public-rooms-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rooms-empty { font-size: 0.82rem; color: var(--muted); padding: 8px 0; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.15s;
}
.room-item:hover { border-color: var(--accent); }
.room-item-info { display: flex; flex-direction: column; gap: 1px; }
.room-item-host { font-size: 0.86rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.room-item-meta { font-size: 0.74rem; color: var(--muted); }
.room-join-btn { flex-shrink: 0; }
.room-lang-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.4;
}
.room-lang-fr { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.room-lang-en { background: color-mix(in srgb, var(--cta) 20%, transparent); color: var(--cta); border: 1px solid color-mix(in srgb, var(--cta) 40%, transparent); }
