:root {
  --bg: #05070e;
  --panel: rgba(8, 14, 28, 0.88);
  --cyan: #00f0ff;
  --magenta: #ff2bd6;
  --yellow: #f5ff3c;
  --text: #c8f7ff;
  --dim: #6a9ab0;
  --border: rgba(0, 240, 255, 0.4);
  --danger: #ff3355;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Share Tech Mono", Consolas, monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Light vignette only — no blend modes */
#scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.45) 100%);
}

#flash {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 6;
  background: var(--cyan);
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

#flash.eat { background: var(--magenta); opacity: 0.16; }
#flash.die { background: var(--danger); opacity: 0.4; }

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
  pointer-events: none;
}

.panel {
  min-width: 132px;
  padding: 12px 16px;
  background: linear-gradient(160deg, rgba(10, 18, 36, 0.92), rgba(6, 12, 24, 0.88));
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.06), inset 0 1px 0 rgba(0, 240, 255, 0.08);
}

.panel-left { border-left: 2px solid var(--cyan); }
.panel-right { border-right: 2px solid var(--magenta); text-align: right; }

.panel .label {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--dim);
  margin-bottom: 4px;
}

.panel .value {
  font-family: "Share Tech Mono", Consolas, monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.55);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.panel-right .value {
  color: var(--magenta);
  text-shadow: 0 0 10px rgba(255, 43, 214, 0.55);
}

.panel .sub {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.value.bump { animation: bump 0.28s ease-out; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 20px;
  pointer-events: none;
}

.hint {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--dim);
  opacity: 0.9;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.hint-main {
  opacity: 0.85;
}

.hint-key {
  font-size: 13px;
  color: var(--yellow);
  letter-spacing: 0.1em;
  opacity: 1;
  text-shadow: 0 0 8px rgba(245, 255, 60, 0.35);
  padding: 4px 10px;
  border: 1px solid rgba(245, 255, 60, 0.35);
  border-radius: 4px;
  background: rgba(245, 255, 60, 0.06);
  animation: hint-pulse 1.6s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

kbd, .kbd-lg {
  display: inline-block;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 700;
  color: var(--bg);
  background: var(--yellow);
  border-radius: 3px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.hint-key kbd {
  padding: 1px 7px;
  font-size: 12px;
  margin: 0 2px;
}

.kbd-lg {
  padding: 3px 10px;
  font-size: 14px;
  margin: 0 4px;
  vertical-align: middle;
}

.back-home {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
  background: rgba(8, 14, 28, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.15);
  pointer-events: auto;
}

.back-home:hover {
  text-decoration: none;
  color: var(--bg);
  background: var(--cyan);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.45);
}

.status {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 12, 0.72);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  pointer-events: none;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  position: relative;
  width: min(400px, calc(100vw - 36px));
  padding: 32px 28px 26px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 0 36px rgba(0, 240, 255, 0.1);
  animation: modal-in 0.35s ease-out;
}

.modal::before,
.modal::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--cyan);
}

.modal::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.modal::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.modal-danger {
  border-color: rgba(255, 51, 85, 0.45);
  box-shadow: 0 0 36px rgba(255, 51, 85, 0.12);
}

.modal-danger::before,
.modal-danger::after { border-color: var(--danger); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-tag {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--dim);
  margin-bottom: 14px;
}

.modal-tag.danger { color: var(--danger); }

.modal-title {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: clamp(34px, 7vw, 48px);
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.05;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.7);
  margin-bottom: 14px;
}

.modal-title-sm {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.55);
  margin-bottom: 8px;
}

.modal-danger .modal-title-sm {
  color: var(--danger);
  text-shadow: 0 0 12px rgba(255, 51, 85, 0.55);
}

.modal-desc {
  font-size: 13px;
  line-height: 1.65;
  color: var(--dim);
  margin-bottom: 18px;
}

.diff-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}

.diff-btn {
  flex: 1;
  max-width: 100px;
  padding: 10px 8px;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--dim);
  background: rgba(8, 16, 32, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.diff-btn:hover {
  color: var(--text);
  border-color: rgba(0, 240, 255, 0.55);
}

.diff-btn.active {
  color: var(--bg);
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.45);
}

.diff-hint {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin-bottom: 20px;
  min-height: 1.2em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 14px;
}

.result-grid .label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
  margin-bottom: 4px;
}

.result-grid .value {
  font-family: "Share Tech Mono", Consolas, monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.new-best {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--yellow);
  text-shadow: 0 0 8px rgba(245, 255, 60, 0.6);
  margin-bottom: 14px;
  animation: pulse-best 1s ease-in-out infinite;
}

.new-best.hidden { display: none; }

@keyframes pulse-best {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-neon {
  display: inline-block;
  min-width: 190px;
  padding: 13px 26px;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--bg);
  background: var(--cyan);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-neon:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.6);
}

.btn-neon.danger {
  background: var(--danger);
  box-shadow: 0 0 16px rgba(255, 51, 85, 0.4);
}

.modal-keys {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.modal-keys.strong {
  font-size: 13px;
  color: var(--yellow);
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(245, 255, 60, 0.3);
}

/* Keep score panel clear of back-home pill */
.hud .panel-left {
  margin-left: 100px;
}

@media (max-width: 600px) {
  .hud { padding: 12px; }
  .panel { min-width: 104px; padding: 10px 12px; }
  .panel .value { font-size: 24px; }
  .hint { font-size: 10px; }
  .hud-bottom { padding: 12px; }
  .hud .panel-left { margin-left: 88px; }
  .back-home { top: 10px; left: 10px; padding: 6px 10px; font-size: 10px; }
}
