:root {
  --hd-orange: #f96302;
  --hd-dark: #1a1208;
  --hd-shelf: #4a3728;
  --text: #fff8f0;
  --canvas-w: 720px;
  --canvas-h: 400px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(180deg, #2a1808 0%, var(--hd-dark) 40%, #0d0a06 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#app {
  width: min(100%, var(--canvas-w));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#hud {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.hud-item { line-height: 1.1; }
.hud-item--right { text-align: right; }

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffb380;
  opacity: 0.9;
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#title span { color: var(--hd-orange); }

.sound-toggle {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 16px;
  line-height: 34px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.sound-toggle:hover { background: rgba(0, 0, 0, 0.4); }
.sound-toggle:active { transform: scale(0.92); }
.sound-toggle.muted { opacity: 0.55; }

#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 400;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px var(--hd-orange),
    0 16px 48px rgba(0, 0, 0, 0.55);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #c8c0b4;
}

.overlay {
  /* On desktop the card sits centered inside the game stage (a contained menu).
     margin:auto on the card centers it; overflow-y lets it scroll if a viewport
     is ever too short. Small screens promote this to a full-window modal below. */
  position: absolute;
  inset: 0;
  display: flex;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(26, 18, 8, 0.92);
  backdrop-filter: blur(4px);
  z-index: 5;
  padding: 12px;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay-card {
  margin: auto;
  text-align: center;
  padding: 14px 20px;
  max-width: 440px;
  width: 100%;
}

.overlay-face {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(249, 99, 2, 0.6));
  margin-bottom: 6px;
}

.overlay-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.overlay-card p {
  margin: 0 0 12px;
  color: #e8d8c8;
  font-size: 13px;
  line-height: 1.4;
}

.overlay-hint {
  font-size: 11px !important;
  opacity: 0.65;
  margin: 10px 0 6px !important;
}

.overlay-link {
  color: var(--hd-orange);
  font-size: 13px;
  text-decoration: none;
}

.overlay-link:hover { text-decoration: underline; }

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(180deg, #ff8533, var(--hd-orange));
  padding: 11px 32px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(249, 99, 2, 0.45);
}

.btn:active { transform: scale(0.98); }

#touch-controls {
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  user-select: none;
}

.touch-row { display: flex; gap: 8px; }

.touch-btn {
  min-width: 64px;
  height: 56px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  background: rgba(249, 99, 2, 0.2);
  border: 2px solid rgba(249, 99, 2, 0.55);
  border-radius: 12px;
}

.touch-btn.jump {
  font-size: 14px;
  letter-spacing: 0.5px;
}

.touch-btn:active { background: rgba(249, 99, 2, 0.45); }

.site-footer {
  text-align: center;
  font-size: 12px;
}

.site-footer a {
  color: #ffb380;
  text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

@media (hover: none) and (pointer: coarse) {
  #touch-controls { display: flex; }
}

/* On phones the game stage is short, so a contained card would get clipped.
   Promote the overlay to a full-window modal so the Start button is always
   reachable, and keep the content compact. */
@media (max-width: 600px) {
  .overlay {
    position: fixed;
    padding: 20px 16px;
  }
  .overlay-face { width: 64px; height: 64px; margin-bottom: 6px; }
  .overlay-card { padding: 18px 16px; }
  .overlay-card h2 { font-size: 21px; }
  .overlay-card p { font-size: 13px; line-height: 1.4; margin-bottom: 12px; }
  .overlay-hint { margin: 10px 0 8px !important; }
}
