/* Atelier Time's Up — styles. Tout passe par des variables : un thème ne redéfinit que les couleurs et formes. */
:root {
  --bg: #FBF3E7; --card: #FFFFFF; --card-alt: #F3E7D6; --text: #4A3B2E; --text-secondary: #8A7863; --text-muted: #B3A18A;
  --border: #F1E8D9; --border-strong: #E7DCC9; --accent: #C6714B; --accent-contrast: #FFF8F0;
  --accent-soft-bg: #F3E4DA; --accent-soft-text: #C6714B; --accent2-soft-bg: #EAEEE0; --accent2-soft-text: #7C8F65;
  --warning-bg: #EFE0D0; --warning-text: #A9764C;
  --radius-card: 20px; --radius-control: 14px; --radius-pill: 999px; --border-width: 1.5px;
  --radius-sm: 10px; --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --font-display: var(--font-body);
  --brand: #E3A93C; --brand-ink: #2A2520; --ok: #5E7D4A; --ok-contrast: #FFFFFF;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 13.5px; }
body { overscroll-behavior: none; }
svg { width: 18px; height: 18px; flex-shrink: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* App shell */
#app { max-width: 480px; margin: 0 auto; height: var(--app-height, 100dvh); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px 12px; background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.app-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.1; }
.app-sub { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin-top: 2px; }
.app-sub .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--accent); }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px 24px; -webkit-overflow-scrolling: touch; }
.screen-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin: 18px 0 8px; }
.kicker:first-child { margin-top: 0; }
.bottomnav { height: calc(68px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: var(--border-width) solid var(--border-strong); display: flex; justify-content: space-around; align-items: stretch; flex-shrink: 0; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 9.5px; color: var(--text-muted); background: none; border: none; padding: 0; }
.nav-item svg { width: 19px; height: 19px; }
.nav-item.active { color: var(--accent); font-weight: 600; }

/* Composants */
.card { background: var(--card); border: var(--border-width) solid var(--border-strong); border-radius: var(--radius-card); padding: 16px; }
.card + .card { margin-top: 10px; }
.btn { height: 42px; padding: 0 16px; border-radius: var(--radius-control); border: var(--border-width) solid var(--accent); background: transparent; color: var(--accent); font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn svg { width: 17px; height: 17px; }
.btn.solid { background: var(--accent); color: var(--accent-contrast); }
.btn.block { width: 100%; }
.btn.big { height: 50px; font-size: 15px; font-weight: 700; }
.btn.neutral { border-color: var(--border-strong); color: var(--text-secondary); background: var(--card); }
.btn.danger { border-color: var(--warning-text); color: var(--warning-text); }
.btn.small { height: 32px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; border-radius: 99px; background: var(--card); border: var(--border-width) solid var(--border-strong); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.field-label { display: block; font-size: 11px; color: var(--text-secondary); margin: 0 0 5px; }
.input { height: 40px; width: 100%; border-radius: var(--radius-control); border: var(--border-width) solid var(--border-strong); background: var(--card); padding: 0 12px; font-size: 13.5px; }
.input:focus, textarea.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
.input.code { text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--accent-soft-bg); color: var(--accent-soft-text); white-space: nowrap; }
.badge.alt { background: var(--accent2-soft-bg); color: var(--accent2-soft-text); }
.badge.warn { background: var(--warning-bg); color: var(--warning-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 6px 12px; border-radius: var(--radius-pill); background: var(--card); border: var(--border-width) solid var(--border-strong); color: var(--text); display: inline-flex; align-items: center; gap: 5px; }
.chip.active { background: var(--accent-soft-bg); color: var(--accent-soft-text); border-color: transparent; font-weight: 600; }
.list-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--radius-control); padding: 10px 12px; margin-bottom: 8px; border: none; width: 100%; text-align: left; }
.list-row .t { font-size: 13px; font-weight: 600; }
.list-row .s { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.list-row .v { font-size: 11px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-tile { background: var(--card-alt); border-radius: var(--radius-control); padding: 10px; min-width: 0; }
.stat-tile .l { font-size: 11px; color: var(--text-secondary); }
.stat-tile .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-tile .v.txt { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-hint { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
input.switch { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); position: relative; flex-shrink: 0; margin: 0; cursor: pointer; transition: background .15s ease; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 99px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.sync-error { background: var(--card-alt); color: var(--warning-text); font-size: 12px; border-radius: var(--radius-control); padding: 10px 12px; display: flex; gap: 8px; align-items: center; }
.team-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; display: inline-block; }
.notice { background: var(--warning-bg); color: var(--warning-text); border-radius: var(--radius-control); padding: 12px 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.notice.ok { background: var(--accent2-soft-bg); color: var(--accent2-soft-text); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* Logo */
.logo-block { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius-card); padding: 20px 18px; display: flex; align-items: center; gap: 16px; }
.logo-block .logo-svg { width: 92px; height: 92px; }
.logo-word { display: flex; flex-direction: column; line-height: 1; gap: 4px; font-family: "Poppins", var(--font-body); font-weight: 800; }
.logo-word .a { font-size: 14px; letter-spacing: .16em; }
.logo-word .b { font-size: 34px; }
.logo-word .c { font-family: var(--font-body); font-size: 11px; font-weight: 600; margin-top: 4px; }

/* Bottom sheet */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .16s ease; }
.modal-overlay.open { opacity: 1; }
.modal-sheet { background: var(--bg); width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; transform: translateY(16px); transition: transform .16s ease; }
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: -6px auto 12px; }
.sheet-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0 0 12px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 13px; z-index: 90; max-width: calc(100% - 32px); box-shadow: 0 12px 30px rgba(0,0,0,.22); animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Thèmes */
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
.theme-opt { position: relative; background: none; border: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: var(--text); }
.theme-prev { width: 100%; height: 66px; border-radius: 12px; padding: 7px; display: flex; flex-direction: column; gap: 4px; position: relative; border: 1.5px solid var(--border-strong); }
.theme-prev .t1 { height: 5px; width: 50%; border-radius: 3px; }
.theme-prev .t2 { flex: 1; border-radius: 6px; }
.theme-prev .t3 { height: 8px; width: 60%; border-radius: 99px; }
.theme-opt.active .theme-prev { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.theme-check { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 99px; background: var(--accent); color: var(--accent-contrast); font-size: 12px; display: flex; align-items: center; justify-content: center; }

/* Splash */
#splash { position: fixed; inset: 0; z-index: 100; background: var(--brand); color: var(--brand-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; transition: opacity .4s ease; cursor: pointer; }
#splash.out { opacity: 0; pointer-events: none; }
.no-splash #splash { display: none; }
#splash .logo-svg { width: 150px; height: 150px; animation: flip 1.8s ease-in-out infinite; }
#splash .t { font-family: "Poppins", var(--font-body); font-weight: 800; text-align: center; line-height: 1; }
#splash .t .a { font-size: 18px; letter-spacing: .2em; display: block; }
#splash .t .b { font-size: 46px; display: block; margin-top: 6px; }
#splash .hint { position: absolute; bottom: calc(30px + env(safe-area-inset-bottom)); font-size: 13px; font-weight: 600; opacity: .8; }
@keyframes flip { 0%, 35% { transform: rotate(0); } 50%, 85% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }

/* ----- Écrans de jeu (plein écran par-dessus l'app) ----- */
#game { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 20; }
.game-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.game-head .title { font-size: 15px; font-weight: 700; }
.game-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.game-foot { padding: 10px 18px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.conn-bar { background: var(--warning-bg); color: var(--warning-text); font-size: 12px; text-align: center; padding: 6px; flex-shrink: 0; }

.code-card { display: flex; align-items: center; gap: 14px; }
.qr { width: 92px; height: 92px; background: #fff; border-radius: var(--radius-sm); padding: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.qr svg { width: 100%; height: 100%; }
.big-code { font-size: 30px; font-weight: 800; letter-spacing: .14em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.team-card { background: var(--card); border-radius: var(--radius-control); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; border: var(--border-width) solid transparent; }
.team-card.mine { border-color: var(--border-strong); }
.team-head { display: flex; align-items: center; gap: 8px; }
.team-head .name { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip { font-size: 12px; padding: 5px 10px; border-radius: 99px; border: none; display: inline-flex; align-items: center; gap: 5px; color: var(--text); background: var(--card-alt); }
.pchip .on { width: 7px; height: 7px; border-radius: 99px; background: #4FA36A; }
.pchip .off { width: 7px; height: 7px; border-radius: 99px; background: var(--text-muted); }
.pchip.me { font-weight: 700; }
.pchip.add { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--text-secondary); }

/* Tirage */
.draft-row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--radius-control); padding: 11px 12px; border: none; width: 100%; text-align: left; }
.draft-row.out { background: var(--card-alt); opacity: .7; }
.draft-row.out .t { text-decoration: line-through; }
.draft-row .t { font-size: 14px; font-weight: 600; }
.draft-row .tag { font-size: 12px; font-weight: 600; color: var(--accent2-soft-text); }
.draft-row.out .tag { color: var(--warning-text); }

/* Écran orateur */
.speaker { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); min-height: 0; }
.speaker-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.round-label .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.round-label .t { font-size: 15px; font-weight: 700; }
.team-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 99px; background: var(--card); border: var(--border-width) solid var(--border-strong); font-size: 12px; font-weight: 600; max-width: 55%; }
.timer-ring { position: relative; width: 104px; height: 104px; margin: 0 auto; flex-shrink: 0; }
.timer-ring svg { width: 104px; height: 104px; transform: rotate(-90deg); }
.timer-ring .lbl { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-ring .sec { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.timer-ring .unit { font-size: 11px; color: var(--text-secondary); }
.timer-ring.hurry .sec { color: var(--warning-text); }
.card-zone { flex: 1; position: relative; min-height: 220px; touch-action: none; }
.card-under { position: absolute; inset: 14px 10px -8px 10px; background: var(--card-alt); border-radius: 26px; border: var(--border-width) solid var(--border-strong); }
.play-card { position: absolute; inset: 0; background: var(--card); border-radius: 26px; border: var(--border-width) solid var(--border-strong); box-shadow: 0 8px 20px rgba(0,0,0,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; user-select: none; -webkit-user-select: none; will-change: transform; cursor: grab; }
.play-card .cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-secondary); }
.play-card .name { font-family: var(--font-display); font-size: clamp(30px, 10vw, 46px); font-weight: 800; line-height: 1.05; overflow-wrap: anywhere; }
.play-card .stamp { position: absolute; top: 18px; padding: 6px 12px; border-radius: 10px; font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; opacity: 0; border: 3px solid currentColor; }
.play-card .stamp.ok { left: 18px; color: var(--ok); transform: rotate(-10deg); }
.play-card .stamp.ko { right: 18px; color: var(--warning-text); transform: rotate(10deg); }
.play-card.paused { filter: blur(14px); }
.swipe-btns { display: flex; gap: 10px; }
.swipe-btn { flex: 1; height: 56px; border-radius: 18px; border: none; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 700; }
.swipe-btn.ko { background: var(--warning-bg); color: var(--warning-text); }
.swipe-btn.ok { background: var(--ok); color: var(--ok-contrast); }
.swipe-btn:disabled { opacity: .35; }
.speaker-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Écran « Prêt ? » */
.ready-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: 26px 24px calc(30px + env(safe-area-inset-bottom)); color: #fff; }
.ready-screen .who { font-size: 54px; font-weight: 800; line-height: 1; overflow-wrap: anywhere; }
.ready-screen .rule { background: rgba(255,255,255,.16); border-radius: 20px; padding: 14px 18px; font-size: 14px; line-height: 1.45; max-width: 320px; }
.go-btn { width: 168px; height: 168px; border-radius: 999px; border: none; background: #fff; font-size: 22px; font-weight: 800; box-shadow: 0 12px 30px rgba(0,0,0,.22); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.go-btn svg { width: 40px; height: 40px; }
.ready-screen .pill { font-size: 15px; font-weight: 600; padding: 6px 14px; border-radius: 99px; background: rgba(255,255,255,.18); }

/* Spectateur */
.live { border-radius: 26px; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: #fff; }
.live .team { font-size: 28px; font-weight: 800; line-height: 1.1; }
.live .clock { font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; margin-top: 8px; }
.score-table { background: var(--card); border: var(--border-width) solid var(--border-strong); border-radius: var(--radius-card); padding: 4px 14px; }
.score-row { display: grid; grid-template-columns: minmax(0, 2.6fr) repeat(4, minmax(0, 1fr)); gap: 4px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: center; font-variant-numeric: tabular-nums; }
.score-row:last-child { border-bottom: none; }
.score-row.head { font-size: 11px; color: var(--text-secondary); }
.score-row > span:not(:first-child) { text-align: right; }
.score-row .tn { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.score-row .tn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .tot { font-weight: 800; }

/* Fin de tour */
.tour-banner { background: var(--brand); color: var(--brand-ink); border-radius: 0 0 26px 26px; padding: 22px 18px 18px; text-align: center; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.tour-banner .big { font-family: "Poppins", var(--font-body); font-size: 32px; font-weight: 800; }
.tour-banner .pts { font-size: 44px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.found-chip { font-size: 13px; padding: 7px 12px; border-radius: 99px; background: var(--accent2-soft-bg); color: var(--accent2-soft-text); font-weight: 600; border: none; display: inline-flex; gap: 6px; align-items: center; }
.found-chip.cancel { background: var(--card-alt); color: var(--text-secondary); text-decoration: line-through; }

/* Podium & résultats */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 190px; }
.podium .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.podium .nm { font-size: 13px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.podium .bar { width: 100%; border-radius: 14px 14px 0 0; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.podium .bar b { font-size: 26px; }

/* Écran central (TV) */
.tv { position: fixed; inset: 0; background: var(--bg); padding: 4vh 4vw; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 3vw; z-index: 30; }
.tv .live { border-radius: 32px; justify-content: center; }
.tv .live .team { font-size: 5vh; }
.tv .live .clock { font-size: 24vh; }
.tv .live .sub { font-size: 2.6vh; }
.tv .side { display: flex; flex-direction: column; gap: 2.4vh; min-height: 0; }
.tv .score-row { font-size: 2.8vh; padding: 1.6vh 0; }
.tv .score-row.head { font-size: 1.8vh; }
.tv-brand { display: flex; align-items: center; gap: 14px; }
.tv-brand .logo-svg { width: 7vh; height: 7vh; }
.tv .stat-tile .v { font-size: 4vh; }
.tv .stat-tile .l { font-size: 1.8vh; }
@media (orientation: portrait) { .tv { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .tv .live .clock { font-size: 14vh; } }

/* Desktop : colonne centrée avec un peu d'air */
@media (min-width: 560px) { #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
