* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  /* The radial glow has an explicit 1100×560 px size; without `no-repeat`
     it tiles vertically as soon as the page is taller than 560 px (lobby,
     in-game, fin de partie), producing repeated halos. `fixed` anchors it
     to the viewport so the ambient light effect stays at the top edge
     during scroll instead of riding the content. */
  background: radial-gradient(1100px 560px at 50% -8%, #1c2150 0%, #0f1020 55%), #0f1020;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #fff; display: flex; flex-direction: column; min-height: 100vh; padding: 12px 16px 22px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* App-like feel: UI text never selects on tap/long-press — except the editable
   inputs and the room code you may want to copy. */
input, .rb-code { -webkit-user-select: text; user-select: text; }

/* top app-bar */
.topbar { width: 100%; max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand span { background: linear-gradient(90deg, #ffd23f, #ff7a7a, #8aa0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar-actions { display: flex; gap: 8px; }
.iconbtn { width: auto; min-width: 42px; height: 42px; padding: 0 12px; font-size: 1.1rem; font-weight: 700; border: none; border-radius: 12px; background: #1b1d35; color: #fff; cursor: pointer; }
/* On narrow phones the topbar now carries up to 6 icons + the brand; shrink
   the icon buttons so they all fit instead of pushing ✕ Quitter off-screen. */
@media (max-width: 420px) {
  .iconbtn { min-width: 36px; padding: 0 6px; font-size: 1rem; }
  .topbar { gap: 6px; }
  .bar-actions { gap: 6px; }
}
/* Sub-iPhone-SE widths: drop the "Aperolympics" wordmark (the 🍹 stays) and
   crunch the icons further so all six action buttons still fit. */
@media (max-width: 380px) {
  .iconbtn { min-width: 32px; padding: 0 4px; font-size: .95rem; }
  .topbar, .bar-actions { gap: 4px; }
  .brand span { display: none; }
  .brand { font-size: 1.35rem; }
}
.iconbtn.danger { background: #3a1d2a; color: #ff9a9a; }

.sub { color: #9aa; font-size: .9rem; margin: 6px auto 8px; width: 100%; max-width: 560px; }

h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; margin: 4px 0; text-align: center; }

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 560px; margin: 0 auto; }
.screen { flex: 1; display: none; flex-direction: column; gap: 14px; justify-content: center; }
.screen.on { display: flex; animation: fade .25s ease; }
#game-area.on, #s-hub.on, #s-lobby.on { justify-content: flex-start; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* landing hero + onboarding steps */
.hero { text-align: center; }
.hero-emoji { font-size: 3.2rem; line-height: 1; }
.hero p { margin-top: 4px; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.steps li { position: relative; padding: 10px 12px 10px 46px; background: #161830; border-radius: 12px; font-size: .95rem; line-height: 1.4; }
.steps .num { position: absolute; left: 10px; top: 9px; width: 26px; height: 26px; border-radius: 50%; background: #5b6cff; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: .9rem; }

input { padding: 16px; font-size: 1.15rem; border: 2px solid transparent; border-radius: 12px; width: 100%; background: #1b1d35; color: #fff; }
input:focus { outline: none; border-color: #5b6cff; }
input::placeholder { color: #7a7e9a; }

button { padding: 16px; font-size: 1.1rem; font-weight: 700; border: none; border-radius: 12px; color: #fff; cursor: pointer; background: #2a2d4a; width: 100%; transition: transform .05s ease, filter .15s ease; }
button:active { transform: scale(.985); }
button:disabled { opacity: .4; }
/* Keyboard a11y: a visible ring on focus (only when navigating via keyboard,
   not on every tap — :focus-visible suppresses it on touch/click). */
button:focus-visible, input:focus-visible, .game-card:focus-visible { outline: 2px solid #ffd23f; outline-offset: 2px; }
.primary { background: linear-gradient(90deg, #5b6cff, #7a5bff); }

.row { display: flex; gap: 8px; align-items: stretch; }
.row .grow { flex: 1; }
.info { width: 48px; flex: none; background: #1b1d35; font-size: 1rem; }
.mini { width: auto; padding: 8px 12px; font-size: .85rem; background: #2a2d4a; border-radius: 10px; }

.or { text-align: center; color: #7a7e9a; }
.error { color: #ff7a7a; min-height: 1.2em; text-align: center; }
.field-label { color: #cdd; font-size: .9rem; font-weight: 600; }
.small { font-size: .85rem; }

/* --- Choice screen (post-pseudo) ---------------------------------------- */
.choice-head { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-bottom: 4px; }
.choice-who { font-size: 1.05rem; color: #cdd; }
.choice-who b { color: #fff; }
.link { display: inline; background: transparent; padding: 0; color: #8aa0ff; font-size: .9rem; font-weight: 600; text-decoration: underline; width: auto; vertical-align: baseline; }
/* Live "N parties publiques en cours" badge with a pulsing dot to convey
   "real-time list". */
.choice-counter { background: #1b1d35; border: 1px solid #2a2f5c; border-radius: 999px; padding: 6px 14px; font-size: .9rem; font-weight: 600; color: #cdd; display: inline-flex; align-items: center; gap: 8px; }
.cc-dot { width: 8px; height: 8px; border-radius: 50%; background: #26890c; animation: cc-pulse 1.6s ease-in-out infinite; }
@keyframes cc-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.choice-card { background: #161830; border: 1px solid #262a52; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.choice-card h3 { font-size: 1rem; font-weight: 800; color: #e9ecff; }
.choice-sep { text-align: center; color: #7a7e9a; font-size: .85rem; margin: 2px 0; }
.pub-list-head { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; }
.pub-list { display: flex; flex-direction: column; gap: 8px; }
/* Public room row: emoji + game name + meta (code · players · phase) + CTA. */
.pub-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #1b1d35; border: 1px solid #2a2f5c; border-radius: 12px; cursor: pointer; transition: border-color .15s, transform .05s; text-align: left; }
.pub-item:hover { border-color: #5b6cff; }
.pub-item:active { transform: scale(.99); }
.pi-emoji { font-size: 1.6rem; flex: none; }
.pi-body { flex: 1; min-width: 0; }
.pi-game { font-weight: 700; font-size: 1rem; }
.pi-meta { font-size: .82rem; color: #9aa; margin-top: 2px; }
.pi-code { font-weight: 700; color: #ffd23f; letter-spacing: .12em; }
.pi-go { color: #8aa0ff; font-weight: 800; white-space: nowrap; font-size: .9rem; }
/* Visibility toggle: 2 large radio-button cards, .on receives the gradient. */
.vis-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vis-btn { padding: 12px 10px; background: #1b1d35; border: 2px solid #2a2f5c; border-radius: 12px; color: #cdd; text-align: center; transition: background .2s, border-color .2s; }
.vis-btn.on { background: linear-gradient(135deg, #5b6cff, #7a5bff); color: #fff; border-color: #5b6cff; }
.vis-label { font-weight: 800; font-size: 1rem; }
.vis-sub { font-size: .75rem; opacity: .85; margin-top: 2px; }

.section-label { font-weight: 700; color: #cdd; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.section-label .info { width: 28px; height: 28px; padding: 0; font-size: .85rem; }

/* room badge (shareable code + link) */
.roombadge { text-align: center; background: #161830; border: 1px solid #262a52; border-radius: 14px; padding: 12px; }
.rb-label { color: #9aa; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.rb-code { font-size: 2rem; font-weight: 900; letter-spacing: .25em; margin: 2px 0; }
.rb-share { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; font-size: .8rem; word-break: break-all; }

/* players */
.players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { background: #1b1d35; border-radius: 999px; padding: 6px 12px; font-size: .95rem; display: inline-flex; align-items: center; gap: 6px; }
.chip.off { opacity: .45; }
.chip-score { color: #ffd23f; font-variant-numeric: tabular-nums; }
.crown { color: #ffd23f; }

/* game cards */
.game-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
/* Section header above each bucket of cards (jouable / encore-requis). */
.gc-divider { font-size: .8rem; font-weight: 800; color: #cdd; text-transform: uppercase; letter-spacing: .08em; padding: 6px 4px 2px; }
.game-card { display: flex; align-items: center; gap: 14px; background: #161830; border: 1px solid #262a52; border-radius: 14px; padding: 14px; cursor: pointer; transition: border-color .15s, transform .05s, opacity .2s; }
.game-card:not(.disabled):not(.below-min):hover { border-color: #5b6cff; }
.game-card:not(.disabled):not(.below-min):active { transform: scale(.99); }
.game-card .icon { font-size: 2rem; }
.game-card .gc-body { flex: 1; min-width: 0; }
.game-card .name { font-weight: 700; font-size: 1.1rem; }
.game-card .gc-go { color: #8aa0ff; font-weight: 800; white-space: nowrap; }
.game-card.disabled { opacity: .55; cursor: default; }
.game-card.disabled .gc-info { opacity: 1; } /* rules stay readable even when you can't pick */
/* Jouable maintenant: brighter border + faint green tint to draw the eye.
   Combines with .disabled (non-host) without losing the visual cue. */
.game-card.ready { border-color: #2f6633; background: linear-gradient(180deg, rgba(38, 137, 12, .10), rgba(38, 137, 12, .02)), #161830; }
.game-card.ready:not(.disabled):hover { border-color: #5be072; }
/* Encore X joueurs: dimmed, not tappable, badge shows the missing count. */
.game-card.below-min { opacity: .5; cursor: default; }
.game-card.below-min .gc-info { opacity: 1; } /* still let me read the rules */
.gc-info { width: 36px; height: 36px; padding: 0; flex: none; align-self: center; }
/* "👥 N+" pill on each game card. Punchier than the previous v20 sizing
   (.82rem solid tint) — bumped further per user request: bigger digits,
   inline "encore K" hint in the below-min state, green tick in .ok. */
.gc-min { display: inline-block; font-size: .85rem; color: #e9ecff; font-weight: 700; padding: 3px 10px; background: #22264a; border: 1px solid #3a3f72; border-radius: 999px; margin-left: 8px; vertical-align: middle; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gc-min.ok { color: #b8e8a8; border-color: #2f6633; background: rgba(38, 137, 12, .16); }
.gc-min b { color: #ffce6b; font-weight: 800; }
.game-card.below-min .gc-min { color: #ffce6b; border-color: #7a5e2e; background: rgba(255, 206, 107, .14); }

.lobby-head { display: flex; align-items: center; gap: 12px; justify-content: center; }
/* Lobby room badge is the share CTA — beef it up vs. the in-game variant. */
.lobby-roombadge { padding: 18px 14px; }
.lobby-roombadge .rb-code { font-size: 2.4rem; }
.lobby-roombadge .rb-share .mini { background: linear-gradient(90deg, #5b6cff, #7a5bff); font-weight: 700; }
/* Live ready-state card: progress + count + status line. Two flavours via
   .waiting (amber) / .ready (green) on the wrapper. Solid background-color
   tints (not gradients) so the colour swap actually animates — `transition`
   does not interpolate linear-gradient values. */
.lobby-ready { background-color: #161830; border: 2px solid #262a52; border-radius: 14px; padding: 14px; transition: border-color .25s, background-color .25s; }
.lobby-ready.waiting { border-color: #5b4828; background-color: rgba(255, 206, 107, .08); }
.lobby-ready.ready { border-color: #26890c; background-color: rgba(38, 137, 12, .10); }
.lr-progress { height: 8px; background: #2a2d4a; border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.lr-progress > i { display: block; height: 100%; width: 0; background: #ffce6b; transition: width .35s ease, background-color .25s; }
.lobby-ready.ready .lr-progress > i { background: #26890c; }
.lr-count { font-weight: 800; font-size: 1.1rem; text-align: center; font-variant-numeric: tabular-nums; }
.lr-status { text-align: center; margin-top: 6px; font-size: .9rem; line-height: 1.4; }
.lobby-ready.waiting .lr-status { color: #ffce6b; }
.lobby-ready.ready .lr-status { color: #b8e8a8; }
.rules { background: #161830; border: 1px solid #262a52; border-radius: 12px; padding: 14px; font-size: .95rem; line-height: 1.5; color: #cdd; }
.rules h4 { margin-bottom: 6px; color: #fff; }
.bullets { padding-left: 18px; }
.bullets li { margin: 4px 0; }

.muted { color: #9aa; }
.center { text-align: center; }
.q { font-size: 1.35rem; text-align: center; margin-bottom: 8px; }
.big { font-size: 3rem; text-align: center; }

/* quiz answer grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.grid button { font-size: 1.3rem; min-height: 92px; }
.a { background: #e6394a; } .b { background: #1368ce; } .c { background: #d89e00; } .d { background: #26890c; }

/* ranked lists: per-game reveal ols + leaderboard overlay (.board) */
ol { list-style: none; padding: 0; }
#game-area ol li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: #1b1d35; border-radius: 10px; margin-bottom: 8px; }
.board li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #1b1d35; border-radius: 10px; margin-bottom: 8px; }
.board .rank { width: 1.8em; text-align: center; font-weight: 800; font-size: 1.05rem; }
.board .who { flex: 1; min-width: 0; }
.board .pts { color: #ffd23f; font-weight: 800; font-variant-numeric: tabular-nums; }
.board li.off { opacity: .5; }
/* 🏆 overlay tab strip: switch between current-game scores and session totals */
.board-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.board-tab { flex: 1; padding: 10px 8px; font-size: .9rem; font-weight: 700; background: #1b1d35; border: 1px solid transparent; border-radius: 10px; color: #cdd; }
.board-tab.on { background: linear-gradient(90deg, #5b6cff, #7a5bff); color: #fff; }
/* Inline trophy/MVP badges next to the name on the session-totals tab */
.bd-stats { display: inline-block; margin-left: 6px; font-size: .78rem; color: #aab; white-space: nowrap; }

/* secondary / option buttons used by game renderers (e.g. vote targets) */
.ghost { background: #1b1d35; border: 1px solid #2a2f5c; }
.ghost:disabled { opacity: .45; }

/* quiz countdown: points fading with time + draining timer bar */
.quiz-top { display: flex; align-items: center; gap: 12px; }
.timerbar { flex: 1; height: 14px; background: #1b1d35; border-radius: 999px; overflow: hidden; }
.timerbar > i { display: block; height: 100%; width: 100%; border-radius: 999px; background: #26890c; transition: width .5s linear, background-color .3s; }
.points { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; font-size: 1.1rem; }

/* overlays (leaderboard / help) as bottom sheets on mobile */
.overlay { position: fixed; inset: 0; background: rgba(8, 9, 20, .72); display: none; align-items: flex-end; justify-content: center; z-index: 50; }
.overlay.on { display: flex; animation: fade .2s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; background: #14162e; border: 1px solid #2a2f5c; border-radius: 18px 18px 0 0; padding: 16px 16px 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head .iconbtn { background: #22264a; }

/* match history overlay */
.hist-entry { margin-bottom: 14px; }
.hist-head { margin-bottom: 6px; font-size: 1.05rem; }
#historyBody li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #1b1d35; border-radius: 8px; margin-bottom: 6px; }
#historyBody .pts, #historyBody b { color: #ffd23f; font-variant-numeric: tabular-nums; }
/* session recap card at the top of the 📜 overlay (2+ games only) */
.hist-recap { background: linear-gradient(135deg, #161830, #1b1f44); border: 1px solid #2d3370; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: .95rem; line-height: 1.7; }
.hist-recap-head { color: #9aa; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; }
/* per-entry headline strip + MVP line. Banner mirrors fin-de-partie gradient
   so a player recognises the moment they're recalling. */
.hist-banner { background: linear-gradient(90deg, #5b6cff, #7a5bff); color: #fff; border-radius: 8px; padding: 6px 10px; margin: 2px 0 8px; font-weight: 700; font-size: .92rem; text-align: center; word-break: break-word; }
.hist-mvp { font-size: .88rem; margin: 4px 0 8px; padding: 0 4px; word-break: break-word; }

/* end-of-game "fin de partie" screen: podium + per-game MVP/winner */
.results { display: flex; flex-direction: column; gap: 14px; }
.results-head { text-align: center; }
.results-emoji { font-size: 3.5rem; line-height: 1; }
.results-head h2 { margin-top: 4px; }
.winner-banner { text-align: center; background: linear-gradient(90deg, #5b6cff, #7a5bff); border-radius: 12px; padding: 14px; font-weight: 800; font-size: 1.15rem; }
.podium { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; }
.podium li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #1b1d35; border-radius: 12px; }
.podium .rank { width: 2em; text-align: center; font-size: 1.4rem; }
.podium .who { flex: 1; }
.podium .pts { color: #ffd23f; font-weight: 800; font-variant-numeric: tabular-nums; }
.mvp { background: #161830; border: 1px solid #262a52; border-radius: 12px; padding: 14px; text-align: center; }
.mvp-label { color: #9aa; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.mvp-name { font-weight: 800; font-size: 1.1rem; }
.mvp-value { color: #ffd23f; font-weight: 700; margin-left: 6px; font-variant-numeric: tabular-nums; }
.results-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* tap tooltip */
.tipbubble { position: fixed; z-index: 60; max-width: 260px; background: #20254d; color: #e9ecff; border: 1px solid #3a3f72; border-radius: 10px; padding: 10px 12px; font-size: .88rem; line-height: 1.4; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }

/* reconnecting overlay: a centered card (not a bottom sheet) with a spinner */
#ov-reconnect { align-items: center; }
.reconnect-card { max-width: 360px; border-radius: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.reconnect-card button { margin-top: 4px; background: #1b1d35; width: auto; padding: 12px 18px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #2a2f5c; border-top-color: #5b6cff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* connection-lost treatment: loud status + a dimmed, non-tappable game area so
   dead taps aren't silently swallowed during a reconnect */
body.offline #status { color: #ffce6b; font-weight: 700; }
body.offline #status::before { content: "⚠ "; }
body.offline #game-area, body.offline #startBtn, body.offline .game-card, body.offline #lobbyReady { opacity: .5; pointer-events: none; }

/* transient toast (host hand-off, etc.) */
.toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 70; max-width: 90%; background: #20254d; color: #fff; border: 1px solid #3a3f72; border-radius: 12px; padding: 12px 16px; font-weight: 700; text-align: center; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); display: none; }
.toast.on { display: block; animation: fade .2s ease; }

/* Build badge: tiny, low-contrast version + date in the bottom-right corner.
   Visible everywhere so a tester can spot the running build without digging
   into devtools, but low-opacity enough that it doesn't distract a player. */
.version-tag { position: fixed; bottom: 4px; right: 8px; z-index: 5; font-size: .65rem; color: rgba(233, 236, 255, .22); font-variant-numeric: tabular-nums; letter-spacing: .04em; pointer-events: none; user-select: none; }

@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; }
}
