:root {
  --bg: #0f1220;
  --panel: #181c30;
  --panel2: #20253d;
  --text: #e8ebf7;
  --muted: #8b93b5;
  --accent: #ffc531;
  --discord: #5865f2;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--muted); }
.small { font-size: 12px; color: var(--muted); }

header { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--panel); height: 48px; }
#timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 20px; min-width: 62px; }
#roundNr { color: var(--muted); font-size: 14px; min-width: 70px; text-align: right; }
#scoreBar { flex: 1; display: flex; height: 22px; border-radius: 11px; overflow: hidden; background: var(--panel2); }
#scoreBar div { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  color: rgba(0,0,0,.65); transition: width .6s ease; min-width: 0; overflow: hidden; }

main { display: flex; height: calc(100% - 48px); }
#stage { flex: 1; position: relative; min-width: 0; }
#board { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
aside { width: 290px; padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; background: var(--bg); }
.panel { background: var(--panel); border-radius: 12px; padding: 12px; }
.panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar { height: 12px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
#energyFill { height: 100%; width: 100%; background: linear-gradient(90deg, #ffc531, #ff8a3d); transition: width .1s linear; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #231a00; font-weight: 700; }
button:disabled { opacity: .4; cursor: not-allowed; }
#rallyBtn { width: 100%; margin-top: 10px; background: var(--panel2); color: var(--text); font-weight: 600; }
#rallyBtn:hover { background: #2a3050; }

/* profiel */
.meHead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.meHead > div { flex: 1; min-width: 0; }
.meHead b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meHead img { border-radius: 50%; }
.lvl { background: var(--accent); color: #231a00; font-weight: 800; font-size: 12px; padding: 3px 8px; border-radius: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; margin-bottom: 8px; }
.stats div { background: var(--panel2); border-radius: 8px; padding: 6px 2px; }
.stats b { display: block; font-size: 18px; }
.stats span { font-size: 10px; color: var(--muted); }

.discord { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--discord); color: #fff;
  text-decoration: none; font-weight: 700; padding: 12px; border-radius: 10px; }
.discord:hover { filter: brightness(1.1); }
.small-btn { font-size: 12px; padding: 8px; margin-bottom: 6px; }

#topList { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.7; }
#topList li span.n { font-weight: 600; }
#topList li span.c { float: right; color: var(--muted); }
#topList li.me { background: var(--panel2); border-radius: 6px; margin-left: -6px; padding-left: 6px; padding-right: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex: none; }
#meDot { width: 14px; height: 14px; margin: 0; }
.rank { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 8px; }

.chat { display: flex; flex-direction: column; flex: 1; min-height: 160px; }
#chatLog { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.5; margin-bottom: 8px; min-height: 80px; }
#chatLog .sys { color: var(--muted); font-style: italic; }
#chatLog b { font-weight: 700; }
#chatInput { width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: var(--panel2); color: var(--text); font: inherit; }

.overlay { position: fixed; inset: 0; background: rgba(8,10,20,.85); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; backdrop-filter: blur(4px); }
.card { background: var(--panel); border-radius: 18px; padding: 28px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h1 { margin: 0 0 4px; font-size: 38px; letter-spacing: -.02em; }
.card h1 span { color: var(--accent); }
.card h2 { margin: 0 0 8px; font-size: 28px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
#loginBox { margin-bottom: 14px; }
#loggedIn { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--panel2); border-radius: 12px; padding: 10px 12px; }
#loggedIn > div { flex: 1; min-width: 0; }
#loggedIn img { border-radius: 50%; }
#nameInput { width: 100%; padding: 12px; font-size: 16px; border-radius: 10px; border: 2px solid var(--panel2); background: var(--bg); color: var(--text); margin-bottom: 14px; text-align: center; }
#nameInput:focus { outline: none; border-color: var(--accent); }
#teamPick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.teamBtn { padding: 14px 8px; border-radius: 12px; border: 3px solid transparent; color: rgba(0,0,0,.75); font-weight: 800; font-size: 16px; }
.teamBtn small { display: block; font-weight: 600; opacity: .7; font-size: 11px; }
.teamBtn.sel { border-color: #fff; transform: scale(1.04); }
#joinBtn { width: 100%; font-size: 16px; padding: 14px; }

#toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 8px 14px;
  border-radius: 20px; font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

button.ghost { background: var(--panel2); color: var(--text); font-weight: 600; width: 100%; margin-top: 6px; }
button.ghost:hover { background: #2a3050; }

/* leaderboard */
.card h2 .ic { color: var(--accent); width: 1.1em; height: 1.1em; margin-right: 10px; }
#lbList { max-height: 50vh; overflow-y: auto; margin-bottom: 8px; text-align: left; }
.lbHead, .lbRow { display: grid; grid-template-columns: 44px 1fr 64px 64px 56px; gap: 8px; align-items: center; padding: 8px 10px; font-size: 14px; }
.lbHead { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0; background: var(--panel); }
.lbRow { border-radius: 8px; }
.lbRow:nth-child(odd) { background: rgba(255,255,255,.03); }
.lbRow.me { background: var(--panel2); outline: 1px solid var(--accent); }
.lbRow .rk { font-weight: 800; color: var(--muted); }
.lbRow.r1 .rk { color: #ffc531; } .lbRow.r2 .rk { color: #c9d1e6; } .lbRow.r3 .rk { color: #d98c52; }
.lbRow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lbRow .nm small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.lbRow .w { font-weight: 800; color: var(--accent); text-align: right; }
.lbHead span:nth-child(n+3), .lbRow .p, .lbRow .l { text-align: right; }
.lbRow .p, .lbRow .l { color: var(--muted); }
.lbEmpty { padding: 24px 10px; color: var(--muted); text-align: center; }
@media (max-width: 520px) { .lbHead, .lbRow { grid-template-columns: 36px 1fr 52px 44px; } .lbHead span:nth-child(5), .lbRow .l { display: none; } }

/* eigen outline-iconen */
.ic { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.22em; flex: none; margin-right: 0.4em; }
.iconBtn .ic, #botList .bot button .ic, .skinCard small .ic { margin-right: 0; }
.skinCard small .ic { margin-right: 3px; width: 1.1em; height: 1.1em; }
.coins .ic { color: var(--accent); }
.sub .ic { color: var(--accent); margin-left: 2px; }
.upCard h4 { display: flex; align-items: center; }
.upCard h4 .ic { color: var(--accent); width: 1.3em; height: 1.3em; margin-right: 8px; }
.iconBtn { background: transparent; color: var(--muted); padding: 4px 8px; font-size: 16px; font-weight: 400; }
.iconBtn:hover { color: var(--text); background: var(--panel2); }
#renameInput { width: 100%; padding: 4px 8px; border-radius: 6px; border: 2px solid var(--accent); background: var(--bg); color: var(--text); font: inherit; font-weight: 700; }
#renameInput:focus { outline: none; }
#nameHint { margin: -6px 0 12px; }
.coins { font-size: 14px; margin: 2px 0 6px; }
.coins b { color: var(--accent); }
#upGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 8px; text-align: left; }
.upCard { background: var(--panel2); border-radius: 12px; padding: 14px; }
.upCard h4 { margin: 0 0 2px; font-size: 16px; }
.upCard .small { display: block; margin-bottom: 8px; }
.upCard .pips { display: flex; gap: 3px; margin-bottom: 8px; }
.upCard .pips i { flex: 1; height: 8px; border-radius: 4px; background: var(--bg); }
.upCard .pips i.on { background: linear-gradient(90deg, #ffc531, #ff8a3d); }
.upCard .now { font-size: 13px; margin-bottom: 10px; color: var(--muted); }
.upCard .now b { color: var(--text); }
.upCard button { width: 100%; }

button.tiny { font-size: 11px; padding: 5px 8px; font-weight: 500; opacity: .6; }
button.tiny:hover { opacity: 1; }

/* zoom */
#zoomBtns { position: absolute; right: 12px; bottom: 36px; display: flex; flex-direction: column; gap: 6px; }
#zoomBtns .ic { margin: 0; width: 20px; height: 20px; vertical-align: middle; }
#zoomBtns button { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; font-size: 20px; background: rgba(24,28,48,.9); color: var(--text); border: 1px solid var(--panel2); }
#zoomBtns button:hover { background: var(--panel2); }
#zoomHint { position: absolute; left: 12px; bottom: 8px; font-size: 11px; color: var(--muted); pointer-events: none; opacity: .8; }
#board.panning { cursor: grabbing; }

/* skins */
.card.wide { max-width: 640px; }
#skinGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 8px; max-height: 55vh; overflow-y: auto; }
.skinCard { background: var(--panel2); border: 3px solid transparent; border-radius: 12px; padding: 10px 6px; cursor: pointer; text-align: center; color: var(--text); font-weight: 600; font-size: 14px; }
.skinCard canvas { display: block; margin: 0 auto 6px; width: 60px; height: 60px; border-radius: 6px; background: #1b2038; }
.skinCard small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; margin-top: 2px; }
.skinCard.sel { border-color: var(--accent); }
.skinCard.locked { opacity: .5; cursor: not-allowed; }

/* admin */
.adminRow { display: flex; gap: 6px; margin-bottom: 8px; }
.adminRow input { width: 56px; padding: 8px; border-radius: 8px; border: 0; background: var(--panel2); color: var(--text); font: inherit; }
.adminRow button { flex: 1; padding: 8px; }
.adminRow input { width: 80px; }
.adminNote { margin: -2px 0 10px; line-height: 1.4; }
.adminNote b { color: var(--accent); }
.adminNote a { color: var(--muted); cursor: pointer; text-decoration: underline; }
.panel h3.sep { margin-top: 14px; }
#botSpeed { width: 100%; margin: 4px 0 8px; }
#botList { max-height: 150px; overflow-y: auto; font-size: 13px; margin-bottom: 4px; }
#botList .bot { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#botList .bot span.n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#botList .bot span.c { color: var(--muted); }
#botList .bot button { padding: 0 8px; background: transparent; color: var(--muted); font-size: 16px; }
#botList .bot button:hover { color: #ff4d5e; }
#botList .bot button:first-of-type:hover { color: var(--accent); }
#botList .bot.off span { opacity: .45; }

@media (max-width: 760px) {
  main { flex-direction: column; }
  aside { width: 100%; flex-direction: row; overflow-x: auto; max-height: 190px; }
  aside .panel { min-width: 230px; }
  #roundNr { display: none; }
}
