:root {
  color-scheme: dark;
  --ink: #f5f0d0;
  --muted: #b9b08a;
  --panel: #101015;
  --panel-2: #191923;
  --accent: #f0b43c;
  --danger: #e85042;
  --screen-width: min(760px, 92vw, calc((100svh - 190px) * 64 / 42));
  --screen-gap: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #050508;
  color: var(--ink);
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

.is-hidden {
  display: none !important;
}

.title-screen {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: var(--screen-gap);
  place-items: center;
  min-height: 100svh;
  padding: 24px;
}

.title-screen h1 {
  color: #fff1a0;
  font-size: clamp(34px, 6vw, 76px);
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 6px 0 #35210b;
}

.screen-frame {
  display: block;
  width: var(--screen-width);
  aspect-ratio: 64 / 42;
  border: 8px solid #a96e18;
  border-radius: 8px;
  background: #030304;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.title-video,
.bad-video {
  object-fit: cover;
}

.title-screen button {
  min-width: 180px;
  font-size: 22px;
}

.music-credit {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 8px;
  z-index: 20;
  margin: 0;
  color: rgba(245, 240, 208, 0.72);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

.music-credit a {
  border: 0;
  background: transparent;
  color: #ffdf70;
  padding: 0;
}

button,
a {
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

button {
  border: 2px solid #8b7736;
  background: #241f16;
  cursor: pointer;
  padding: 12px 18px;
}

button:hover,
button:focus-visible,
a:hover,
a:focus-visible {
  background: #3a2f17;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-shell {
  display: grid;
  align-content: center;
  width: min(960px, calc(100vw - 24px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 24px 0;
}

.top-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--panel);
  border: 1px solid #2d2a24;
  border-radius: 8px;
  padding: 14px 16px;
}

.label,
h1,
h2,
p {
  margin: 0;
}

.label {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(24px, 4vw, 42px);
}

.compass {
  display: grid;
  grid-template-columns: 42px 42px 42px;
  grid-template-rows: 34px 34px 34px;
  gap: 2px;
  place-items: center;
  min-width: 140px;
}

.compass-item {
  display: grid;
  place-items: center;
  width: 40px;
  height: 32px;
  border: 1px solid #393526;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
}

.compass-item.is-current {
  border-color: var(--accent);
  background: #3a2f17;
  color: #fff1a0;
}

.north {
  grid-column: 2;
  grid-row: 1;
}

.west {
  grid-column: 1;
  grid-row: 2;
}

.east {
  grid-column: 3;
  grid-row: 2;
}

.south {
  grid-column: 2;
  grid-row: 3;
}

.compass-core {
  grid-column: 2;
  grid-row: 2;
  color: #ffdf70;
  font-size: 24px;
  line-height: 1;
  transition: transform 120ms ease;
}

.viewport-wrap {
  margin: 0 auto var(--screen-gap);
  background: #030304;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 64 / 42;
  image-rendering: pixelated;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, auto);
  gap: 8px;
  width: min(100%, 520px);
  margin: 0 auto var(--screen-gap);
}

.move-forward {
  grid-column: 2;
  grid-row: 1;
}

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

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

.move-back {
  grid-column: 2;
  grid-row: 3;
}

.info-panel {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 8px;
  width: min(100%, 220px);
  margin: 0 auto var(--screen-gap);
}

.info-panel div {
  background: var(--panel);
  border: 1px solid #312d24;
  border-radius: 6px;
  padding: 8px 10px;
}

.info-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.info-panel strong {
  display: block;
  color: #fff1a0;
  font-size: 18px;
}

.links {
  width: min(100%, 720px);
  margin: 0 auto;
  text-align: center;
}

.links a {
  display: inline-block;
  border: 1px solid #51462b;
  background: #17151a;
  padding: 10px 12px;
  text-decoration: none;
}

.cutscene {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
  padding: 18px;
}

.video-scene {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: var(--screen-gap);
  background: rgba(0, 0, 0, 0.92);
  padding: 18px;
}

.video-scene.is-open {
  display: grid;
}

.video-scene h2 {
  color: #ffdf70;
  font-size: clamp(34px, 6vw, 76px);
  line-height: 1.05;
  margin: 0;
  text-shadow: 0 5px 0 #350b0b;
}

.video-scene button {
  min-width: 180px;
  font-size: 20px;
}

.cutscene.is-open {
  display: grid;
}

.cutscene-card {
  position: relative;
  overflow: hidden;
  width: min(520px, 100%);
  border: 3px solid var(--danger);
  border-radius: 8px;
  background: #120f12;
  text-align: center;
  padding: 26px;
  animation: shake 0.18s steps(2, end) infinite;
}

.cutscene-card img {
  display: block;
  width: min(360px, 90%);
  margin: 0 auto 12px;
  image-rendering: pixelated;
}

.cutscene-card h2 {
  color: #ffdf70;
  font-size: 34px;
  margin: 0 0 18px;
}

.cutscene-card p {
  color: #f5f0d0;
  margin: 0 0 18px;
}

.goal-card {
  border-color: #ffdf70;
  animation: none;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.08) 2px,
    transparent 2px,
    transparent 6px
  );
  mix-blend-mode: screen;
  animation: roll 0.65s linear infinite;
}

@keyframes roll {
  from {
    transform: translateY(-12px);
  }
  to {
    transform: translateY(12px);
  }
}

@keyframes shake {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(2px, -1px);
  }
  100% {
    transform: translate(-1px, 1px);
  }
}

@media (max-width: 680px) {
  .top-panel,
  .info-panel {
    grid-template-columns: 1fr;
  }

  .compass {
    justify-self: start;
  }

  .controls {
    width: min(100%, 360px);
  }
}
