:root {
  color-scheme: dark;
  --ink: #0b0c0c;
  --panel: rgba(13, 14, 14, 0.78);
  --panel-line: rgba(96, 90, 78, 0.45);
  --text: #d9d0bd;
  --muted: #877f72;
  --red: #d71918;
  --cyan: #1aa7a7;
  --amber: #d7af6b;
  --shadow: rgba(0, 0, 0, 0.64);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background: #050606;
  color: var(--text);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: block;
}

.canvas-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #050606;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: cover;
}

/* Start screen */

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  gap: 22px;
  align-content: start;
  padding-top: 9vh;
  background:
    linear-gradient(rgba(7, 8, 8, 0.32), rgba(7, 8, 8, 0.05) 40%, rgba(7, 8, 8, 0.25)),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.015) 4px 5px);
  transition: opacity 220ms ease, visibility 220ms ease;
}

.start-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-mark {
  color: #d6c5a2;
  font-size: clamp(36px, 8vw, 96px);
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #2a1510, 0 0 48px rgba(215, 25, 24, 0.5);
}

.start-button,
.icon-button,
.debug-toggle {
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid rgba(189, 59, 50, 0.55);
  border-radius: 4px;
  background: rgba(21, 13, 12, 0.85);
  color: #f0d2af;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.start-hint {
  color: #d9d0bd;
  font-size: clamp(16px, 2.4vw, 24px);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  text-shadow: 2px 2px 0 #0a0606;
  animation: start-hint-pulse 1.8s ease-in-out infinite;
}

.start-hint span {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 6px;
  border: 1px solid #6f2b24;
  border-radius: 4px;
  background: rgba(21, 13, 12, 0.85);
  color: #ffd2a8;
  text-align: center;
}

@keyframes start-hint-pulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

.start-tag {
  color: #b7eadb;
  font-size: clamp(13px, 1.8vw, 18px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #0a0606;
  margin-top: -8px;
}

.start-spotify {
  color: #8fd6a8;
  font-size: clamp(12px, 1.5vw, 15px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-shadow: 2px 2px 0 #0a0606;
}

.start-spotify span {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid #1f6e3d;
  border-radius: 4px;
  background: rgba(10, 21, 13, 0.85);
  color: #8fe39a;
  text-align: center;
}

.start-spotify:hover {
  color: #b7f0c8;
}

.start-mechanics {
  margin-top: 18px;
  padding: 12px 18px;
  display: grid;
  gap: 6px;
  background: rgba(5, 6, 6, 0.72);
  border: 1px solid rgba(215, 175, 107, 0.3);
  color: #c9c0ac;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

.start-mechanics span {
  display: inline-block;
  min-width: 52px;
  color: #ffd2a8;
  font-weight: bold;
}

.start-mechanics-note {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(215, 175, 107, 0.18);
  color: rgba(215, 175, 107, 0.85);
  font-size: 11.5px;
}

.icon-button:hover,
.debug-toggle:hover {
  border-color: #bd3b32;
  color: #ffe1bc;
}

/* In-page shop modal */

.shop-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 4, 0.72);
  backdrop-filter: blur(3px);
}

.shop-modal.is-hidden {
  display: none;
}

.shop-frame-wrap {
  width: min(92vw, 980px);
  height: min(88vh, 760px);
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(215, 175, 107, 0.55);
  background: #0a0a0b;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.8);
}

.shop-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(215, 175, 107, 0.35);
  color: var(--amber);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.shop-bar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-bar a {
  color: #b7eadb;
  font-size: 12px;
  text-decoration: none;
}

.shop-bar a:hover {
  text-decoration: underline;
}

.shop-bar button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(189, 59, 50, 0.55);
  border-radius: 4px;
  background: rgba(21, 13, 12, 0.85);
  color: #f0d2af;
  cursor: pointer;
}

#shop-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f4f2ec;
}

/* HUD overlay */

.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: grid;
  grid-template-areas:
    "top    side"
    "bottom side";
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  padding: 14px;
  gap: 14px;
  transition: opacity 200ms ease;
}

.hud.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.hud-top {
  grid-area: top;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  max-width: 320px;
}

.hud-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  align-items: stretch;
  pointer-events: auto;
}

.hud-block {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(6px);
  padding: 10px 14px;
  font-size: 12px;
}

.hud-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.now-playing {
  color: var(--cyan);
  font-size: 18px;
  line-height: 1.15;
  text-shadow: 0 0 12px rgba(26, 167, 167, 0.5);
  margin-bottom: 2px;
}

.zone-label {
  color: #c34836;
  font-size: 12px;
  margin-bottom: 6px;
}

.money-label {
  color: var(--amber);
  font-size: 15px;
  margin-bottom: 6px;
  text-shadow: 0 0 10px rgba(215, 175, 107, 0.4);
}

.meter-canvas {
  width: 100%;
  height: 48px;
  display: block;
  image-rendering: pixelated;
}

.combat-block {
  display: grid;
  gap: 6px;
}

.combat-block.is-hidden {
  display: none;
}

.hp-bar {
  position: relative;
  width: 100%;
  height: 16px;
  background: #1a0807;
  border: 1px solid #45110d;
  overflow: hidden;
}

.hp-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #d72020, #ff8a52);
  transition: width 120ms linear;
}

.hp-text {
  position: relative;
  display: block;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: #fff8e6;
  text-shadow: 1px 1px 0 #000;
}

.combat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #d8c8a4;
}

.combat-row .combat-key {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}

.cleared-banner {
  text-align: center;
  padding: 4px 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #ff8a72;
  border: 1px solid #45110d;
  background: rgba(69, 17, 13, 0.4);
}

.cleared-banner.is-go {
  color: #b7eadb;
  border-color: #1f8f78;
  background: rgba(31, 143, 120, 0.35);
}

.volume-control {
  display: grid;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: auto;
}

.volume-control input {
  width: 100%;
  accent-color: var(--cyan);
}

.icon-button {
  width: 100%;
}

.debug-toggle {
  width: 100%;
  font-size: 10px;
}

.debug-panel {
  margin: 4px 0 0;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  font-size: 11px;
}

.debug-panel.is-hidden {
  display: none;
}

.debug-panel div {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
}

.debug-panel dt {
  color: var(--muted);
  text-transform: uppercase;
}

.debug-panel dd {
  margin: 0;
  color: #cfc2ae;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .hud {
    padding: 10px;
    gap: 10px;
  }

  .hud-top {
    max-width: 220px;
  }

  .now-playing {
    font-size: 15px;
  }
}
