:root {
  --bg-0: #050b16;
  --bg-1: #0a1224;
  --bg-2: #0e1b33;
  --card: rgba(16, 27, 47, 0.72);
  --card-border: rgba(120, 171, 255, 0.22);
  --text: #eaf2ff;
  --muted: #adc2e8;
  --azure: #2490ff;
  --azure-2: #00bcf2;
  --ok: #3ddc97;
  --warn: #ffbf5f;
  --err: #ff7e7e;
}

* { box-sizing: border-box; }
body {
  font-family: Inter, Segoe UI, Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(36, 144, 255, 0.22), transparent 60%),
    radial-gradient(800px 500px at 88% -10%, rgba(0, 188, 242, 0.16), transparent 58%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 35%, var(--bg-2));
}

header, main, footer { max-width: 1180px; margin: 0 auto; padding: 22px; }

h1 { margin: 0 0 8px; letter-spacing: 0.2px; }
h1 span {
  font-size: 0.5em;
  background: linear-gradient(90deg, var(--azure), var(--azure-2));
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
}
p, small { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}
.card:hover { border-color: rgba(143, 188, 255, 0.45); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #d6e7ff; }

input, select, button, textarea {
  border-radius: 10px;
  border: 1px solid #35517f;
  background: rgba(8, 16, 32, 0.9);
  color: var(--text);
  padding: 10px;
}

button {
  cursor: pointer;
  border: none;
  margin: 10px 8px 0 0;
  background: linear-gradient(90deg, #1573ff, #00a4ef);
  color: #fff;
  font-weight: 600;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); }

.result {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.2em;
  padding: 12px;
  background: rgba(6, 13, 26, 0.8);
  border: 1px dashed #4f77ba;
  border-radius: 10px;
  margin-bottom: 8px;
  word-break: break-all;
}

ul { margin: 0; padding-left: 20px; }
li.ok { color: var(--ok); }
li.warn { color: var(--warn); }
li.err { color: var(--err); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  border-bottom: 1px solid rgba(94, 129, 184, 0.34);
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

pre {
  background: rgba(6, 13, 26, 0.85);
  border: 1px solid #2f4a77;
  border-radius: 10px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
}

a { color: #7dc3ff; }
footer { opacity: 0.98; padding-bottom: 40px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 20, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.hidden { display: none !important; }
.overlay-card {
  width: min(90vw, 900px);
  background: #0d1830;
  border: 1px solid #3a5e97;
  border-radius: 14px;
  padding: 16px;
}
#runnerCanvas {
  width: 100%;
  max-width: 820px;
  background: #091223;
  border: 1px solid #2f4d7e;
  border-radius: 10px;
  display: block;
  margin-top: 10px;
  image-rendering: pixelated;
}
.overlay-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.highscores {
  margin-top: 12px;
  background: rgba(6, 12, 24, 0.82);
  border: 1px solid #2e476f;
  border-radius: 10px;
  padding: 10px;
}
.highscores h3 { margin: 0 0 6px; font-size: 14px; }
#highScores { margin: 0; padding-left: 20px; font-size: 14px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 22px;
  backdrop-filter: blur(12px);
  background: rgba(5, 11, 22, 0.72);
  border-bottom: 1px solid rgba(98, 142, 212, 0.3);
}
.topbar-actions { display: flex; gap: 8px; }
.resource-badge {
  margin-top: 8px;
  display: inline-block;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(36, 144, 255, 0.2);
  border: 1px solid rgba(93, 167, 255, 0.5);
}

.result.pulse {
  animation: pulse 380ms ease-out;
}
@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(36,144,255,0); }
  50% { transform: scale(1.01); box-shadow: 0 0 18px rgba(36,144,255,0.35); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(36,144,255,0); }
}

body.light {
  --bg-0: #eaf2ff;
  --bg-1: #f5f9ff;
  --bg-2: #ffffff;
  --card: rgba(255, 255, 255, 0.86);
  --card-border: rgba(37, 99, 235, 0.2);
  --text: #0b1d3b;
  --muted: #456089;
}
body.light input, body.light select, body.light textarea {
  background: rgba(255,255,255,0.95);
  color: #0b1d3b;
}
body.light .topbar {
  background: rgba(234, 242, 255, 0.8);
}

#bulkCollision { margin-top: 10px; }
#bulkCollision .err { color: var(--err); }
#bulkCollision .ok { color: var(--ok); }
