* {
  box-sizing: border-box;
}

:root {
  --bg: #02030a;
  --panel: rgba(255, 255, 255, 0.065);
  --border: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.58);
  --blue: #8ab4ff;
  --green: #8bffb0;
  --pink: #ff8fb7;
}

html {
  min-height: 100%;
  background: #000;
}

body {
  margin: 0;
  min-height: 100dvh;

  color: var(--text);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  background-color: #000;
  background-image: url("/images/snake-background.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;

  overflow-x: hidden;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.page-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;

  background:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.54),
      rgba(0, 0, 0, 0.78)
    );

  pointer-events: none;
}

.page-wrap {
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
  padding: 24px 0 70px;
}

/* TOP BAR */

.site-topbar {
  position: relative;
  z-index: 50;

  display: flex;
  align-items: center;
  justify-content: space-between;

  height: 62px;
  padding: 0 14px;
}

.site-logo {
  width: 42px;
  height: 42px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 15px;
  overflow: hidden;

  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.site-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.menu-toggle {
  width: 44px;
  height: 44px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.13);

  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.82);

  cursor: pointer;
  text-decoration: none;

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.icon-button:hover,
.menu-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: white;
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.menu-toggle {
  flex-direction: column;
  gap: 5px;
  padding: 0;
}

.menu-toggle span {
  width: 20px;
  height: 2px;

  border-radius: 999px;
  background: currentColor;

  transition:
    transform 0.28s ease,
    opacity 0.28s ease;
}

body.menu-open .menu-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.menu-open .menu-toggle span:nth-child(2) {
  opacity: 0;
}

body.menu-open .menu-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.back-button {
  width: 44px;
  height: 44px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.13);

  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.82);

  text-decoration: none;
  cursor: pointer;

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.back-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: white;
}

.back-icon {
  width: 24px;
  height: 24px;
}

/* MAIN */

.snake-main {
  min-height: calc(100dvh - 86px);
  padding-top: 24px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-hero {
  width: min(760px, 100%);
  margin: 0 auto 38px;
  text-align: center;
}

.snake-hero h1 {
  margin: 0;

  color: white;
  font-size: clamp(58px, 10vw, 118px);
  line-height: 0.82;
  letter-spacing: -0.09em;
}

.snake-hero p {
  width: min(620px, 100%);
  margin: 24px auto 0;

  color: rgba(255, 255, 255, 0.68);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.65;
  font-weight: 650;
}

.game-layout {
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;
}

.game-shell {
  width: fit-content;
  max-width: 100%;

  padding: 14px;

  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.55);

  background: rgba(0, 0, 0, 0.82);

  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.game-top {
  width: min(520px, calc(100vw - 64px), calc(100dvh - 245px));

  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;

  margin: 0 auto 10px;;
}

.game-top div {
  padding: 9px 10px;

  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);

  background: rgba(255, 255, 255, 0.055);
}

.label {
  display: block;

  margin-bottom: 2px;

  color: rgba(255, 255, 255, 0.42);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-top strong {
  color: white;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.canvas-wrap {
  position: relative;

  width: min(520px, calc(100vw - 64px), calc(100dvh - 245px));
  height: min(520px, calc(100vw - 64px), calc(100dvh - 245px));

  margin: 0 auto;

  overflow: hidden;

  background: #000;

  border: 1px solid rgba(255, 255, 255, 0.12);

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    inset 0 0 70px rgba(139, 255, 176, 0.035);
}

#snakeCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.start-screen,
.game-over-screen {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 24px;

  text-align: center;

  background:
    radial-gradient(circle, rgba(139, 255, 176, 0.10), transparent 45%),
    rgba(0, 0, 0, 0.78);

  backdrop-filter: blur(5px);
}

.start-screen[hidden],
.game-over-screen[hidden] {
  display: none;
}

.start-screen h2,
.game-over-screen h2 {
  margin: 0 0 10px;

  color: white;
  font-size: clamp(38px, 8vw, 72px);
  line-height: 0.88;
  letter-spacing: -0.08em;
}

.start-screen p,
.game-over-screen p {
  margin: 0 0 20px;

  color: rgba(255, 255, 255, 0.62);
  font-weight: 700;
}

.start-screen button,
.game-over-screen button,
.game-actions button {
  border: 0;
  border-radius: 14px;

  color: rgba(255, 255, 255, 0.9);

  font-size: 14px;
  font-weight: 950;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.start-screen button,
.game-over-screen button {
  padding: 12px 18px;
}

.game-actions button {
  flex: 1;
  padding: 10px 12px;
}

.start-screen button:hover,
.game-over-screen button:hover,
.game-actions button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.game-actions {
  width: min(520px, calc(100vw - 64px), calc(100dvh - 245px));

  display: flex;
  gap: 20px;
  margin: 12.5px auto 0;
}

.game-actions button {
  flex: 1;
}

#startBtn {
  background: rgba(19, 131, 19, 0.92);
}

#restartBtn {
  background: rgba(118, 53, 17, 0.92);
}

#pauseBtn {
  background: rgba(49, 116, 150, 0.92);
}

#resetBtn {
  background: rgba(174, 48, 48, 0.92);
}

.mobile-controls {
  display: none;

  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  justify-content: center;
  gap: 8px;

  margin-top: 16px;
}

.control-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;

  background: rgba(255, 255, 255, 0.08);
  color: white;

  font-size: 20px;
  font-weight: 950;

  cursor: pointer;
}

.control-btn.up {
  grid-column: 2;
  grid-row: 1;
}

.control-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.control-btn.down {
  grid-column: 2;
  grid-row: 2;
}

.control-btn.right {
  grid-column: 3;
  grid-row: 2;
}

.info-panel {
  padding: 22px;

  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);

  background: rgba(0, 0, 0, 0.72);

  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.info-panel h2 {
  margin: 0 0 18px;

  color: white;
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-list div {
  padding: 14px;

  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.info-list strong {
  display: block;

  margin-bottom: 4px;

  color: white;
  font-size: 14px;
  font-weight: 950;
}

.info-list span {
  color: rgba(255, 255, 255, 0.56);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

/* MOBILE */

@media (max-width: 860px) {
  body {
    background-attachment: scroll;
  }

  .page-wrap {
    width: min(100% - 24px, 1180px);
    padding-top: 14px;
    padding-bottom: 24px;
  }

  .site-topbar {
    height: 58px;
    border-radius: 19px;
  }

  .snake-main {
    min-height: calc(100dvh - 86px);
    padding-top: 18px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-shell {
    padding: 10px;
    border-radius: 20px;
  }

  .game-top {
    width: min(390px, calc(100vw - 44px), calc(100dvh - 335px));
    gap: 6px;
    margin-bottom: 8px;
  }

  .game-top div {
    padding: 8px;
    border-radius: 12px;
  }

  .game-top strong {
    font-size: 16px;
  }

  .canvas-wrap {
    width: min(390px, calc(100vw - 44px), calc(100dvh - 335px));
    height: min(390px, calc(100vw - 44px), calc(100dvh - 335px));
  }

  .game-actions {
    width: min(390px, calc(100vw - 44px), calc(100dvh - 335px));
    margin-top: 8px;
    line-break: 1;
  }

  .game-actions button {
    padding: 9px 10px;
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 6px;
    margin-top: 10px;
  }
}

footer {
  padding:20px;
  color:var(--muted);
  text-align:center;
}