:root {
  --bg: #12301f; --bg2: #1c4630; --card: rgba(255,255,255,0.08); --line: rgba(255,255,255,0.14);
  --txt: #f4f7f2; --mut: #a9c2b1; --acc: #ffd23f; --acc2: #2ed47a; --bad: #ff4d5a;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: radial-gradient(circle at 50% 0%, var(--bg2), var(--bg) 70%); color: var(--txt);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.screen { position: absolute; inset: 0; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; }
h2 { margin: 4px 0; font-size: 22px; }
.logo { text-align: center; margin: 18px 0 6px; }
.logo .flag { font-size: 54px; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); animation: bob 2.4s ease-in-out infinite; }
.logo h1 { margin: 0; font-size: 40px; letter-spacing: -1px; font-weight: 900; background: linear-gradient(180deg,#fff,#c8f5d6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo small { display: block; font-size: 15px; letter-spacing: 3px; text-transform: uppercase; color: var(--acc); -webkit-text-fill-color: var(--acc); font-weight: 700; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(6px); }
.card.small { font-size: 14px; color: var(--mut); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mut); }
.label { font-size: 14px; color: var(--mut); }
input[type=text], input:not([type]), input[type=password] { background: rgba(0,0,0,0.25); border: 1px solid var(--line); color: var(--txt); padding: 12px 14px; border-radius: 12px; font-size: 17px; outline: none; }
input:focus { border-color: var(--acc); }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,0.1); border-radius: 14px; padding: 14px; font-weight: 700; font-size: 16px; width: 100%; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffe066, #ffc21a); color: #2a2100; border: none; box-shadow: 0 6px 18px rgba(255,200,40,.3); font-size: 18px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mut); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row input { flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 6px; font-weight: 800; min-width: 0; }
.row .btn { width: auto; padding: 12px 18px; }
.resume { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.resume button { background: rgba(46,212,122,.15); border: 1px solid rgba(46,212,122,.4); border-radius: 12px; padding: 10px; font-weight: 600; }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset -5px -6px 10px rgba(0,0,0,.35), inset 4px 4px 8px rgba(255,255,255,.5); }
.colors button.on { border-color: #fff; transform: scale(1.12); }
.colors button.taken { opacity: .25; pointer-events: none; }

.chips, .seg { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button, .seg button { flex: 1; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.2); font-weight: 600; font-size: 14px; }
.chips button.on, .seg button.on { background: var(--acc); color: #2a2100; border-color: var(--acc); }
input[type=range] { width: 100%; accent-color: var(--acc); }
.hint { font-size: 13px; color: var(--mut); margin: 0; }
.center { text-align: center; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--txt); font-size: 15px; }
.switch input { display: none; }
.switch span { width: 46px; height: 26px; border-radius: 13px; background: rgba(255,255,255,.2); position: relative; transition: .2s; flex: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--acc2); }
.switch input:checked + span::after { left: 23px; }

.big-code { font-size: 46px; font-weight: 900; letter-spacing: 10px; text-align: center; color: var(--acc); text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.lobby-head { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0,0,0,.18); border-radius: 12px; animation: pop .3s; }
.players li .host { margin-left: auto; font-size: 13px; color: var(--acc); }
.players li.off { opacity: .5; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.ball { display: inline-block; vertical-align: middle; width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset -3px -4px 6px rgba(0,0,0,.35), inset 3px 3px 5px rgba(255,255,255,.6); }

/* ---------- jeu ---------- */
#game { padding: 0; gap: 0; max-width: none; }
.hud { padding: calc(8px + var(--safe-t)) 12px 6px; background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,0)); position: relative; z-index: 2; }
.hud-top { display: flex; align-items: center; gap: 10px; }
.hole-info { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.hole-info b { font-size: 17px; }
.hole-info span { font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.par { display: flex; gap: 8px; font-size: 13px; }
.par span { background: rgba(0,0,0,.3); padding: 4px 8px; border-radius: 8px; }
.icon.on { background: var(--acc); }
.icon { background: rgba(0,0,0,.3); border: none; width: 38px; height: 38px; border-radius: 12px; font-size: 22px; line-height: 1; }
.turn { margin-top: 6px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.35); border-radius: 14px; padding: 7px 10px; font-weight: 700; transition: background .3s; }
.turn.mine { background: linear-gradient(90deg, rgba(255,210,63,.95), rgba(255,180,20,.9)); color: #2a2100; animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 18px rgba(255,210,63,.6); } }
.turn .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset -2px -3px 4px rgba(0,0,0,.35); }
.turn .strokes { margin-left: auto; font-size: 13px; opacity: .85; }
.timer { width: 26px; height: 26px; transform: rotate(-90deg); flex: none; }
.timer circle { fill: none; stroke: rgba(255,255,255,.2); stroke-width: 4; }
.timer #timerArc { stroke: currentColor; stroke-dasharray: 94.25; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.timer.urgent #timerArc { stroke: var(--bad); }
.stage { position: absolute; inset: 0; z-index: 1; touch-action: none; }
#cv { position: absolute; left: 0; right: 0; width: 100%; touch-action: none; display: block; }
.hint-drag { position: absolute; left: 50%; bottom: calc(62px + var(--safe-b)); transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 6px 12px; border-radius: 20px; font-size: 13px; white-space: nowrap; pointer-events: none; animation: fade 3s 4s forwards; }
@keyframes fade { to { opacity: 0; } }
.chips-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px calc(8px + var(--safe-b)); background: linear-gradient(0deg, rgba(0,0,0,.5), rgba(0,0,0,0)); scrollbar-width: none; }
.chip { display: flex; align-items: center; gap: 6px; padding: 5px 9px 5px 6px; background: rgba(0,0,0,.4); border-radius: 20px; font-size: 13px; white-space: nowrap; border: 2px solid transparent; flex: none; }
.chip.turn-on { border-color: var(--acc); }
.chip .ball { width: 16px; height: 16px; }
.chip small { color: var(--mut); }
.chip.done { opacity: .6; }
.chip.off .ball { filter: grayscale(1); }

