:root {
  color-scheme: dark;
  --ink: #15202a;
  --night: #1c2d3a;
  --paper: #f7d99b;
  --paper-light: #ffe8b8;
  --copper: #b46a3c;
  --brick: #9a3f45;
  --teal: #37b8ad;
  --cloud: #c8edf0;
  --gold: #f3b84d;
  --danger: #f15b4a;
  --panel: rgba(21, 32, 42, 0.9);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(35, 60, 74, 0.95), rgba(24, 31, 41, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 232, 184, 0.05) 0 2px, transparent 2px 8px);
  color: var(--paper-light);
  font-family: "Courier New", Courier, monospace;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 24px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
}

.game-header,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header {
  gap: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #fff4d0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 0.95;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.icon-button,
.touch-controls button {
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.primary-button {
  min-width: 142px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
  text-transform: uppercase;
}

.icon-button {
  width: 46px;
  height: 46px;
  font-size: 1.25rem;
  font-weight: 800;
}

.primary-button:hover,
.icon-button:hover,
.touch-controls button:hover {
  filter: brightness(1.08);
}

.primary-button:active,
.icon-button:active,
.touch-controls button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hud div {
  min-height: 62px;
  padding: 10px 12px;
  border: 3px solid rgba(255, 232, 184, 0.22);
  background: var(--panel);
}

.hud div > span,
.hud strong {
  display: block;
}

.hud div > span {
  color: var(--cloud);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.hud strong {
  margin-top: 3px;
  color: #fff4d0;
  font-size: clamp(1rem, 3vw, 1.55rem);
}

.hud strong.life-meter {
  min-height: 26px;
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  align-items: center;
}

.life-pip {
  display: block;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 2px solid #fff1c4;
  background: #f15b4a;
  box-shadow: 0 0 0 2px rgba(21, 32, 42, 0.65), inset 0 0 0 3px #f3b84d;
}

.life-pip.is-empty {
  border-color: rgba(200, 237, 240, 0.35);
  background: rgba(21, 32, 42, 0.78);
  box-shadow: inset 0 0 0 3px rgba(200, 237, 240, 0.12);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  border: 4px solid var(--ink);
  background: #214a5a;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.message-panel {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 32px));
  padding: 14px 18px;
  border: 3px solid var(--ink);
  background: rgba(247, 217, 155, 0.94);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.32);
}

.message-panel strong,
.message-panel span {
  display: block;
}

.message-panel strong {
  margin-bottom: 4px;
  font-size: clamp(1rem, 3vw, 1.55rem);
}

.message-panel span {
  font-size: clamp(0.78rem, 2.4vw, 1rem);
}

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

.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 10px;
  justify-content: center;
  padding-top: 4px;
}

.touch-controls button {
  width: 72px;
  height: 54px;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 720px) {
  .game-shell {
    width: min(100vw - 16px, 640px);
    min-height: auto;
    padding-top: 12px;
    gap: 8px;
    grid-template-rows: auto auto auto auto;
  }

  .game-header {
    align-items: flex-start;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-wrap {
    min-height: 250px;
  }

  .primary-button {
    min-width: 118px;
    padding: 0 12px;
  }
}
