:root {
  --paper: #eff7e7;
  --mist: #b8d9c4;
  --ink: #071110;
  --deep: #081d1b;
  --panel: rgba(7, 17, 16, 0.9);
  --line: rgba(239, 247, 231, 0.2);
  --amber: #ffd15a;
  --green: #ff3b3b;
  --cyan: #ff756b;
  --red: #ff5348;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

button,
a {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 59, 59, 0.08), transparent 18%, transparent 82%, rgba(255, 117, 107, 0.08)),
    linear-gradient(180deg, rgba(34, 10, 10, 0.8), rgba(9, 3, 3, 0.98)),
    var(--deep);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.title-card {
  display: none;
  position: absolute;
  left: 50%;
  top: 7vh;
  z-index: 5;
  width: min(920px, calc(100vw - 32px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  transition:
    opacity 450ms ease,
    transform 450ms ease;
}

.quick-links {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-links a {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(109, 255, 145, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(239, 247, 231, 0.18), transparent 42%),
    rgba(7, 17, 16, 0.7);
  color: var(--paper);
  text-decoration: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 0 20px rgba(77, 231, 255, 0.14);
  backdrop-filter: blur(12px);
}

.quick-links a:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(77, 231, 255, 0.36);
}

.quick-links .avatar-link {
  width: 72px;
  height: 72px;
  border-color: rgba(239, 247, 231, 0.38);
  background:
    radial-gradient(circle at 45% 40%, #f6eff1 0 22%, #b8b5bc 44%, #1b2427 72%),
    #071110;
  color: #071110;
  font-size: 1rem;
}

.title-card.hidden {
  transform: translate(-50%, -4px);
}

.title-card.playing .crest,
.title-card.playing .kicker,
.title-card.playing .title-actions {
  opacity: 0;
  pointer-events: none;
}

.title-card.playing h1 {
  opacity: 0.9;
  font-size: clamp(2.8rem, 6.5vw, 6.4rem);
}

.title-card.playing .tagline {
  opacity: 0.58;
}

.crest {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  border: 2px solid rgba(255, 209, 90, 0.7);
  border-radius: 50%;
  background: rgba(255, 209, 90, 0.09);
  color: var(--amber);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 800;
  box-shadow: 0 0 34px rgba(255, 209, 90, 0.22);
  animation: crestPulse 2.8s ease-in-out infinite;
}

.kicker,
.panel-kicker,
.hud span,
.game-help,
.prompt {
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0;
}

.kicker {
  margin: 0 0 6px;
  color: var(--green);
  font-size: clamp(0.75rem, 2vw, 0.95rem);
}

h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(3rem, 9vw, 8.4rem);
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 0.88;
  background: linear-gradient(135deg, var(--paper) 30%, #4de7ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 35px rgba(77, 231, 255, 0.16);
}

.tagline {
  margin: 12px auto 20px;
  max-width: 760px;
  color: var(--mist);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
}

.title-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  pointer-events: auto;
}

.title-actions button,
.title-actions a,
.mobile-controls button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(239, 247, 231, 0.08);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
}

.title-actions button,
.title-actions a {
  min-width: 148px;
  padding: 0 18px;
  font-weight: 700;
}

.title-actions button {
  border-color: rgba(109, 255, 145, 0.55);
  background: rgba(109, 255, 145, 0.18);
  color: var(--green);
}

.hud {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 6;
  display: none;
  gap: 10px;
  pointer-events: none;
}

.hud div,
.mini-map,
.prompt,
.codex-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(77, 231, 255, 0.08), transparent 42%),
    var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.hud div {
  min-width: 150px;
  padding: 12px 14px;
}

.hud span {
  display: block;
  color: var(--green);
  font-size: 0.68rem;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
}

.mini-map {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 6;
  display: none;
  gap: 8px;
  padding: 10px;
}

.mini-map span {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(239, 247, 231, 0.38);
  border-radius: 50%;
  background: rgba(239, 247, 231, 0.09);
}

.mini-map span.done {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 18px rgba(109, 255, 145, 0.8);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 112px;
  z-index: 6;
  transform: translateX(-50%);
  padding: 12px 16px;
  color: var(--paper);
  display: none;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  margin: 0 4px;
  border: 1px solid rgba(255, 209, 90, 0.55);
  background: rgba(255, 209, 90, 0.14);
  color: var(--amber);
  font-family: "IBM Plex Mono", monospace;
}

.codex-panel {
  position: absolute;
  right: 24px;
  bottom: 86px;
  z-index: 8;
  width: min(520px, calc(100vw - 32px));
  max-height: min(72vh, 660px);
  padding: 24px;
  overflow: auto;
}

.close-panel {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  cursor: pointer;
}

.panel-kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.78rem;
}

.codex-panel h2 {
  margin: 0 36px 14px 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 3.1rem);
  line-height: 0.95;
}

.panel-body {
  color: var(--mist);
  line-height: 1.48;
}

.panel-body p,
.panel-body ul {
  margin: 0 0 14px;
}

.panel-body ul {
  padding-left: 18px;
}

.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.panel-links a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(77, 231, 255, 0.42);
  background: rgba(77, 231, 255, 0.1);
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
}

.game-help {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 6;
  display: flex;
  gap: 22px;
  transform: translateX(-50%);
  color: rgba(239, 247, 231, 0.7);
  font-size: 0.72rem;
  pointer-events: none;
  white-space: nowrap;
}

.mobile-controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  z-index: 7;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mobile-controls button {
  min-width: 0;
  border-color: rgba(239, 247, 231, 0.24);
  background: rgba(7, 17, 16, 0.72);
}

@keyframes crestPulse {
  0%,
  100% {
    box-shadow: 0 0 28px rgba(255, 209, 90, 0.18);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 52px rgba(255, 209, 90, 0.36);
    transform: translateY(-3px);
  }
}

.seo-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 760px) {
  .quick-links {
    left: 10px;
    top: 10px;
    gap: 7px;
  }

  .quick-links a {
    width: 40px;
    height: 40px;
    font-size: 0.76rem;
  }

  .quick-links .avatar-link {
    width: 54px;
    height: 54px;
  }

  .title-card {
    top: 10vh;
  }

  .hud {
    left: 10px;
    right: 10px;
    top: 10px;
  }

  .hud div {
    min-width: 0;
    flex: 1;
    padding: 10px;
  }

  .mini-map {
    right: 10px;
    top: 84px;
  }

  .codex-panel {
    left: 12px;
    right: 12px;
    bottom: 82px;
    width: auto;
    padding: 20px;
  }

  .game-help {
    display: none;
  }

  .mobile-controls {
    display: grid;
  }

  .prompt {
    bottom: 76px;
    width: max-content;
    max-width: calc(100vw - 28px);
  }
}
