:root {
  --bg: #10131f;
  --bg-soft: #171b2a;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --panel-deep: rgba(0, 0, 0, 0.22);
  --text: #f7f4e9;
  --muted: #b8bfd6;
  --accent: #ffd166;
  --accent-2: #7bdff2;
  --danger: #ff6b6b;
  --success: #6df0a7;
  --warning: #ffb86b;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(123, 223, 242, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(255, 209, 102, 0.16), transparent 36rem),
    linear-gradient(135deg, #0d1020 0%, #17162c 48%, #100c21 100%);
  overflow-x: auto;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  color: #151515;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(255, 209, 102, 0.18);
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: default;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.15);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-shell {
  width: max-content;
  min-width: 100%;
  min-height: 100vh;
  padding: 0;
}

.stream-layout {
  position: relative;
  width: min(1280px, 100vw);
}

.stream-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  grid-template-rows: 102px 164px minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
    radial-gradient(circle at 12% 8%, rgba(123, 223, 242, 0.2), transparent 20rem),
    radial-gradient(circle at 88% 0%, rgba(255, 209, 102, 0.18), transparent 18rem),
    rgba(14, 18, 34, 0.96);
  box-shadow: var(--shadow);
}

.stream-header,
.draw-zone,
.words-panel,
.status-panel,
.streamer-controls,
.summary-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.stream-header {
  display: grid;
  grid-template-columns: minmax(240px, 1.15fr) minmax(320px, 0.95fr) minmax(300px, 0.9fr);
  align-items: stretch;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 22px;
}

.brand-block {
  min-width: 0;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 950;
}

.eyebrow.compact {
  margin-bottom: 0.15rem;
  font-size: 0.62rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.9rem, 4.4vw, 4.5rem);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.6vw, 1.45rem);
  line-height: 1.05;
}

.subtitle,
.modifiers,
#remainingHint,
.round-info p,
.control-note,
.status-card p,
.goal-card small {
  color: var(--muted);
}

