:root {
  --bg: #03050c;
  --glass: rgba(10, 15, 32, 0.85);
  --line: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #fb7185;
  --pink: #f0abfc;
  --amber: #fcd34d;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 14px;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  user-select: none;
  background:
    radial-gradient(circle at 18% 15%, rgba(6, 182, 212, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 82% 20%, rgba(16, 185, 129, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(244, 63, 94, 0.1) 0%, transparent 55%),
    var(--bg);
}
body > * { max-width: 1280px; margin-left: auto; margin-right: auto; }
.mono { font-family: var(--mono); }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
button, select { font: inherit; color: inherit; cursor: pointer; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; }
.brand h1 { margin: 2px 0 0; font-size: 22px; font-weight: 800; background: linear-gradient(90deg, #fff, #a5f3fc, #6ee7b7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 2px 10px; border-radius: 99px; }
.chip.cyan { color: #67e8f9; background: rgba(6, 182, 212, .18); border: 1px solid rgba(6, 182, 212, .4); }
.chip.green { color: #6ee7b7; background: rgba(16, 185, 129, .14); border: 1px solid rgba(16, 185, 129, .3); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: rgba(2, 6, 23, .9); border: 1px solid rgba(51, 65, 85, .8); font: 700 11px var(--mono); text-transform: uppercase; color: var(--muted); }
.field select { background: transparent; border: 0; color: #67e8f9; font: 700 13px var(--mono); text-transform: none; outline: none; }
.field select option { background: #0f172a; }
.seg { padding: 3px; gap: 3px; }
.seg button { border: 1px solid transparent; background: none; padding: 4px 10px; border-radius: 8px; font: 700 12px var(--mono); color: var(--muted); }
.seg button.on { color: #67e8f9; background: rgba(6, 182, 212, .22); border-color: rgba(6, 182, 212, .4); }
.toggle { padding: 7px 12px; border-radius: 10px; font: 800 12px var(--mono); background: rgba(2, 6, 23, .95); border: 1px solid rgba(217, 70, 239, .45); color: #f0abfc; }
.toggle[aria-pressed="false"] { color: var(--muted); border-color: rgba(71, 85, 105, .6); text-decoration: line-through; }
.go { padding: 8px 16px; border: 0; border-radius: 10px; font: 800 13px var(--mono); text-transform: uppercase; color: #020617; background: linear-gradient(135deg, #06b6d4, #10b981); box-shadow: 0 4px 0 #064e3b; }
.go:active { transform: translateY(3px); box-shadow: 0 1px 0 #064e3b; }
.ghost { padding: 8px 12px; border-radius: 10px; background: #1e293b; border: 1px solid #475569; font: 700 12px var(--mono); }
.next { padding: 8px 16px; border: 0; border-radius: 10px; font: 800 13px var(--mono); text-transform: uppercase; color: #020617; background: #d946ef; }

.status { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 12px; margin-bottom: 12px; }
.pill-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; font-size: 12px; }
.pill-row.left { border-left: 4px solid var(--cyan); }
.pill-row.right { border-right: 4px solid var(--green); }
.lbl { text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: #cbd5e1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 10px #f43f5e; }
.red { color: var(--red); padding: 3px 10px; border-radius: 8px; background: rgba(244, 63, 94, .18); border: 1px solid rgba(251, 113, 133, .4); }
.pink { color: var(--pink); }
.banner { display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 14px; font-weight: 800; font-size: 13px; color: var(--amber); }
.banner.win { color: #6ee7b7; } .banner.lose { color: var(--red); } .banner.live { color: #67e8f9; }

.arenas { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 14px; }
.card { border-radius: 16px; overflow: hidden; background: #050814; border: 2px solid; display: flex; flex-direction: column; }
.card.you { border-color: rgba(6, 182, 212, .5); box-shadow: 0 16px 40px -10px rgba(6, 182, 212, .25); }
.card.bot { border-color: rgba(16, 185, 129, .5); box-shadow: 0 16px 40px -10px rgba(16, 185, 129, .25); }
.card-head, .card-foot { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; background: rgba(2, 6, 23, .92); font-size: 12px; }
.card-head { border-bottom: 1px solid #1e293b; }
.card-foot { border-top: 1px solid #1e293b; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.card h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .04em; display: flex; align-items: center; gap: 9px; }
.card.you h2 { color: #67e8f9; } .card.bot h2 { color: #6ee7b7; }
.card h2 small { font: 700 10px var(--mono); color: var(--muted); letter-spacing: 0; }
.gem { width: 11px; height: 11px; transform: rotate(45deg); display: inline-block; }
.gem.cyan { background: var(--cyan); } .gem.green { background: var(--green); }
.score { color: var(--muted); } .score b { color: #fff; }
.canvas-wrap { position: relative; height: clamp(320px, 52vh, 520px); background: radial-gradient(circle, #0a1124, #040711); }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.hud { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; font-size: 11px; }
.hud > span { padding: 4px 9px; border-radius: 8px; background: rgba(2, 6, 23, .85); border: 1px solid rgba(51, 65, 85, .8); color: #cbd5e1; }
.cyan-t { color: var(--cyan); } .green-t { color: var(--green); }
.hud .queued { color: var(--red); background: rgba(244, 63, 94, .22); border-color: rgba(251, 113, 133, .6); font-weight: 700; }
.hud .loop { color: #a7f3d0; background: rgba(16, 185, 129, .18); border-color: rgba(52, 211, 153, .4); }
.overlay { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; background: rgba(2, 6, 23, .86); backdrop-filter: blur(6px); }
.overlay[hidden], [hidden] { display: none !important; }
.ov-title { font-size: 28px; font-weight: 800; color: #67e8f9; margin-bottom: 6px; }
.ov-title.lose { color: var(--red); }
.overlay p { font-size: 13px; color: #cbd5e1; max-width: 420px; margin: 0 0 18px; }
.ov-btns { display: flex; gap: 10px; }

.bottom { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.pad-box, .code-box { padding: 14px 16px; }
.pad-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #67e8f9; margin-bottom: 8px; }
.dpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 220px; margin: 0 auto; }
.dpad button { height: 50px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; background: linear-gradient(145deg, #162038, #090e1a); border: 1px solid rgba(56, 189, 248, .28); box-shadow: 0 4px 0 #02040a; }
.dpad button small { font: 9px var(--mono); color: var(--muted); }
.dpad button:active, .dpad button.pressed { transform: translateY(3px); box-shadow: 0 1px 0 #02040a; border-color: #f43f5e; color: #f43f5e; }
.tip { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 12px 0 0; }
.tip.lock { color: var(--amber); }
.code { margin: 0; padding: 12px; border-radius: 10px; background: rgba(2, 6, 23, .9); border: 1px solid #1e293b; font-size: 13px; line-height: 1.55; color: #cbd5e1; white-space: pre; overflow-x: auto; }
.code span { display: inline-block; min-width: 100%; border-left: 3px solid transparent; padding-left: 6px; border-radius: 4px; }
.code span.active { background: rgba(16, 185, 129, .2); border-left-color: #10b981; color: #ecfdf5; font-weight: 700; }

@media (max-width: 900px) {
  .status, .arenas, .bottom { grid-template-columns: 1fr; }
}
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-6px, 4px); } 40% { transform: translate(6px, -5px); } 60% { transform: translate(-5px, -3px); } 80% { transform: translate(5px, 4px); } }
.shake { animation: shake .38s both; }
