* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #0b0c0f;
  color: #f4f2ea;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game {
  width: min(780px, 100%);
  height: 100dvh;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 14px;
}

.game-info {
  width: min(780px, 100%);
  padding: 36px 18px 64px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.game-info .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  color: #b8bec9;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s;
}

.game-info .back-link:hover { color: #f4f2ea; }

.game-info h1 {
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #f4f2ea;
}

.game-info p {
  margin: 0 0 12px;
  color: #b8bec9;
  line-height: 1.75;
  max-width: 64ch;
}

.game-info h2 {
  margin: 28px 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #f7b84b;
}

.game-info hr {
  margin: 28px 0 0;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.game-info ul {
  margin: 0;
  padding-left: 20px;
  color: #b8bec9;
  line-height: 2;
}

.game-info .more-games-link {
  display: inline-block;
  margin-top: 36px;
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #f4f2ea;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.game-info .more-games-link:hover { background: rgba(255, 255, 255, 0.13); }

.hud {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  color: #b8bec9;
}

.hud strong {
  color: #f4f2ea;
}

.hp-bar {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
  border-radius: 5px;
  padding: 2px;
  transition: box-shadow 0.15s ease;
}

.hp-seg {
  display: block;
  width: 14px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease, transform 0.15s ease;
}

.hp-seg.filled {
  background: #f05d5e;
}

.hp-seg.just-lost {
  background: #fff;
  transform: scale(1.25);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

canvas {
  grid-column: 1 / -1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: #151820;
  touch-action: none;
}

button {
  grid-row: 3;
  justify-self: start;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f2ea;
  font: inherit;
  cursor: pointer;
}

.action {
  grid-column: 3;
  justify-self: end;
  background: #f7b84b;
  color: #1b1205;
  font-weight: 800;
}

/* Arcade joystick + d-pad controls (injected by action-pack.js) */

.game:has(.controls) {
  grid-template-rows: auto 1fr auto auto;
}

.game:has(.controls) > div:has(#restart) {
  grid-column: 1 / -1;
  grid-row: 4;
}

.game:has(.controls) .action {
  display: none;
}

.controls {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px;
  touch-action: none;
  user-select: none;
}

.joystick {
  position: relative;
  width: clamp(72px, 18vh, 120px);
  height: clamp(72px, 18vh, 120px);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  touch-action: none;
  flex-shrink: 0;
}

.joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44%;
  height: 44%;
  margin-left: -22%;
  margin-top: -22%;
  border-radius: 50%;
  background: rgba(247, 184, 75, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
  width: clamp(72px, 18vh, 120px);
  height: clamp(72px, 18vh, 120px);
  flex-shrink: 0;
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-row: auto;
  grid-column: auto;
  justify-self: stretch;
  align-self: stretch;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f2ea;
  padding: 0;
  touch-action: none;
}

.dpad-btn:active,
.dpad-btn.active {
  background: #f7b84b;
  border-color: #f7b84b;
}
