@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/PressStart2P.ttf") format("truetype");
  font-display: swap;
}

:root {
  --sea-0: #071b28;
  --sea-1: #0c3d52;
  --sea-2: #1a7a8c;
  --sand: #e2c07a;
  --coral: #e07a5a;
  --ink: #07141c;
  --foam: #d4fff2;
  --bezel: #16343c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 50% -8%, #1a6a82 0%, transparent 58%),
    radial-gradient(500px 280px at 12% 88%, rgba(32, 90, 72, 0.45), transparent 70%),
    radial-gradient(460px 240px at 88% 80%, rgba(64, 40, 72, 0.28), transparent 70%),
    linear-gradient(180deg, #0c3a4c 0%, var(--sea-0) 46%, #031018 100%);
  color: var(--foam);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at 18% 82%, rgba(24, 80, 64, 0.3), transparent 48%),
    radial-gradient(ellipse at 84% 76%, rgba(48, 36, 72, 0.2), transparent 44%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 32px;
}

.page-head {
  text-align: center;
  margin-bottom: 14px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.14em;
  text-shadow: 2px 0 0 #031018, -2px 0 0 #031018, 0 2px 0 #031018, 0 -2px 0 #031018, 0 0 18px rgba(90, 210, 196, 0.28);
}

.page-head p {
  margin: 8px 0 0;
  color: #9ad7d0;
  font-size: 12px;
  letter-spacing: 0.2em;
}

.stage {
  position: relative;
  line-height: 0;
  background: #041018;
  border: 10px solid var(--bezel);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px #7cf0d8,
    inset 0 0 0 6px #0a1818,
    0 0 0 2px #2a5a58,
    0 18px 48px rgba(0, 16, 24, 0.55);
  overflow: hidden;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border-radius: 1px;
  box-shadow: inset 0 0 28px rgba(0, 20, 30, 0.18);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(4, 12, 18, 0.05) 4px
  );
}

#game {
  display: block;
  width: 768px;
  height: 720px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, rgba(4, 16, 24, 0.08), rgba(4, 16, 24, 0.46));
  pointer-events: none;
}

.overlay.hidden {
  display: none;
}

.overlay-inner {
  width: 236px;
  padding: 14px 12px 12px;
  background: rgba(7, 24, 32, 0.78);
  border: 2px solid #e8fff8;
  box-shadow:
    0 0 0 2px #7cf0d8,
    0 0 0 4px #071820,
    0 10px 24px rgba(0, 8, 16, 0.4);
  color: #e8fff8;
  text-align: center;
  line-height: 1.45;
  pointer-events: auto;
}

.overlay-inner.is-select {
  width: 268px;
}

.portrait {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  background: #14708a;
  border: 2px solid #d7fff4;
  image-rendering: pixelated;
  overflow: hidden;
}

.portrait canvas {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay-inner h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.tag {
  margin: 8px 0 12px;
  color: var(--coral);
  font-size: 12px;
}

.menu,
.worlds {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: #bfeee6;
  text-align: left;
}

.menu li {
  display: grid;
  grid-template-columns: 10px 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  cursor: pointer;
}

.menu li + li {
  margin-top: 4px;
}

.menu-label {
  color: #e8fff8;
}

.worlds li {
  display: grid;
  grid-template-columns: 10px 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
}

.worlds li + li {
  margin-top: 2px;
}

.worlds li:not(.locked) {
  cursor: pointer;
}

.menu li.selected,
.worlds li.selected {
  background: rgba(124, 240, 216, 0.14);
  box-shadow: inset 0 0 0 1px rgba(124, 240, 216, 0.45);
}

.worlds li.locked {
  opacity: 0.38;
}

.world-cursor,
.world-id,
.world-rec {
  color: var(--sand);
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 8px;
  line-height: 18px;
}

.world-cursor {
  color: var(--coral);
}

.world-name {
  color: #bfeee6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-rec {
  color: #9ad7d0;
  letter-spacing: 0.02em;
}

.hint {
  margin: 0;
  color: var(--sand);
  font-size: 13px;
}

.hint kbd {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 8px;
  line-height: 1.8;
}

kbd {
  display: inline-block;
  min-width: 1.2em;
  padding: 1px 5px 0;
  border: 1px solid #7cf0d8;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 0 #0a3038;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 8px;
  line-height: 1.7;
}

.help {
  max-width: 768px;
  margin-top: 14px;
  text-align: center;
  color: #9ad7d0;
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 820px) {
  #game {
    width: min(100vw - 24px, 768px);
    height: auto;
    aspect-ratio: 256 / 240;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint {
    animation: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hint {
    animation: hintPulse 1.6s ease-in-out infinite;
  }
}

@keyframes hintPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}
