* {
  box-sizing: border-box;
}

:root {
  --bg-a: #0d1b30;
  --bg-b: #12263e;
  --bg-c: #0b2c30;
  --panel: rgba(10, 20, 34, 0.78);
  --text: #edf7ff;
  --muted: #9ab5cb;
  --line: rgba(152, 184, 213, 0.28);
  --accent: #5cf7ba;
  --accent-dark: #17bf83;
  --danger: #ff5f6d;
  --warning: #ffd869;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 0% 0%, #1a3f72 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #174a37 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  pointer-events: none;
}

body::before {
  top: -120px;
  left: -100px;
  background: #2c9dff;
}

body::after {
  right: -110px;
  bottom: -130px;
  background: #19ca89;
}

.app {
  max-width: 520px;
  margin: 28px auto;
  padding: 18px;
  border: 1px solid rgba(140, 175, 206, 0.2);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 26px 50px rgba(2, 8, 16, 0.45);
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.title-wrap {
  position: relative;
  padding-left: 62px;
}

.snake-symbol {
  position: absolute;
  left: 0;
  top: 2px;
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 2px 8px rgba(31, 219, 154, 0.28));
}

.snake-symbol svg {
  width: 100%;
  height: 100%;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(92, 247, 186, 0.35);
  background: rgba(92, 247, 186, 0.12);
  color: #7affcb;
  font-size: 0.86rem;
  font-weight: 700;
}

.stats {
  display: flex;
  gap: 10px;
  margin: 14px 0 12px;
}

.stat-card {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(19, 35, 56, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.value {
  margin: 3px 0 0;
  font-size: 1.28rem;
  font-weight: 700;
  color: #d9f9ff;
}

.board-shell {
  position: relative;
  width: fit-content;
  margin: 0 auto;
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(155deg, #1a2e47, #102638);
  border: 1px solid rgba(131, 172, 208, 0.35);
  box-shadow: 0 0 0 1px rgba(84, 130, 171, 0.3),
    0 0 28px rgba(62, 160, 255, 0.18), 0 18px 30px rgba(0, 0, 0, 0.35);
}

#game {
  display: block;
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(124, 160, 191, 0.45);
  border-radius: 12px;
  background: #091623;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

button {
  padding: 9px 13px;
  border: 1px solid rgba(140, 180, 212, 0.5);
  border-radius: 10px;
  background: linear-gradient(180deg, #213b5a, #162e45);
  color: #e8f6ff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.1s ease;
}

button:hover {
  background: linear-gradient(180deg, #2a4e75, #1a3a57);
  border-color: rgba(164, 210, 247, 0.7);
  box-shadow: 0 0 0 1px rgba(90, 173, 255, 0.35);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.touch-controls {
  margin-top: 12px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.touch-controls button {
  width: 48px;
  height: 48px;
  font-size: 18px;
  border-radius: 12px;
}

.middle-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.help {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  margin-right: 3px;
  border-radius: 7px;
  border: 1px solid rgba(173, 210, 242, 0.4);
  background: rgba(16, 42, 67, 0.65);
  color: #d2ebff;
  font-size: 0.8rem;
  font-weight: 700;
}

@media (max-width: 520px) {
  .app {
    margin: 12px;
    padding: 14px;
  }

  h1 {
    font-size: 1.38rem;
  }

  .title-wrap {
    padding-left: 56px;
  }

  .snake-symbol {
    width: 46px;
    height: 46px;
  }

  .stats {
    margin-top: 12px;
  }

  .board-shell {
    padding: 8px;
  }
}