/* ---------- panneaux ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; background: rgba(5,15,10,.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
.panel { width: 100%; max-width: 440px; background: linear-gradient(180deg, #24553a, #173a28); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.5); animation: rise .35s cubic-bezier(.2,1.4,.4,1); max-height: 100%; overflow-y: auto; }
.panel.tall { max-height: calc(100% - var(--safe-t) - var(--safe-b)); }
@keyframes rise { from { transform: translateY(30px) scale(.95); opacity: 0; } }
.results { width: 100%; border-collapse: collapse; }
.results td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.results td.n { text-align: right; font-weight: 800; }
.results .tag { font-size: 12px; padding: 2px 7px; border-radius: 8px; background: rgba(255,255,255,.12); }
.tag.ace { background: var(--acc); color: #2a2100; }
.tag.good { background: var(--acc2); color: #062a14; }
.tag.bad { background: rgba(255,77,90,.8); }
.bar { height: 5px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; }
.bar div { height: 100%; background: var(--acc); width: 100%; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: 190px; margin-top: 4px; }
.podium .step { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podium .block { width: 100%; border-radius: 12px 12px 4px 4px; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; font-size: 26px; font-weight: 900; color: rgba(0,0,0,.55); animation: grow .7s cubic-bezier(.2,1.3,.4,1) both; transform-origin: bottom; }
.podium .p1 .block { height: 110px; background: linear-gradient(180deg, #ffe680, #f0b400); animation-delay: .9s; }
.podium .p2 .block { height: 80px; background: linear-gradient(180deg, #f1f4f6, #aeb8c0); animation-delay: .5s; }
.podium .p3 .block { height: 58px; background: linear-gradient(180deg, #f2c39a, #c27a3e); animation-delay: .2s; }
.podium .who { font-weight: 800; font-size: 14px; text-align: center; animation: fadein .4s both; }
.podium .p1 .who { animation-delay: 1.4s; } .podium .p2 .who { animation-delay: 1s; } .podium .p3 .who { animation-delay: .7s; }
.podium .who small { display: block; font-weight: 600; color: var(--mut); }
.podium .crown { font-size: 26px; animation: bob 2s infinite; }
@keyframes grow { from { transform: scaleY(0); } }
.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: rgba(0,0,0,.2); border-radius: 14px; animation: fadein .5s both; }
.comment .rk { font-weight: 900; font-size: 18px; min-width: 30px; text-align: center; }
.comment p { margin: 2px 0 0; font-size: 14px; }
.comment b { font-size: 15px; }
.comment .pts { margin-left: auto; font-weight: 800; color: var(--acc); white-space: nowrap; }
details summary { cursor: pointer; color: var(--mut); font-size: 14px; }
.scroll { overflow-x: auto; margin-top: 8px; }
.card-table { border-collapse: collapse; font-size: 12px; }
.card-table th, .card-table td { padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.card-table td:first-child, .card-table th:first-child { text-align: left; position: sticky; left: 0; background: #1d4630; }
.card-table .u { color: var(--acc2); font-weight: 700; } .card-table .o { color: #ff9aa2; }
.kick { display: flex; flex-wrap: wrap; gap: 6px; }
.kick button { border: 1px solid rgba(255,77,90,.5); background: rgba(255,77,90,.12); border-radius: 10px; padding: 8px 10px; }

#toasts { position: fixed; top: calc(110px + var(--safe-t)); left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(0,0,0,.75); padding: 8px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; animation: toast 3.2s forwards; max-width: 90%; text-align: center; }
@keyframes toast { 0% { transform: translateY(-10px); opacity: 0; } 8%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; } }