.subtitle {
  margin-bottom: 0;
  font-size: clamp(0.72rem, 1.1vw, 0.95rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-card,
.mini-stat,
.status-card {
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
}

.goal-card {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px 16px;
}

.goal-card span,
.mini-stat span,
.status-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.goal-card strong {
  font-size: clamp(1.3rem, 2.1vw, 2.15rem);
  line-height: 0.98;
}

.goal-card small {
  font-weight: 800;
}

.objective-track,
.timer-track {
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.objective-track {
  height: 9px;
}

.objective-bar,
.timer-bar {
  width: 0%;
  height: 100%;
  transform-origin: left center;
  transition: width 260ms ease;
}

.objective-bar {
  background: linear-gradient(90deg, var(--accent-2), var(--success), var(--accent));
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.mini-stat {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  padding: 10px 8px;
  min-width: 0;
  text-align: center;
}

.mini-stat strong {
  font-size: clamp(1.3rem, 2.15vw, 2.35rem);
  line-height: 1;
}

.draw-zone {
  display: grid;
  grid-template-rows: 44px minmax(78px, 1fr) 30px;
  gap: 8px;
  padding: 12px 18px 14px;
  border-radius: 22px;
  text-align: center;
}

.round-info {
  display: grid;
  align-content: center;
  min-width: 0;
}

.round-info p {
  margin-bottom: 0.12rem;
  font-size: clamp(0.74rem, 1.04vw, 0.98rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.letters-display {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 0.75vw, 10px);
  min-width: 0;
}

.letter-tile {
  position: relative;
  width: clamp(54px, 5.4vw, 76px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 0;
  border-radius: 17px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  color: #181421;
  background:
    radial-gradient(circle at 28% 20%, #fff9dc 0 18%, transparent 22%),
    linear-gradient(160deg, #fff1b8, var(--accent));
  font-weight: 1000;
  text-transform: uppercase;
  box-shadow:
    inset 0 -7px 0 rgba(0, 0, 0, 0.11),
    0 12px 24px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.tile-letter {
  display: block;
  font-size: clamp(1.95rem, 4vw, 3.55rem);
  line-height: 1;
  letter-spacing: -0.05em;
  transform: translateY(-6px);
}

.tile-points {
  position: absolute;
  right: 8px;
  bottom: 6px;
  min-width: 1.1em;
  padding: 0 0.15em;
  border-radius: 999px;
  color: rgba(24, 20, 33, 0.88);
  font-size: clamp(0.62rem, 0.95vw, 0.9rem);
  font-weight: 1000;
  line-height: 1.1;
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
}

.letter-tile.hidden-letter {
  color: var(--text);
  background:
    linear-gradient(160deg, #35405f, #141827);
  border: 2px dashed rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 -7px 0 rgba(0, 0, 0, 0.18),
    0 12px 24px rgba(0, 0, 0, 0.3);
}

.letter-tile.hidden-letter .tile-points {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.timer-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 10px;
  width: min(880px, 100%);
  margin: 0 auto;
}

.timer-row strong {
  color: var(--accent);
  font-size: 1.18rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer-track {
  height: 13px;
}

.timer-bar {
  width: 100%;
  background: linear-gradient(90deg, var(--success), var(--accent));
}

.play-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 278px;
  gap: 12px;
}

.words-panel,
.status-panel {
  min-height: 0;
  border-radius: 22px;
}

.words-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
  overflow: hidden;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 10px;
}

#remainingHint {
  margin-bottom: 0;
  font-size: 0.78rem;
  text-align: right;
}

.words-container {
  min-height: 0;
  display: grid;
  grid-auto-rows: min-content;
  gap: 9px;
  overflow: auto;
  padding-right: 6px;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.words-container::-webkit-scrollbar,
.summary-card::-webkit-scrollbar {
  width: 8px;
}

.words-container::-webkit-scrollbar-thumb,
.summary-card::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.word-group h3 {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-slot {
  min-width: 52px;
  min-height: 30px;
  padding: 0.42rem 0.56rem;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-align: center;
  white-space: nowrap;
}

.word-slot.found {
  color: #06120b;
  background: var(--success);
  border-color: rgba(255, 255, 255, 0.18);
  letter-spacing: normal;
}

.length-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.length-pill {
  padding: 0.52rem 0.72rem;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  font-weight: 850;
}

.status-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.status-card {
  min-width: 0;
  padding: 12px;
}

.progress-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 2.35rem;
  line-height: 1;
}

.feedback-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.feedback {
  display: grid;
  align-content: center;
  min-height: 86px;
  margin: 8px 0 0;
  padding: 0.8rem;
  border-radius: 16px;
  font-weight: 900;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.1);
}

.feedback.valid {
  color: #05150c;
  background: var(--success);
}

.feedback.duplicate {
  color: #261300;
  background: var(--warning);
}

.feedback.invalid {
  color: #2b0404;
  background: var(--danger);
}

.feedback.neutral {
  color: var(--text);
}

.rules-card p {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  line-height: 1.25;
}

.streamer-controls {
  position: absolute;
  left: calc(100% + 14px);
  top: 0;
  width: 300px;
  max-height: 100%;
  overflow: auto;
  padding: 18px;
  border-radius: 22px;
  border-style: dashed;
  background: rgba(10, 13, 25, 0.96);
}

.streamer-controls h2 {
  margin-bottom: 16px;
}

.control-group,
.answer-form {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.answer-form label,
.control-group label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.answer-line {
  display: flex;
  gap: 8px;
}

.answer-line input {
  min-width: 0;
}

.answer-line button {
  flex: 0 0 auto;
}

.actions {
  grid-template-columns: 1fr;
}

.control-note {
  margin: 16px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

code {
  padding: 0.08rem 0.28rem;
  border-radius: 6px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.summary-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 14, 0.76);
}

.summary-panel.hidden {
  display: none;
}

.summary-card {
  width: min(820px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: clamp(22px, 4vw, 34px);
  border-radius: var(--radius);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.stat-box {
  padding: 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-box strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 2rem;
}

.missed-words h3 {
  margin-bottom: 10px;
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.error-box {
  width: min(800px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 18px;
  color: #2b0404;
  background: var(--danger);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .stream-layout {
    width: 100vw;
    min-width: 0;
  }

  .streamer-controls {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 12px;
  }
}

@media (max-width: 760px) {
  .stream-frame {
    aspect-ratio: auto;
    grid-template-rows: auto auto auto;
    min-height: 720px;
  }

  .stream-header,
  .play-grid {
    grid-template-columns: 1fr;
  }

  .quick-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .letters-display {
    flex-wrap: wrap;
  }

  .panel-title-row,
  .answer-line {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* v3.3 cache-clean : corrections visuelles et verrouillage du niveau suivant */
.stream-header {
  grid-template-columns: minmax(260px, 1.05fr) minmax(310px, 0.9fr) minmax(300px, 0.85fr);
  align-items: stretch;
}

.brand-block {
  align-items: center;
}

.brand-block .eyebrow,
.brand-block .subtitle {
  display: none !important;
}

.tile-letter {
  transform: translateY(-9px);
  font-size: clamp(1.9rem, 3.9vw, 3.45rem);
}

.tile-points {
  right: 7px;
  bottom: 6px;
  font-size: clamp(0.6rem, 0.9vw, 0.84rem);
}

.goal-card,
.mini-stat {
  text-align: center;
}

.goal-card strong {
  font-size: clamp(1.25rem, 2vw, 2.05rem);
}

.mini-stat strong {
  font-size: clamp(1.25rem, 2vw, 2.25rem);
}

button:disabled,
button.locked {
  opacity: 0.42;
  filter: grayscale(0.4);
  transform: none;
  cursor: not-allowed;
  box-shadow: none;
}

.version-pill {
  display: inline-block;
  margin: -8px 0 12px;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(123, 223, 242, 0.1);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

/* ===================================================================
   Écran "faites pivoter votre téléphone" — affiché uniquement en
   orientation portrait (le jeu se joue en paysage).
   =================================================================== */
.orientation-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(135deg, #0d1020 0%, #17162c 48%, #100c21 100%);
  color: var(--text);
}
.og-inner { max-width: 380px; }
.og-badge {
  display: inline-block;
  margin-bottom: 1.1rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  color: #10131f;
  background: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.og-title { margin: 0 0 0.3rem; font-size: 1.7rem; font-weight: 800; line-height: 1.15; }
.og-sub {
  margin: 0 0 1.6rem;
  color: var(--muted);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.og-anim { display: flex; justify-content: center; margin: 1.4rem 0; }
.og-phone {
  width: 46px; height: 78px;
  border: 4px solid var(--text);
  border-radius: 9px;
  animation: og-rotate 2.6s ease-in-out infinite;
}
@keyframes og-rotate {
  0%, 15%  { transform: rotate(0deg); }
  45%, 65% { transform: rotate(-90deg); }
  100%     { transform: rotate(-90deg); }
}
.og-text { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }

@media (orientation: portrait) {
  .orientation-gate { display: flex; }
  .app-shell { display: none; }
}

/* ===================================================================
   Mode compact : téléphone en PAYSAGE (écran bas et large). Objectif :
   que tout tienne sur un seul écran, sans défilement dans aucun sens.
   =================================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  .app-shell {
    width: 100vw;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
  }

  .stream-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100vw;
    height: 100vh;
    gap: 8px;
    padding: 8px;
  }

  .stream-frame {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    aspect-ratio: auto;
    grid-template-rows: 50px 62px minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
    border-radius: 16px;
  }

  .streamer-controls {
    position: static;
    flex: 0 0 180px;
    width: 180px;
    height: 100%;
    max-height: 100%;
    margin-top: 0;
    padding: 10px;
    border-radius: 16px;
    overflow-y: auto;
  }

  .stream-header {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 6px 8px;
  }

  h1 { font-size: 1.25rem; }

  .goal-card, .mini-stat { padding: 4px 6px; gap: 2px; }
  .goal-card strong, .mini-stat strong { font-size: 0.92rem; }
  .goal-card span, .mini-stat span { font-size: 0.52rem; }
  .objective-track { height: 6px; }

  .draw-zone {
    grid-template-rows: 18px minmax(0, 1fr) 14px;
    padding: 6px 8px 8px;
    gap: 4px;
    border-radius: 14px;
  }
  .round-info p { font-size: 0.6rem; }
  .timer-row strong { font-size: 0.8rem; }
  .timer-track, .timer-bar { height: 7px; }

  .letter-tile { width: clamp(28px, 6vw, 40px); border-radius: 9px; }
  .tile-letter { font-size: clamp(1rem, 3vw, 1.45rem); transform: translateY(-3px); }
  .tile-points { font-size: 0.52rem; right: 4px; bottom: 3px; }

  .play-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
  .words-panel, .status-panel { padding: 6px; border-radius: 12px; }
  .panel-title-row { margin-bottom: 4px; }
  #remainingHint { font-size: 0.58rem; }
  .word-slot { min-width: 32px; min-height: 20px; padding: 0.2rem 0.32rem; font-size: 0.58rem; }

  .status-card { padding: 6px; }
  .feedback { min-height: 30px; padding: 0.3rem; font-size: 0.66rem; }
  .rules-card { display: none; }
  .progress-card strong { font-size: 1.05rem; }

  .streamer-controls h2 { margin-bottom: 6px; font-size: 0.92rem; }
  .control-group, .answer-form { margin-top: 6px; gap: 4px; }
  .answer-form label, .control-group label { font-size: 0.6rem; }
  button { padding: 0.42rem 0.55rem; font-size: 0.7rem; }
}
