/* ============================================================
   Snake Game — Styles
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0d0d0d;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-tap-highlight-color: transparent;   /* remove tap flash on mobile */
  user-select: none;
}

/* ---------- Header ---------- */
#header {
  width: 100%;
  max-width: 600px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.score-group {
  display: flex;
  gap: 24px;
  font-size: 1.1rem;
  font-weight: 600;
}

#score, #highscore {
  color: #4cff72;
}

.controls-hint {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: #888;
}

/* ---------- Canvas Wrapper ---------- */
#canvas-wrapper {
  position: relative;
  width: min(90vw, 600px);
  height: min(90vw, 600px);
  max-width: 600px;
  max-height: 600px;
  border: 2px solid #2a2a2a;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #111;
}

/* ---------- Overlays ---------- */
#overlay, #pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.80);
  z-index: 10;
  transition: opacity 0.25s ease;
}

.hidden {
  display: none !important;
}

#overlay-content, #pause-content {
  text-align: center;
}

#overlay-title {
  font-size: 2.2rem;
  margin-bottom: 12px;
  color: #ff4c4c;
}

#overlay-score {
  font-size: 1.3rem;
  margin-bottom: 20px;
}

#pause-content h1 {
  font-size: 2rem;
  color: #ffd54f;
}

#pause-content p {
  margin-top: 10px;
  color: #bbb;
}

#restart-btn {
  padding: 12px 32px;
  font-size: 1.1rem;
  border: none;
  border-radius: 8px;
  background: #4cff72;
  color: #111;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

#restart-btn:hover {
  background: #3de062;
}

/* ---------- Mobile D-Pad ---------- */
#mobile-controls {
  display: none;               /* shown via media query */
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-middle-row {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
  border: none;
  border-radius: 10px;
  background: #222;
  color: #ccc;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}

.dpad-btn:active {
  background: #4cff72;
  color: #111;
}

.mobile-action-btn {
  padding: 10px 28px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: #333;
  color: #ccc;
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-action-btn:active {
  background: #555;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .controls-hint {
    display: none;
  }

  #canvas-wrapper {
    width: 92vw;
    height: 92vw;
  }

  #mobile-controls {
    display: flex;
  }
}

@media (max-height: 680px) and (max-width: 640px) {
  #canvas-wrapper {
    width: 70vw;
    height: 70vw;
  }
}
