* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd3f0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #f4f6fa; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#c:active { cursor: grabbing; }
.hidden { display: none !important; }

.panel { background: rgba(16, 20, 28, 0.72); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0,0,0,0.25); }
#hud { position: fixed; inset: 0; pointer-events: none; }

#levelinfo { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 18px; text-align: center; min-width: 300px; }
.lvl-name { font-weight: 700; font-size: 15px; letter-spacing: .3px; margin-bottom: 4px; }
.stats { display: flex; gap: 18px; justify-content: center; font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }
.stats .lbl { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; font-weight: 500; }

#hud.cab #levelinfo { left: 14px; top: 14px; transform: none; min-width: 0; }
#camlabel { position: absolute; left: 14px; bottom: 14px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
#toggles { position: absolute; left: 14px; bottom: 52px; font-size: 11px; opacity: .85; text-shadow: 0 1px 2px #000; white-space: pre; }

#dash { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; padding: 8px 16px; align-items: flex-end; }
.gauge { display: flex; flex-direction: column; align-items: center; min-width: 74px; }
.gauge .big { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.gauge .lbl { font-size: 11px; opacity: .7; margin-top: 2px; white-space: nowrap; }
.gear { color: #7dd3fc; }
.gear.rev { color: #ffb02e; }

#minimap { position: absolute; right: 14px; bottom: 14px; width: 230px; height: 230px; }

#msg { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) scale(.8); font-size: 40px; font-weight: 900; opacity: 0; transition: opacity .2s, transform .2s; text-shadow: 0 3px 12px rgba(0,0,0,.5); white-space: nowrap; }
#msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#msg.bad { color: #ff5a5a; }
#msg.good { color: #5dff8a; }
#msg.info { color: #fff; }

#goalbar { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); width: 260px; height: 26px; border-radius: 13px; background: rgba(0,0,0,.55); overflow: hidden; opacity: 0; transition: opacity .2s; }
#goalbar.show { opacity: 1; }
#goalfill { height: 100%; width: 0; background: linear-gradient(90deg, #2ecc71, #a3ff6b); }
#goalbar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10, 20, 30, 0.55); backdrop-filter: blur(3px); padding: 16px; overflow: auto; }
.card { background: rgba(18, 24, 34, 0.94); border-radius: 18px; padding: 26px 30px; max-width: 520px; width: 100%; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.card.wide { max-width: 860px; }
h1 { margin: 0 0 6px; font-size: 34px; }
h1 .sub { font-size: 16px; font-weight: 500; opacity: .7; margin-left: 6px; }
h2 { margin: 18px 0 8px; font-size: 18px; }
.intro { opacity: .8; line-height: 1.5; margin: 0 0 18px; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.lvl { background: linear-gradient(160deg, #2f5d8a, #1d3b5c); border-radius: 12px; padding: 12px 14px; cursor: pointer; border: 2px solid transparent; transition: transform .1s, border-color .1s; text-align: left; color: #fff; font: inherit; }
.lvl:hover { transform: translateY(-2px); border-color: #ffd400; }
.lvl .n { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.lvl { min-width: 0; }
.lvl .t { font-size: clamp(14px, 1.5vw, 17px); font-weight: 800; margin: 2px 0 4px; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; line-height: 1.2; }
.lvl .d { font-size: 12px; opacity: .85; line-height: 1.35; min-height: 48px; }
.lvl .b { font-size: 12px; margin-top: 6px; font-weight: 700; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
button { font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: 10px 18px; background: #ffd400; color: #1a1a1a; cursor: pointer; }
button.ghost { background: rgba(255,255,255,0.1); color: #fff; }
button:hover { filter: brightness(1.1); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
table { border-collapse: collapse; font-size: 13px; width: 100%; }
td { padding: 4px 6px; vertical-align: top; }
td:first-child { white-space: nowrap; }
kbd { background: rgba(255,255,255,.14); border-radius: 5px; padding: 1px 6px; font-size: 12px; border-bottom: 2px solid rgba(255,255,255,.2); }
.tips { line-height: 1.55; font-size: 14px; padding-left: 20px; margin: 0; }
.result-title { font-size: 42px; font-weight: 900; text-align: center; color: #ffd400; }
.result-body { text-align: center; font-size: 16px; line-height: 1.7; margin-top: 8px; }
.result-body b { font-size: 22px; }
@media (max-width: 1100px) {
  #levelinfo { top: calc(13.5vw + 44px); min-width: 0; }
  #minimap { width: 150px; height: 150px; bottom: 130px; }
  #toggles { display: none; }
}
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } #dash { transform: translateX(-50%) scale(.75); transform-origin: bottom center; } #camlabel { bottom: 120px; } }

/* Spelare & topplistor */
.player { margin: -6px 0 14px; opacity: .9; }
button.link { background: none; color: #ffd400; padding: 0 4px; font-weight: 600; text-decoration: underline; }
.lvl .rec { font-size: 12px; margin-top: 4px; color: #ffd400; font-weight: 700; overflow-wrap: anywhere; }
.card.narrow { max-width: 380px; }
#nameInput { width: 100%; font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; outline: none; }
#nameInput:focus { border-color: #ffd400; }
.result-rank { text-align: center; margin-top: 10px; font-weight: 700; color: #ffd400; min-height: 1.4em; }
.board-wrap { margin-top: 8px; max-height: 300px; overflow: auto; }
table.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.board td { padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,.07); }
table.board td:first-child { width: 2.5em; text-align: center; }
table.board td:nth-child(3), table.board td:nth-child(4) { text-align: right; white-space: nowrap; opacity: .9; }
table.board td:nth-child(2) { overflow-wrap: anywhere; }
table.board tr.me td { background: rgba(255,212,0,.16); font-weight: 700; }
.board-empty { opacity: .7; padding: 10px 0; text-align: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.tabs button { padding: 6px 12px; font-size: 13px; background: rgba(255,255,255,.1); color: #fff; }
.tabs button.on { background: #ffd400; color: #1a1a1a; }
