@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --bg-ink: #0b0f16;
  --bg-deep: #0a0d13;
  --panel: #161f33;
  --panel-muted: #121a2b;
  --ink: #f5f8ff;
  --accent: #ff7a5c;
  --accent-2: #31c3ff;
  --accent-3: #6ddf6b;
  --accent-4: #f6c356;
  --shadow: rgba(2, 4, 10, 0.6);
  --grid: rgba(49, 195, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'VT323', 'Courier New', monospace;
  color: var(--ink);
  background: radial-gradient(circle at top, #1b2333 0%, #0b0f16 45%, #070a0f 100%);
  min-height: 100dvh;
  height: 100dvh;
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="120" height="120" filter="url(%23n)" opacity="0.08"/></svg>');
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
  touch-action: none;
  position: static;
  z-index: 2;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}


.control-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  line-height: 1;
  border: 2px solid rgba(49, 195, 255, 0.45);
  border-radius: 16px;
  background: #0f1522;
  color: #e8f0ff;
  box-shadow: 0 8px 14px rgba(2, 4, 10, 0.5);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.arrow-glyph {
  display: block;
  font-size: 0.85rem;
  line-height: 1;
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 10px rgba(2, 4, 10, 0.5);
}

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

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

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

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

.shell {
  position: relative;
  z-index: 1;
  padding: 18px 4vw 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100dvh;
  overflow: hidden;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 40px var(--shadow);
  border: 2px solid rgba(49, 195, 255, 0.2);
}

.eyebrow {
  font-family: 'Press Start 2P', monospace;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.6rem;
  color: var(--accent-2);
  margin: 0 0 10px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw, 3.2rem);
  font-family: 'Press Start 2P', monospace;
}

.lede {
  margin: 0;
  max-width: 560px;
  font-size: 1.1rem;
}

.badges {
  display: grid;
  gap: 10px;
  padding: 16px 20px;
  border-radius: 16px;
  background: #0c121f;
  box-shadow: inset 0 0 0 1px rgba(49, 195, 255, 0.2);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
}

.stage {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.game-card,
.info-card {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 18px 40px var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  min-height: 0;
  overflow: hidden;
}

.game-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  gap: 12px;
  height: 100%;
}

.game-top,
.game-bottom {
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 18px 40px var(--shadow);
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.game-top {
  flex: 1;
}

.game-bottom {
  flex: 0 0 auto;
}

.game-bottom h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-family: 'Press Start 2P', monospace;
}

.game-bottom p {
  margin: 0 0 10px;
  line-height: 1.4;
  color: #f3f6ff;
}

.copyright {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  text-align: center;
}

.footer-links {
  display: block;
  margin: 0;
}

.footer-links a {
  color: #f3f6ff;
  text-decoration: none;
  margin: 0 6px;
  display: inline-block;
}

.footer-links a:hover {
  text-decoration: underline;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game-head h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-family: 'Press Start 2P', monospace;
}

.game-head p {
  margin: 0;
  color: rgba(245, 248, 255, 0.92);
}

.game-field-note {
  font-size: 0.95rem;
  color: rgba(245, 248, 255, 0.88);
}

.status {
  text-align: right;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
}

.status .label {
  display: block;
  opacity: 0.6;
  margin-bottom: 6px;
}

.status .value {
  color: var(--accent-2);
  font-size: 0.75rem;
}

.game-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}

.legend {
  background: var(--panel-muted);
  border-radius: 14px;
  padding: 10px;
  border: 1px solid rgba(49, 195, 255, 0.15);
}

.legend h3 {
  margin: 0 0 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
}

.legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.game-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  color: rgba(245, 248, 255, 0.92);
  font-size: 0.85rem;
}

