:root {
  color-scheme: dark;
  --bg: #0c1010;
  --ink: #f5d89b;
  --muted: #9a7d56;
  --line: #684a2e;
  --panel: #141512;
  --red: #d84437;
  --blue: #3474c9;
  --green: #69ad44;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    var(--bg);
  background-size: 4px 4px;
  color: var(--ink);
  font-family: "Courier New", monospace;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 960px) 280px;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.game-wrap {
  position: relative;
  width: min(960px, calc(100vw - 336px));
  aspect-ratio: 3 / 2;
  border: 3px solid var(--line);
  background: #080b0b;
  box-shadow: 0 0 0 4px #18130e, 0 16px 40px rgba(0, 0, 0, 0.55);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.panel {
  min-height: 640px;
  border: 3px solid var(--line);
  background: linear-gradient(#191915, #10110f);
  padding: 14px;
  box-shadow: 0 0 0 4px #18130e;
}

.brand {
  color: #f4be62;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  line-height: 1.1;
  margin-bottom: 18px;
}

.meters {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.meters label {
  display: grid;
  gap: 4px;
  color: var(--ink);
  font-size: 13px;
}

.bar {
  height: 18px;
  border: 2px solid #9d6b2d;
  background: #0a0b0b;
  padding: 2px;
}

.bar span {
  display: block;
  width: 100%;
  height: 100%;
  transition: width 120ms linear;
}

.hp {
  background: linear-gradient(90deg, #7e171d, var(--red));
}

.mp {
  background: linear-gradient(90deg, #163b7d, var(--blue));
}

.xp {
  background: linear-gradient(90deg, #305c22, var(--green));
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-grid div {
  min-height: 58px;
  border: 2px solid #5d432c;
  background: #0b0d0c;
  display: grid;
  place-items: center;
  padding: 6px;
}

.stat-grid span {
  color: #f3d367;
  font-size: 21px;
  line-height: 1;
}

.stat-grid small {
  color: var(--muted);
  font-size: 10px;
}

#minimap {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border: 2px solid #835b2c;
  image-rendering: pixelated;
  background: #08100f;
}

.sheet-loader {
  display: block;
  margin: 12px 0 6px;
  border: 2px solid #8a5b2d;
  background: #1e160d;
  color: #f1d59b;
  text-align: center;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
}

.sheet-loader input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.sheet-status {
  min-height: 16px;
  color: #f0b66b;
  font-size: 11px;
  margin-bottom: 10px;
}

.inventory {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin: 14px 0;
}

.slot {
  aspect-ratio: 1;
  border: 2px solid #7a552e;
  background: #10100d;
  display: grid;
  place-items: center;
  color: #efc55d;
  font-size: 20px;
}

.controls {
  display: grid;
  gap: 8px;
  color: #bca77c;
  font-size: 12px;
  line-height: 1.25;
}

.panel-button {
  width: 100%;
  margin-top: 14px;
  border: 2px solid #b8772d;
  background: #2a2011;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
  text-transform: uppercase;
}

.panel-button:hover,
.panel-button:focus-visible {
  background: #3a2813;
  outline: 2px solid #e0a64d;
  outline-offset: 2px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 5, 5, 0.78);
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  width: min(420px, 86%);
  border: 3px solid #9a672d;
  background: #12130f;
  text-align: center;
  padding: 22px;
  box-shadow: 0 0 0 4px #261b10;
}

.overlay-panel h1 {
  margin: 0 0 12px;
  color: #f4be62;
  font-size: 28px;
  line-height: 1.1;
}

.overlay-panel p {
  margin: 0 0 16px;
  color: #d7c090;
}

.overlay-panel button {
  border: 2px solid #b8772d;
  background: #2a2011;
  color: var(--ink);
  padding: 8px 18px;
  cursor: pointer;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 10px;
  }

  .game-wrap {
    width: 100%;
  }

  .panel {
    min-height: 0;
  }
}
