:root {
  --panel: rgba(22, 30, 44, 0.72);
  --panel-b: rgba(255, 255, 255, 0.14);
  --txt: #f4f7fb;
  --muted: #a9b6c8;
  --accent: #29b6f6;
  --gold: #ffc928;
  --good: #4cff7a;
  --warn: #ffb300;
  --bad: #ff3b3b;
  --eq: #ffe14c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2230; color: var(--txt); font-family: 'Baloo 2', system-ui, sans-serif; user-select: none; }
#app canvas { display: block; }
.hidden { display: none !important; }
kbd { display: inline-block; padding: 0 6px; border-radius: 5px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); font: 700 12px/18px system-ui, sans-serif; }

.panel { background: var(--panel); border: 1px solid var(--panel-b); border-radius: 14px; backdrop-filter: blur(6px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* ---------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
#topleft { position: absolute; left: 16px; top: 16px; padding: 8px; text-align: center; }
#minimap { width: 200px; height: 200px; border-radius: 10px; display: block; }
#district { font-weight: 800; font-size: 15px; margin-top: 4px; letter-spacing: .5px; text-transform: uppercase; }
#road { font-size: 12px; color: var(--muted); margin-top: -4px; }

#logo-small { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 26px; letter-spacing: 1px; color: #fff; text-shadow: 0 3px 0 #1d3557, 0 5px 12px rgba(0,0,0,.4); }
#logo-small span { color: var(--gold); }
#logo-small i { font-style: normal; color: var(--accent); font-size: 18px; }

#topright { position: absolute; right: 16px; top: 16px; width: 290px; display: flex; flex-direction: column; gap: 8px; }
.pill { padding: 6px 14px; font-weight: 800; font-size: 20px; text-align: right; }
#board { padding: 10px 12px; }
#board h3 { margin: 0 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; text-align: center; color: var(--muted); }
#board ol { list-style: none; margin: 0; padding: 0; font-size: 14px; }
#board li { display: grid; grid-template-columns: 26px 1fr 42px 64px; gap: 4px; padding: 1px 6px; border-radius: 6px; }
#board li.me { background: rgba(41,182,246,.35); font-weight: 800; }
#board li.gap { display: block; text-align: center; color: var(--muted); }
#board .rk { color: var(--muted); }
#board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board .sc { text-align: right; font-variant-numeric: tabular-nums; }
.tr { font-weight: 800; font-size: 12px; text-align: center; border-radius: 5px; }
.tr.prey { color: var(--good); } .tr.threat { color: var(--bad); } .tr.eq { color: var(--eq); }
#online { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

#radar-panel { padding: 8px 12px; border-color: rgba(255,59,59,.6); }
#radar-panel h4 { margin: 0 0 4px; color: #ff6b6b; font-size: 14px; }
#radar-panel ol { list-style: none; margin: 0; padding: 0; font-size: 14px; }
#radar-panel li { display: grid; grid-template-columns: 24px 1fr 40px 60px; align-items: center; gap: 4px; }
#radar-panel .arrow { display: inline-block; color: #ff6b6b; font-size: 16px; text-align: center; }
#radar-panel .dist { text-align: right; color: var(--muted); }

#stats { position: absolute; left: 16px; bottom: 16px; padding: 10px 14px; display: flex; gap: 18px; }
#stats div { display: flex; flex-direction: column; }
#stats span { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; }
#stats b { font-size: 22px; line-height: 1.1; display: flex; align-items: center; gap: 5px; }
#stats em { font-style: normal; }
.coin { display: inline-block; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, var(--gold) 55%, #b27b00); }

#bottom { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(460px, 92vw); }
#speedo { display: flex; align-items: baseline; gap: 6px; text-shadow: 0 2px 8px rgba(0,0,0,.6); flex-wrap: wrap; justify-content: center; }
#speedo b { font-size: 44px; line-height: 1; }
#speedo span { font-weight: 800; color: #dfe7f0; }
#speedo .bar { flex-basis: 100%; }
#tierbox { width: 100%; padding: 8px 14px 6px; text-align: center; }
#tier-name { font-weight: 800; font-size: 18px; letter-spacing: 1px; }
#tier-sub { font-size: 13px; color: var(--muted); }
.bar { height: 14px; border-radius: 8px; background: rgba(255,255,255,.14); overflow: hidden; margin: 3px 0; }
.bar.thin { height: 5px; width: 220px; margin: 0 auto; }
#tier-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4cff7a, #29b6f6); transition: width .25s; }
#speed-fill { height: 100%; width: 0; background: linear-gradient(90deg, #fff, #ffb300, #ff3b3b); }
#protect { display: none; padding: 2px 12px; border-radius: 10px; background: rgba(41,182,246,.8); font-weight: 800; font-size: 14px; }
.intent { font-weight: 800; font-size: 18px; min-height: 26px; color: var(--gold); text-shadow: 0 2px 6px rgba(0,0,0,.7); }

#rightbtns { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 290px; }
.keys-hint { font-size: 12px; color: #e8eef6; text-align: right; text-shadow: 0 1px 4px rgba(0,0,0,.8); }

#toasts { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 6px 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-b); font-weight: 800; font-size: 18px; animation: toastIn .2s ease-out; white-space: nowrap; }
.toast.warn { color: var(--warn); } .toast.danger { color: #fff; background: rgba(200,30,30,.85); }
.toast.good { color: var(--good); } .toast.level { color: var(--gold); font-size: 26px; }
@keyframes toastIn { from { transform: scale(.7); opacity: 0; } }
#floaters { position: absolute; left: 50%; top: 52%; }
.floater { position: absolute; transform: translateX(-50%); font-weight: 800; font-size: 26px; color: var(--gold); text-shadow: 0 2px 6px rgba(0,0,0,.6); animation: floatUp 1s ease-out forwards; }
@keyframes floatUp { to { transform: translate(-50%, -80px); opacity: 0; } }

#labels { position: absolute; inset: 0; overflow: hidden; }
.vlabel { position: absolute; left: 0; top: 0; padding: 0 8px; border-radius: 8px; font-weight: 800; font-size: 13px; background: rgba(0,0,0,.55); white-space: nowrap; will-change: transform; }
.vlabel.prey { color: var(--good); } .vlabel.threat { color: #ff6b6b; border: 1px solid #ff3b3b; } .vlabel.eq { color: var(--eq); }

@media (pointer: coarse) { .keys-hint { display: none; } }

#bigmap { position: fixed; inset: 0; background: rgba(10,14,22,.8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; z-index: 5; }
.bigmap-head { display: flex; gap: 18px; align-items: baseline; font-size: 14px; color: var(--muted); }
.bigmap-head b { color: #fff; font-size: 20px; }
#bigmap-canvas { border-radius: 16px; border: 2px solid var(--panel-b); }

/* ---------------- Écrans */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(12,18,30,.35), rgba(12,18,30,.75)); z-index: 10; padding: 16px; overflow-y: auto; }
.card { background: rgba(20,28,42,.9); border: 1px solid var(--panel-b); border-radius: 22px; padding: 24px 28px; width: min(480px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 10px; }
.card.wide { width: min(760px, 100%); }
.card h2 { margin: 0; font-size: 30px; }
.card p { margin: 0; color: #d7e0ea; }
.logo { font-weight: 800; font-size: 58px; line-height: .9; letter-spacing: 2px; color: #fff; text-shadow: 0 5px 0 #1d3557, 0 10px 24px rgba(0,0,0,.45); }
.logo span { color: var(--gold); }
.logo i { font-style: normal; color: var(--accent); font-size: 36px; }
.tagline { font-size: 16px; }
.lbl { text-align: left; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: -6px; }
input#name { font: 700 20px 'Baloo 2', sans-serif; padding: 8px 14px; border-radius: 12px; border: 2px solid var(--panel-b); background: rgba(255,255,255,.08); color: #fff; outline: none; text-align: center; }
input#name:focus { border-color: var(--accent); }
#swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.swatch { width: 36px; height: 36px; border-radius: 10px; border: 3px solid transparent; background: var(--c); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.swatch.sel { border-color: #fff; transform: scale(1.1); }
.swatch.locked { opacity: .55; }
.swatch.big { width: 44px; height: 44px; flex: none; cursor: default; }
.btn { font: 800 16px 'Baloo 2', sans-serif; padding: 8px 16px; border-radius: 12px; border: none; cursor: pointer; background: var(--accent); color: #06263a; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.1); } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 24px; padding: 10px; background: linear-gradient(180deg, #ffd54f, #ffb300); color: #3a2500; box-shadow: 0 4px 0 #b27b00; }
.btn.ghost { background: rgba(255,255,255,.1); color: #fff; }
.btn.small { font-size: 14px; padding: 5px 12px; white-space: nowrap; }
.btn.radar { background: rgba(200,30,30,.85); color: #fff; font-size: 15px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fine { font-size: 12px; color: var(--muted) !important; }
.danger { color: var(--bad); }
.keys { text-align: left; border-collapse: collapse; font-size: 15px; }
.keys td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
.keys td:first-child { white-space: nowrap; }
.rules { text-align: left; font-size: 14px; color: #d7e0ea; margin: 0; padding-left: 18px; }
.rules li { margin: 4px 0; }
.g { color: var(--good); } .y { color: var(--eq); } .r { color: var(--bad); }
.tabs { display: flex; gap: 6px; justify-content: center; }
.tab { font: 800 15px 'Baloo 2', sans-serif; padding: 6px 16px; border-radius: 10px; border: none; cursor: pointer; background: rgba(255,255,255,.1); color: #fff; }
.tab.sel { background: var(--accent); color: #06263a; }
.table-wrap { max-height: 50vh; overflow: auto; border-radius: 12px; }
.board-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.board-table th { position: sticky; top: 0; background: #1d2839; text-align: left; padding: 6px 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.board-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.06); }
.board-table tr.mine td { background: rgba(41,182,246,.22); }
.demo { font-size: 10px; color: var(--muted); border: 1px solid var(--muted); border-radius: 4px; padding: 0 3px; }
.shop-item { display: flex; align-items: center; gap: 12px; text-align: left; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.05); margin-bottom: 6px; }
.shop-item > div { flex: 1; }
.shop-item small { color: var(--muted); }
.big-ico { font-size: 30px; width: 44px; text-align: center; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--muted); border-radius: 6px; padding: 2px 8px; }
.ad-box { background: repeating-linear-gradient(45deg, #2a3446, #2a3446 10px, #243043 10px, #243043 20px); border: 2px dashed #5b6b85; border-radius: 12px; padding: 50px 10px; font-weight: 800; font-size: 24px; color: #8fa0bb; }
.ad-box.small { padding: 10px; font-size: 13px; }
.ad-box a { color: var(--accent); }
.go-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.go-stats div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; }
.go-stats b { font-size: 24px; }
.go-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.rank { color: var(--gold) !important; font-weight: 800; }

@media (max-width: 760px) {
  #topright { width: 200px; }
  #board li { grid-template-columns: 20px 1fr 34px; font-size: 12px; }
  #board .sc { display: none; }
  #minimap { width: 130px; height: 130px; }
  #logo-small { display: none; }
  #stats { bottom: auto; top: 190px; flex-direction: column; gap: 4px; }
  .pill { font-size: 15px; }
  .go-stats { grid-template-columns: repeat(2, 1fr); }
  .logo { font-size: 44px; }
}

/* ---------------- v2 additions */
.vlabel.block { color: #ffbf80; }
.floater.loss { color: #ff6b6b; font-size: 20px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
.dot.off { background: var(--warn); }
#tunnel-badge { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); padding: 4px 14px; border-radius: 10px; background: rgba(90,50,160,.85); font-weight: 800; font-size: 15px; white-space: nowrap; }
body.no-ads .ad-slot { display: none; }
.fine a { color: var(--accent); }
.boost { font-weight: 800; font-size: 13px; padding: 1px 12px; border-radius: 10px; background: rgba(0,0,0,.45); color: #ffcc80; }
.boost.on { background: linear-gradient(90deg, #ff6d00, #ffab00); color: #2a1200; box-shadow: 0 0 14px rgba(255,120,0,.8); }
#tunnel-badge { text-align: center; }
#tunnel-badge .bar.thin { width: 240px; margin: 4px auto 0; background: rgba(255,255,255,.2); }
#tunnel-fill { height: 100%; width: 0; background: linear-gradient(90deg, #b388ff, #fff); }

/* ---------------- accounts */
.acct-bar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
.badge { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--good); color: #06341a; }
.hint { text-transform: none; letter-spacing: 0; color: var(--gold); }
.form { display: flex; flex-direction: column; gap: 8px; }
.form input { font: 700 16px 'Baloo 2', sans-serif; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--panel-b); background: rgba(255,255,255,.08); color: #fff; outline: none; }
.form input:focus { border-color: var(--accent); }
.fine.err { color: #ff8a80 !important; }
.fine.ok { color: var(--good) !important; }
.fine:empty { display: none; }
input#name:disabled { opacity: .85; border-color: var(--good); }
.go-stats.six { grid-template-columns: repeat(3, 1fr); }
h3.sub { margin: 6px 0 0; font-size: 16px; text-align: left; color: var(--muted); }
body.no-ads .ad-note { display: none; }

.verified { color: var(--good); font-weight: 800; }

/* ---------------- mobile : gestes */
#touchpad { position: fixed; inset: 0; z-index: 1; touch-action: none; -webkit-user-select: none; }
#hud { z-index: 2; }
.edge-hint { position: absolute; top: 50%; transform: translateY(-50%); font-size: 64px; font-weight: 800; color: rgba(255,255,255,.14); pointer-events: none; }
.edge-hint.left { left: 6px; } .edge-hint.right { right: 6px; }
#touch-help-btn { position: fixed; z-index: 3; right: 10px; bottom: 58px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(0,0,0,.35); color: #fff; font: 800 18px 'Baloo 2', sans-serif; }
#touch-help { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(8,12,20,.72); padding: 16px; }
.th-card { background: rgba(20,28,42,.95); border: 1px solid var(--panel-b); border-radius: 18px; padding: 16px; max-width: 420px; text-align: center; }
.th-card h3 { margin: 0 0 10px; font-size: 22px; }
.th-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.th-grid div { background: rgba(255,255,255,.06); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.th-grid b { font-size: 15px; } .th-grid span { font-size: 12px; color: var(--muted); }
#board-toggle { cursor: pointer; pointer-events: auto; user-select: none; }
#board-toggle .chev { display: none; }

/* ---------------- mobile : mise en page (petit écran ou écran tactile) */
@media (max-width: 820px), (pointer: coarse) {
  #topleft { left: 8px; top: 8px; padding: 4px; border-radius: 10px; }
  #minimap { width: 92px; height: 92px; border-radius: 8px; }
  #district, #road, #logo-small, .keys-hint { display: none; }
  #topright { right: 8px; top: 8px; width: 190px; gap: 4px; }
  .pill { display: none; }
  #board { padding: 4px 8px; }
  #board h3 { font-size: 12px; margin: 0; text-align: left; }
  #board-toggle .chev { display: inline; }
  #board ol { font-size: 12px; }
  #board li { grid-template-columns: 22px 1fr 32px 48px; padding: 0 4px; }
  #board:not(.open) li:not(.me), #board:not(.open) #online { display: none; }
  #stats { top: 110px; bottom: auto; left: 8px; transform: none; padding: 4px 8px; gap: 3px; flex-direction: column; border-radius: 10px; min-width: 70px; }
  #stats div { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 6px; }
  #stats span { font-size: 9px; }
  #stats b { font-size: 14px; }
  .coin { width: 11px; height: 11px; }
  #bottom { bottom: 8px; width: min(260px, 70vw); gap: 2px; }
  #speedo b { font-size: 24px; }
  #speedo span { font-size: 11px; }
  .bar.thin { width: 120px; }
  #tierbox { padding: 3px 8px 2px; border-radius: 10px; }
  #tier-name { font-size: 12px; }
  #tier-sub { display: none; }
  .bar { height: 7px; margin: 2px 0; }
  .intent { font-size: 13px; min-height: 18px; }
  .boost { font-size: 10px; }
  #protect { font-size: 11px; }
  #rightbtns { right: 8px; bottom: 8px; }
  .btn.radar { font-size: 0; padding: 0; width: 40px; height: 40px; border-radius: 50%; }
  .btn.radar::before { content: '📡'; font-size: 20px; }
  .btn.radar kbd { display: none; }
  #radar-panel { font-size: 11px; padding: 4px 8px; }
  #toasts { top: 20%; }
  .toast { font-size: 13px; padding: 4px 12px; white-space: normal; text-align: center; max-width: 86vw; }
  .toast.level { font-size: 18px; }
  .vlabel { font-size: 10px; padding: 0 5px; }
  #tunnel-badge { top: 44px; font-size: 12px; }
  .floater { font-size: 18px; }
}

.manage { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.purchase { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.05); font-size: 14px; flex-wrap: wrap; }
#me-delete summary { cursor: pointer; color: #ff8a80; font-weight: 700; font-size: 14px; }
#me-delete .form { margin-top: 6px; }
.btn.danger-btn { background: #c62828; color: #fff; }