.hero,
.legend,
.tabs,
.panel,
.about,
.game-head,
.game-foot {
  pointer-events: none;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.tab {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.58rem;
  text-transform: lowercase;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid rgba(49, 195, 255, 0.2);
  background: #121a2b;
  color: #eef3ff;
  cursor: crosshair;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tab.is-active {
  background: #101826;
  color: #fff;
  box-shadow: 0 10px 18px rgba(2, 4, 10, 0.5);
  transform: translateY(-2px);
}

.panel {
  background: var(--panel-muted);
  border-radius: 16px;
  padding: 18px;
  min-height: 200px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(49, 195, 255, 0.1);
  flex: 1;
  min-height: 0;
  color: #f3f6ff;
}

.static-panel h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-family: 'Press Start 2P', monospace;
}

.static-panel p {
  margin: 0 0 10px;
  line-height: 1.35;
  color: #f3f6ff;
}

.meta {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: rgba(245, 248, 255, 0.7);
}

.about {
  border-top: 1px dashed rgba(49, 195, 255, 0.25);
  padding-top: 16px;
  font-size: 0.95rem;
  color: #f3f6ff;
}

.about h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-family: 'Press Start 2P', monospace;
}

.about p {
  margin: 0 0 12px;
  line-height: 1.4;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(transparent 95%, var(--grid) 100%),
    linear-gradient(90deg, transparent 95%, var(--grid) 100%);
  background-size: 28px 28px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

p,
h1,
h2,
h3,
span {
  text-shadow: 0 1px 0 rgba(2, 4, 10, 0.7);
}

#snake-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  image-rendering: pixelated;
}

@keyframes pop {
  0% {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .stage {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px), (max-height: 700px) {
  body {
    font-size: 1.05rem;
  }

  .shell {
    padding: 12px 4vw 16px;
    gap: 10px;
  }

  .hero {
    padding: 14px;
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  .lede {
    display: none;
  }

  .badges {
    font-size: 0.5rem;
    gap: 6px;
    padding: 10px 12px;
  }

  .stage {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
  }

  .game-card,
  .info-card {
    padding: 12px;
    border-radius: 14px;
    gap: 6px;
  }

  .game-card {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    height: auto;
    order: 2;
    flex: 0 0 45%;
    min-height: 200px;
  }

  .game-top,
  .game-bottom {
    padding: 12px;
    border-radius: 14px;
    gap: 6px;
    overflow: visible;
  }

  .game-top {
    flex: 1 1 auto;
  }

  .game-bottom {
    flex: 0 0 auto;
  }

  .game-wrap {
    display: none;
  }

  .game-head p,
  .game-foot {
    display: none;
  }

  .info-card {
    flex: 1 1 55%;
    min-height: 0;
    order: 1;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .tab {
    font-size: 0.5rem;
    padding: 8px 4px;
  }

  .panel {
    padding: 10px;
  }

  .static-panel h3 {
    font-size: 0.9rem;
  }

  .static-panel p {
    font-size: 0.9rem;
    line-height: 1.25;
  }

  .meta,
  .about {
    display: none;
  }


  .badges {
    width: 100%;
  }

  .game-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .status {
    text-align: left;
  }

  .touch-controls {
    position: static;
    transform: none;
    z-index: 12;
  }

  .arrow-glyph {
    font-size: 0.52rem;
    transform: translateY(-2px);
  }

  .copyright,
  .footer-links {
    font-size: 0.6rem;
    line-height: 1.4;
  }

}

@media (max-width: 520px) {
  .touch-controls {
    grid-template-columns: repeat(3, 36px);
    grid-template-rows: repeat(2, 36px);
    gap: 6px;
  }

  .control-btn {
    font-size: 0.45rem;
    line-height: 1;
    border-radius: 12px;
  }

  .arrow-glyph {
    font-size: 0.38rem;
    transform: translateY(-3px) scale(0.9);
  }
}

@media (max-height: 720px) {
  .shell {
    padding: 12px 3vw 16px;
    gap: 12px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .panel {
    min-height: 160px;
  }

  .about p:last-child {
    display: none;
  }

  .legend {
    display: none;
  }
}

@media (max-height: 640px) {
  .hero h1 {
    font-size: 1.4rem;
  }

  .panel {
    min-height: 120px;
  }

  .game-head p,
  .game-foot {
    font-size: 0.8rem;
  }

  .legend,
  .about {
    display: none;
  }

  .game-card {
    flex: 0 0 200px;
  }

  .game-bottom {
    padding: 8px;
  }

  .copyright,
  .footer-links {
    font-size: 0.5rem;
  }
}
