/* Dessine Twitch */
.td-setup,
.td-app {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.td-setup h3,
.td-top h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.td-lead,
.td-meta,
.td-hint {
  color: var(--cyan-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.td-warn {
  color: var(--yellow);
  font-weight: 700;
}

.td-error {
  color: #ff8fab;
  font-weight: 700;
}

.td-twitch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.td-twitch-row input {
  flex: 1;
  min-width: 0;
}

.td-twitch-status {
  margin: -4px 0 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 700;
}

.td-twitch-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #7dffa0;
  flex-shrink: 0;
  background: #0003;
  box-shadow: 0 0 0 2px #0006;
}

.td-twitch-avatar[hidden] {
  display: none !important;
}

.td-twitch-status.is-ok {
  color: #7dffa0;
}

.td-twitch-status.is-warn {
  color: var(--yellow);
}

.td-twitch-status.is-error {
  color: #ff8fab;
}

.td-twitch-status.is-loading {
  color: var(--cyan-soft);
}

.td-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  max-width: 420px;
}

.td-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.td-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  font: inherit;
}

.td-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.td-setup-actions .btn {
  flex: 1 1 200px;
}

.td-fieldset {
  margin: 0;
  padding: 10px 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  display: grid;
  gap: 8px;
}

.td-fieldset legend {
  padding: 0 6px;
  font-weight: 800;
}

.td-radio {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.92rem;
}

.td-vol-label {
  display: grid;
  gap: 8px;
}

.td-vol-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.td-vol-label input[type="range"] {
  width: 100%;
  min-height: 28px;
  padding: 0;
  accent-color: var(--cyan);
}

.td-vol-value {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--cyan);
}

.td-radio input {
  min-height: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

.td-pick-word {
  display: grid;
  gap: 6px;
  width: 100%;
  font-weight: 700;
}

.td-pick-label {
  font-weight: 700;
}

.td-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.td-pick-row input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  font: inherit;
}

.td-dice-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: #ffe566;
  color: #0b1228;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--cyan);
}

.td-dice-btn:hover {
  background: #fff1a0;
}

.td-dice-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.td-dice-icon {
  display: block;
  width: 22px;
  height: 22px;
}

.td-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.td-timer {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--cyan-soft);
  min-width: 90px;
  text-align: right;
}

.td-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
}

@media (max-width: 860px) {
  .td-grid {
    grid-template-columns: 1fr;
  }
}

.td-main,
.td-side {
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #14182c;
  padding: 14px;
  box-shadow: 4px 4px 0 var(--cyan);
}

.td-word {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffe566;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
}

.td-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 3px solid var(--outline);
  border-radius: 14px;
  overflow: hidden;
  background: #fff7fb;
}

#td-canvas,
#td-view-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#td-canvas[hidden],
#td-view-canvas[hidden] {
  display: none !important;
}

.td-app.is-stream #td-view-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff7fb;
}

.td-app.is-stream #td-canvas {
  display: none !important;
}

#td-view-canvas {
  object-fit: contain;
  background: #fff7fb;
}

.td-victory {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  background: linear-gradient(160deg, #0b1228f2 0%, #2a1848f0 55%, #0b1228f2 100%);
  color: #fff;
}

.td-victory[hidden] {
  display: none !important;
}

.td-victory.is-pop {
  animation: tdVictoryIn 0.55s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.td-victory-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  color: var(--cyan-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.td-victory-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: #ffe566;
  text-shadow: 0 0 24px #ffe56688;
  line-height: 1.1;
}

.td-victory-meta {
  margin: 6px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  color: #fff;
}

.td-victory-meta strong {
  color: var(--cyan-soft);
}

.td-victory-pts {
  display: inline-block;
  margin-left: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #30c078;
  color: #04120a;
  font-weight: 800;
}

@keyframes tdVictoryIn {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.td-app.is-stream .td-victory {
  /* bien visible pour OBS */
  backdrop-filter: blur(2px);
}

/* Twitch draw tools wrap */
.td-tools-wrap {
  margin-top: 10px;
}

.td-tools-wrap .draw-tools {
  margin-bottom: 0;
}

.td-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.td-banner {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff14;
  font-size: 0.95rem;
}

.td-side h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
}

.td-side h4 + .td-scores {
  margin-top: 0;
}

.td-guesses,
.td-scores {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.td-guesses li,
.td-scores li {
  padding: 6px 8px;
  border-radius: 8px;
  background: #ffffff12;
  font-size: 0.9rem;
}

.td-guesses li.is-correct {
  background: #30c07844;
  outline: 2px solid var(--mint);
}

.td-scores li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.td-empty {
  opacity: 0.65;
  font-style: italic;
}

.td-meta a {
  color: var(--cyan-soft);
}

.td-stream-wait {
  display: grid;
  gap: 18px;
  min-height: 52vh;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.td-stream-wait h3 {
  margin: 0;
}

.td-wait-body {
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 420px;
}

.td-wait-loader {
  width: 88px;
  height: 88px;
  object-fit: contain;
  /* masque le fond blanc du GIF sur fond sombre */
  mix-blend-mode: multiply;
  filter: contrast(1.15) saturate(1.2);
}

.td-stream-wait .td-lead {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.td-letsgo {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 28, 0.72);
  pointer-events: none;
}

.td-letsgo[hidden] {
  display: none !important;
}

.td-letsgo p {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.55), 4px 4px 0 var(--outline);
  animation: td-letsgo-pop 0.45s ease-out both;
}

@keyframes td-letsgo-pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.td-stream-panel {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 3px solid var(--outline);
  border-radius: 14px;
  background: #1a2240;
  box-shadow: 3px 3px 0 var(--cyan);
}

.td-stream-help {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--cyan-soft);
  line-height: 1.4;
}

.td-stream-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.td-stream-row input {
  flex: 1;
  min-width: 180px;
  min-height: 40px;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  font: inherit;
  background: #0b1228;
  color: #fff;
}

/* Écran stream (OBS) : chrome site masqué, layout plus large */
body.td-stream-mode .topbar,
body.td-stream-mode .cosmos,
body.td-stream-mode #bg-audio,
body.td-stream-mode .game-bar,
body.td-stream-mode #game-back {
  display: none !important;
}

body.td-stream-mode .wrap {
  max-width: none;
  padding: 12px;
}

body.td-stream-mode #view-game h2#game-title {
  display: none;
}

.td-app.is-stream .td-timer {
  font-size: 2.6rem;
}

.td-app.is-stream .td-guesses {
  max-height: min(42vh, 380px);
}

.td-app.is-stream .td-canvas-wrap {
  min-height: 280px;
}

.td-app.is-stream .td-word,
.td-app.is-stream .td-tools-wrap,
.td-app.is-stream .td-actions,
.td-app.is-stream .td-stream-panel {
  display: none !important;
}
