:root {
  --bg: #d7f0ff;
  --bg-deep: #8dc6d9;
  --panel: rgba(8, 25, 32, 0.84);
  --panel-soft: rgba(255, 255, 255, 0.14);
  --text: #f4fbff;
  --accent: #ff8a00;
  --accent-2: #ffc458;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 30% 10%, #f5fbff 0%, var(--bg) 35%, var(--bg-deep) 100%);
}

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

.hidden {
  display: none !important;
}

.modal,
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(160deg, rgba(7, 22, 28, 0.92), rgba(6, 40, 53, 0.8));
}

.menu-shell {
  height: 100%;
  width: 100%;
  display: grid;
  place-items: center;
  padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom));
}

.hero-slot {
  position: relative;
  width: min(1180px, 96vw);
  max-height: 92vh;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.45);
  background: #0f1e29;
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 92vh;
  object-fit: contain;
}

.menu-actions {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(560px, 92%);
  display: grid;
  gap: 10px;
  padding: 16px 12px calc(16px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(3, 16, 23, 0.9), rgba(3, 16, 23, 0.08));
  border-radius: 16px 16px 0 0;
}

.menu-btn,
.hud-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-soft);
  backdrop-filter: blur(6px);
}

.menu-btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #102126;
}

#hud {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 10px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.branch-counter {
  min-width: 88px;
  border-radius: 999px;
  background: rgba(255, 254, 224, 0.95);
  color: #3d2a14;
  text-align: center;
  font-weight: 900;
  font-size: clamp(1.2rem, 5vw, 2rem);
  letter-spacing: 0.04em;
  padding: 8px 16px;
  border: 4px solid #ea9c42;
  text-shadow: 1px 1px 0 #fff8d1;
}

.hud-btn {
  border-radius: 999px;
  padding: 10px 16px;
}

.overlay {
  display: grid;
  place-items: center;
}

.overlay-card {
  width: min(92vw, 340px);
  border-radius: 16px;
  background: rgba(4, 19, 25, 0.9);
  color: var(--text);
  padding: 18px;
  text-align: center;
  display: grid;
  gap: 10px;
}

.overlay-card h2 {
  margin: 0;
}

.overlay-card p {
  margin: 0;
}

.overlay-note {
  min-height: 20px;
  font-size: 0.92rem;
  opacity: 0.88;
}

.score-list {
  margin: 0;
  padding: 0 0 0 1.4em;
  text-align: left;
  max-height: 42dvh;
  overflow: auto;
}

.score-list li {
  margin: 3px 0;
  font-weight: 700;
}
