:root {
  --bg-top: #08111f;
  --bg-bottom: #1f3054;
  --panel: rgba(7, 16, 30, 0.78);
  --panel-border: rgba(197, 227, 255, 0.16);
  --text: #edf6ff;
  --muted: #a8bdd8;
  --blueberry: #7ea1ff;
  --skeletal: #f6f2df;
  --accent: #ffd479;
  --danger: #ff9478;
  --grass: #36614e;
  --stone: #8290b8;
  --shadow: rgba(2, 6, 15, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(126, 161, 255, 0.22), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(255, 212, 121, 0.14), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent 92%);
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero-copy,
.story-card,
.game-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 28px 80px var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

h1,
h2 {
  font-family: "Cinzel", serif;
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 0.95;
  max-width: 11ch;
}

.lede,
.story-card p {
  color: var(--muted);
  line-height: 1.7;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.controls div,
.hud-block {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.controls span,
.hud-block span {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.controls strong,
.hud-block strong {
  font-size: 1rem;
}

.story-card {
  padding: 24px;
}

.story-card h2 {
  margin-bottom: 14px;
}

.game-panel {
  padding: 18px;
}

.settings-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.canvas-shell {
  position: relative;
}

.canvas-shell.fullscreen-active {
  background:
    radial-gradient(circle at 20% 20%, rgba(126, 161, 255, 0.18), transparent 24%),
    linear-gradient(180deg, #08111f, #182744);
}

.canvas-shell.fullscreen-active:fullscreen {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
}

.canvas-shell.fullscreen-active:fullscreen canvas {
  width: 100vw;
  height: 56.25vw;
  max-height: 100vh;
  max-width: 177.777vh;
  border-radius: 0;
  border: 0;
}

.canvas-shell.fullscreen-active:fullscreen .touch-controls {
  inset: 50% auto auto 50%;
  width: min(100vw, 177.777vh);
  height: min(56.25vw, 100vh);
  transform: translate(-50%, -50%);
}

@media (orientation: portrait) {
  .canvas-shell.fullscreen-active:fullscreen canvas {
    width: 100vh;
    height: 56.25vh;
    max-width: 100vw;
    max-height: 177.777vw;
    transform: rotate(90deg);
  }

  .canvas-shell.fullscreen-active:fullscreen .touch-controls {
    width: min(100vh, 100vw);
    height: min(56.25vh, 177.777vw);
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center;
  }
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #95b9ff 0%, #6d92db 40%, #233252 100%);
}

.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.touch-controls.hidden {
  opacity: 0;
  visibility: hidden;
}

.touch-row {
  position: absolute;
  display: flex;
  gap: 12px;
  pointer-events: none;
}

.touch-row-bottom {
  bottom: 18px;
}

.touch-row-left {
  left: 18px;
}

.touch-row-right {
  right: 18px;
}

.touch-button {
  min-width: 74px;
  min-height: 74px;
  border-radius: 24px;
  padding: 0 16px;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(7, 16, 30, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
}

.touch-button:hover,
.touch-button:focus-visible {
  color: var(--text);
  background: rgba(7, 16, 30, 0.58);
}

.touch-button:active,
.touch-button.is-pressed {
  transform: scale(0.98);
  background: rgba(126, 161, 255, 0.4);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.message-bar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
}

.message-bar p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 800;
  color: #16243f;
  background: linear-gradient(135deg, #fff2c0, #ffd479);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 14px 28px rgba(255, 212, 121, 0.24);
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(255, 212, 121, 0.3);
}

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

  .hud,
  .controls {
    grid-template-columns: 1fr;
  }

  .message-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  button {
    width: 100%;
  }

  .settings-bar {
    justify-content: stretch;
  }

  .touch-button {
    min-width: 64px;
    min-height: 64px;
    border-radius: 20px;
  }
}

@media (max-width: 640px) {
  .touch-row-bottom {
    bottom: 12px;
  }

  .touch-row-left {
    left: 12px;
  }

  .touch-row-right {
    right: 12px;
  }

  .touch-row {
    gap: 8px;
  }

  .touch-button {
    min-width: 58px;
    min-height: 58px;
    font-size: 0.92rem;
  }
}
