:root {
  --bg: #0b1020;
  --panel: #141b33;
  --panel-2: #1c2547;
  --line: #2b3666;
  --text: #f2f5ff;
  --muted: #9aa6cf;
  --volt: #ffd400;
  --volt-ink: #2a2100;
  --blue: #00a2e9;
  --ok: #3ddc84;
  --err: #ff6b6b;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; touch-action: pan-y; z-index: 20; }
#start { background: radial-gradient(ellipse at 50% 30%, rgba(0,162,233,.25), transparent 60%), rgba(5,8,18,.72); }
.card { position: relative; width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; margin: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--blue); }
.logo-badge { height: 48px; width: auto; }
.title { margin: 0; font-size: 34px; line-height: 1.05; font-weight: 900; letter-spacing: -.01em; color: var(--volt); text-shadow: 0 0 24px rgba(255,212,0,.35); }
h2 { margin: 4px 0 0; font-size: 19px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; line-height: 1.4; }
.right { text-align: right; }
.err { color: var(--err); margin: 0; min-height: 1em; }
.ok { color: var(--ok); margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; }
input, select { font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; user-select: text; -webkit-user-select: text; }
input:focus, select:focus { outline: 2px solid var(--blue); border-color: transparent; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; font-size: 12.5px; line-height: 1.45; }
label.check input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--volt); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn { font: inherit; font-weight: 800; font-size: 15px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 12px; padding: 12px 16px; cursor: pointer; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--volt); color: var(--volt-ink); border-color: var(--volt); box-shadow: 0 4px 0 #b39500; }
.btn.primary:active { box-shadow: 0 1px 0 #b39500; transform: translateY(3px); }
.btn.ghost { background: transparent; }
.btn.big { font-size: 20px; padding: 15px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.chip { position: absolute; top: 14px; right: 14px; font: inherit; font-weight: 800; font-size: 12px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; cursor: pointer; }

.colors { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.colors button { width: 38px; height: 38px; border-radius: 10px; border: 3px solid transparent; cursor: pointer; }
.colors button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--volt); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 6px; align-items: center; }
.spacer { flex: 1; }
.pill { background: rgba(10,14,30,.75); border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 13px; white-space: nowrap; backdrop-filter: blur(4px); }
.btn-pill { pointer-events: auto; color: var(--text); font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; }
#hudTime.warn { color: var(--err); }
.hint { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); text-align: center; background: rgba(10,14,30,.8); border: 1px solid var(--volt); color: var(--volt); padding: 8px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; }
.act-btn { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); pointer-events: auto; font-size: 18px; padding: 14px 26px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 4px 0 #b39500, 0 0 26px rgba(255,212,0,.7); } }
.switch-bar { position: absolute; left: 50%; top: 100px; width: min(320px, 80%); height: 16px; transform: translateX(-50%); background: rgba(10,14,30,.8); border: 2px solid var(--volt); border-radius: 999px; overflow: hidden; }
.switch-bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--volt), #fff6a8); transition: width .1s linear; }

#touch { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; left: 0; bottom: 0; width: 140px; height: 140px; margin: 0 0 max(24px, env(safe-area-inset-bottom)) 24px; border-radius: 50%; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.18); pointer-events: none; opacity: .9; }
.knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255,255,255,.3); }
.round-btn { position: absolute; pointer-events: auto; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(255,212,0,.85); color: var(--volt-ink); font-size: 34px; font-weight: 900; touch-action: none; }
.round-btn.jump { right: 26px; bottom: max(34px, env(safe-area-inset-bottom)); width: 86px; height: 86px; }
.round-btn:active { transform: scale(.94); }

/* Dialog */
#dialog { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px; z-index: 30; display: flex; justify-content: center; }
.dialog-box { width: 100%; max-width: 640px; background: rgba(12,16,34,.95); border: 2px solid var(--blue); border-radius: 16px; padding: 14px 16px; cursor: pointer; animation: rise .25s ease-out; }
.speaker { font-weight: 900; color: var(--blue); font-size: 14px; letter-spacing: .04em; }
.speaker.volta { color: var(--volt); }
.dlg-text { font-size: 17px; line-height: 1.45; margin: 6px 0 4px; min-height: 2.9em; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }

/* Mini game */
#mg { background: rgba(5,8,18,.82); z-index: 25; }
.mg-card { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; margin: auto; }
.mg-head { display: flex; align-items: center; gap: 10px; }
.mg-head > div:first-child { flex: 1; min-width: 0; }
.mg-head h2 { margin: 0; font-size: 22px; color: var(--volt); }
.mg-sector { font-size: 12px; font-weight: 800; color: var(--blue); letter-spacing: .08em; text-transform: uppercase; }
.mg-help { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.mg-body { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mg-body canvas { width: 100%; max-width: 520px; border-radius: 12px; background: #070b18; touch-action: none; }
.mg-result { text-align: center; padding: 8px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.mg-result .big { font-size: 28px; font-weight: 900; }
.stars { font-size: 26px; letter-spacing: 4px; color: var(--volt); }
.mg-msg { min-height: 1.3em; color: var(--err); font-weight: 700; font-size: 14px; text-align: center; }

/* Kabel */
.grid-k { display: grid; gap: 4px; width: min(100%, 420px); position: relative; }
.tile { aspect-ratio: 1; background: #0c1330; border: 1px solid var(--line); border-radius: 8px; padding: 0; cursor: pointer; touch-action: manipulation; }
.tile svg { width: 100%; height: 100%; transition: transform .15s; display: block; }
.tile.on { background: #2a2600; border-color: var(--volt); }
.k-wrap { display: flex; align-items: center; gap: 6px; width: 100%; justify-content: center; }
.k-end { font-size: 28px; width: 34px; text-align: center; }

/* Turbin */
.tap-btn { width: 100%; max-width: 360px; font-size: 26px; padding: 22px; }

/* Server */
.srv-wrap { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.prog { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; width: 100%; max-width: 440px; padding: 6px; border: 1px dashed var(--line); border-radius: 10px; }
.prog span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 14px; font-weight: 700; }
.prog span.cur { border-color: var(--volt); color: var(--volt); }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; max-width: 440px; }
.palette .btn { padding: 11px 4px; font-size: 14px; }

/* Akhir */
#end { background: rgba(5,8,18,.85); align-items: flex-start; }
.end-card { max-width: 480px; }
.score-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; background: var(--panel-2); border-radius: 14px; padding: 14px; }
.big-num { font-size: 36px; font-weight: 900; color: var(--volt); }
.match { font-size: 20px; font-weight: 900; margin-top: 4px; }
#leadForm { display: flex; flex-direction: column; gap: 11px; }
.card-img { width: 100%; max-width: 260px; align-self: center; border-radius: 14px; border: 1px solid var(--line); }
#sharePanel { display: flex; flex-direction: column; gap: 10px; }
.share-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.share-btns .btn { padding: 12px 6px; font-size: 14px; }

#toasts { position: fixed; top: 60px; right: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 40; pointer-events: none; max-width: 70%; }
.toast { background: rgba(10,14,30,.9); border-left: 3px solid var(--volt); padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; animation: rise .25s ease-out; }
#fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 50; transition: opacity .6s; }

@media (pointer: coarse) {
  .act-btn { bottom: calc(190px + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) {
  .title { font-size: 28px; }
  .dlg-text { font-size: 15px; }
  .hud-top { flex-wrap: wrap; gap: 4px; }
  .pill { padding: 5px 8px; font-size: 11.5px; }
  .hint { top: 84px; font-size: 13px; }
  .switch-bar { top: 128px; }
}
