@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700&display=swap');

:root {
  --bg: #0a0f0a;
  --grid-even: #0b150b;
  --snake-head: #39ff14;
  --snake-body-max: #1f8c09;
  --apple: #ff3b3b;
  --ui: #39ff14;
  --ui-dim: #1a6b06;
  --text: #c8f5c8;
  --score-bg: #0d1a0d;
  --border: #1f3d1f;
}

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

body {
  background: var(--bg);
  font-family: 'Share Tech Mono', monospace;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12px 8px;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* ── Header ── */
#header {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 4px;
}

#title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 700;
  color: var(--snake-head);
  letter-spacing: 3px;
  text-shadow: 0 0 12px #39ff1466;
}

#hi-score-label {
  font-size: 11px;
  color: var(--ui-dim);
  text-align: right;
  line-height: 1.3;
}

#hi-score-label span {
  display: block;
  color: var(--ui);
  font-size: 15px;
}

/* ── Score bar ── */
#score-bar {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--score-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 10px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-item label {
  font-size: 10px;
  color: var(--ui-dim);
  letter-spacing: 1px;
}

.score-item span {
  font-size: 18px;
  font-weight: 700;
  color: var(--ui);
}

/* ── Arena ── */
#arena {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  border: 1px solid var(--border);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Overlay ── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 10, 0.88);
  border-radius: 4px;
  gap: 14px;
}

#overlay.hidden {
  display: none;
}

#overlay-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(22px, 7vw, 36px);
  font-weight: 700;
  color: var(--snake-head);
  letter-spacing: 4px;
  text-align: center;
}

#overlay-sub {
  font-size: clamp(12px, 3.5vw, 15px);
  color: var(--ui-dim);
  text-align: center;
  line-height: 1.6;
  padding: 0 20px;
}

#overlay-score {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--ui);
  display: none;
}

#btn-start {
  font-family: 'Orbitron', monospace;
  font-size: clamp(13px, 4vw, 16px);
  font-weight: 700;
  letter-spacing: 2px;
  padding: 12px 28px;
  background: transparent;
  border: 2px solid var(--snake-head);
  color: var(--snake-head);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 6px;
}

#btn-start:hover,
#btn-start:active {
  background: var(--snake-head);
  color: var(--bg);
}

/* ── Hint ── */
#hint {
  font-size: 11px;
  color: var(--ui-dim);
  text-align: center;
  margin-top: 10px;
  letter-spacing: 1px;
}

/* ── D-Pad (mobile) ── */
#dpad {
  display: none;
  width: 100%;
  max-width: 200px;
  margin: 14px auto 4px;
  position: relative;
  height: 140px;
}

.dpad-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  background: #0d1a0d;
  border: 1.5px solid #2a5c2a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--ui);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: #1a3d1a;
}

#btn-up    { top: 0;    left: 50%; transform: translateX(-50%); }
#btn-down  { bottom: 0; left: 50%; transform: translateX(-50%); }
#btn-left  { left: 0;   top: 50%;  transform: translateY(-50%); }
#btn-right { right: 0;  top: 50%;  transform: translateY(-50%); }

#btn-pause {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: #0a120a;
  border: 1.5px solid var(--border);
  font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 400px) {
  body { padding: 8px 4px; }
  #score-bar { padding: 6px 10px; }
  .score-item span { font-size: 16px; }
}

@media (min-width: 600px) {
  #arena { max-width: 480px; }
  #header, #score-bar { max-width: 480px; }
}
