:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #f3f1ea;
  color: #1f1d1a;
  --panel: #fffdf7;
  --border: #d7d1c4;
  --grid: #ece6d9;
  --snake: #2f6f4f;
  --snake-head: #1f5239;
  --food: #c94f3d;
  --accent: #3d5a80;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background, #f3f1ea);
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.screen {
  display: none;
  width: min(100%, 520px);
}

.screen-active {
  display: block;
}

.panel {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.splash-screen,
.highscore-screen {
  text-align: center;
}

.eyebrow,
.label,
.hint,
.intro {
  margin: 0;
  color: #5a554b;
  font-size: 0.9rem;
}

.game-title {
  margin: 12px 0 8px;
  font-size: clamp(3rem, 10vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0.18em;
}

.title {
  margin: 8px 0 12px;
  font-size: 1.5rem;
}

.final-score {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
}

.splash-difficulty,
.hud,
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.splash-difficulty,
.hud,
.actions,
.name-form {
  margin-bottom: 16px;
}

.splash-difficulty,
.hud,
.name-form {
  padding: 16px;
  background: rgba(255, 253, 247, 0.7);
  border: 1px solid var(--border);
}

.value {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.difficulty select,
.actions button,
.control,
.name-entry input,
.name-entry button,
.primary-button,
.secondary-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: inherit;
  padding: 10px 16px;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  min-width: 160px;
}

.difficulty select:hover,
.actions button:hover,
.control:hover,
.name-entry input:hover,
.name-entry button:hover,
.primary-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.board {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 2px;
  aspect-ratio: 1;
  padding: 12px;
  background: rgba(255, 253, 247, 0.7);
  border: 1px solid var(--border);
}

.cell {
  background: var(--grid);
  border-radius: 2px;
}

.cell.snake {
  background: var(--snake);
}

.cell.head {
  background: var(--snake-head);
}

.cell.food {
  background: var(--food);
}

.cell.super-food {
  background: linear-gradient(
    135deg,
    #ff5f6d,
    #ffb347,
    #fff56b,
    #67e48b,
    #5ec6ff,
    #ae7dff,
    #ff5f6d
  );
  background-size: 300% 300%;
  animation: shimmer 1.4s linear infinite;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.up {
  grid-column: 2;
}

.left {
  grid-column: 1;
}

.down {
  grid-column: 2;
}

.right {
  grid-column: 3;
}

.name-entry {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.name-entry input {
  width: 100%;
  text-transform: uppercase;
}

.highscore-list {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.highscore-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #e7e0d2;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  color: #5a554b;
  text-align: center;
}

.hint {
  margin-top: 12px;
  text-align: center;
}

.hidden {
  display: none;
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
    filter: brightness(0.95);
  }

  50% {
    background-position: 100% 50%;
    filter: brightness(1.08);
  }

  100% {
    background-position: 0% 50%;
    filter: brightness(0.95);
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 16px;
  }

  .splash-difficulty,
  .hud,
  .actions,
  .name-entry {
    flex-direction: column;
    align-items: stretch;
  }
}
