:root {
  --night: #0b1030;
  --red: #e0222f;
  --gold: #f2c14e;
  --snow: #f6f4ee;
  --muted: #b9bfd8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  background: #05071a;
  color: var(--snow);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 540 / 800));
  width: min(100vw, calc(100dvh * 540 / 800));
  aspect-ratio: 540 / 800;
  overflow: hidden;
  background: var(--night);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#mute {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(5, 7, 26, 0.6);
  color: var(--snow);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

#pause {
  position: absolute;
  top: 38px;
  right: 10px;
  width: 60px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(5, 7, 26, 0.6);
  color: var(--snow);
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
}

.panel .back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  min-height: 52px;
  margin-top: 12px;
  padding: 10px 18px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(5, 7, 26, 0.55);
  color: var(--snow);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.panel .back:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

#bomb {
  position: absolute;
  right: 10px;
  bottom: 52px;
  min-width: 92px;
  padding: 14px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--gold);
  color: #2a1712;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  touch-action: none;
}

#bomb:disabled {
  background: rgba(5, 7, 26, 0.6);
  color: var(--muted);
  cursor: default;
}

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  padding: 16px;
  background: rgba(5, 7, 26, 0.62);
}

.panel {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

h1 {
  margin: 0 0 10px;
  color: var(--red);
  font-size: clamp(38px, 11vmin, 62px);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-shadow: 0 3px 0 var(--snow), 0 8px 24px rgba(0, 0, 0, 0.7);
}

.panel p {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.35;
}

.panel .help {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.panel .help b {
  color: var(--snow);
}

.panel .stats {
  margin: 14px 0 0;
  color: var(--gold);
  font-size: 15px;
}

.gifts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.gifts button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 92px;
  padding: 6px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(35, 163, 90, 0.35);
  color: var(--snow);
  font: inherit;
  font-size: 44px;
  line-height: 1;
  cursor: pointer;
}

.gifts button:hover:not(:disabled) {
  background: rgba(35, 163, 90, 0.6);
}

.gifts button:disabled {
  background: rgba(242, 193, 78, 0.18);
  cursor: default;
}

.gifts small {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

#overlay-button {
  min-width: 200px;
  padding: 14px 28px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: var(--snow);
  font: inherit;
  font-size: 21px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 #7c0f18;
}

#overlay-button:hover {
  background: #f03340;
}

#overlay-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #7c0f18;
}

#overlay-button:disabled {
  opacity: 0.5;
  cursor: default;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
