:root{ 
  --bg:#0f1724; 
  --panel:#0b1220; 
  --accent:#10b981; 
  --grid:#15303a; 
  --snake:#34d399; 
  --snake-head:#facc15; 
  --food:#fb7185; 
  --text:#e6eef6;
}

html,body {
  height: 100%;
  margin: 0;
  background: linear-gradient(180deg,var(--bg),#091021);
  color: var(--text);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,'PingFang SC',"Hiragino Sans GB","Microsoft YaHei",Arial;
}

.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18px;
  box-sizing: border-box;
}

header {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

h1 { margin: 0; font-size: 20px; }

.controls { display: flex; gap: 8px; align-items: center; }

button {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.03);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover { background: rgba(255,255,255,0.08); }
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: linear-gradient(90deg,#0ea5a0,#10b981);
  color: #04201a;
  font-weight: 600;
}

.scorebox { display: flex; gap: 12px; align-items: center; margin-left: 8px; }
.score { background: rgba(255,255,255,0.03); padding: 6px 10px; border-radius: 8px; font-size: 14px; }

.canvas-wrap {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1/1;
  background: var(--panel);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 6px 30px rgba(2,6,23,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

canvas {
  flex: 1; 
  background: var(--bg); 
  display: block;
  width: 100%; 
  height: 100%;
  box-shadow: 0 0 0 3px #10b981, 0 0 12px #10b981;
  border-radius: 6px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
  background: rgba(0,0,0,0.4);
}

.dialog {
  background: rgba(2,6,23,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 24px;
  border-radius: 16px;
  min-width: 280px;
  pointer-events: auto;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
}

.dialog h2, .dialog h3 { margin-top: 0; margin-bottom: 12px; }
.dialog p { margin: 8px 0; color: #94a3b8; }

.hidden { display: none !important; }

/* Start Screen specific */
.mode-select {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.mode-btn {
  padding: 16px;
  font-size: 16px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mode-btn small { opacity: 0.6; font-size: 12px; font-weight: normal; }

.level-info {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0,0,0,0.7);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
}

@media (max-width: 640px) {
  h1 { font-size: 18px; }
  .controls { flex-wrap: wrap; }
}

/* Gamepad Hints */
.gamepad-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #334155;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  margin-left: 8px;
  box-shadow: 0 2px 0 #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  vertical-align: middle;
}

body:not(.input-mode-gamepad) .gamepad-hint {
  display: none !important;
}

/* Optional: Hide keyboard hints if we had any when in gamepad mode */
body.input-mode-gamepad .keyboard-hint {
  display: none;
}
