:root {
  --sky-top: #fbfeff;
  --sky-bottom: #dff5ff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.97);
  --border: rgba(34, 94, 132, 0.12);
  --text-main: #1c4f6d;
  --text-soft: #55738a;
  --blue: #32a7ff;
  --mint: #2ecf97;
  --gold: #ffcb4f;
  --coral: #ff8f63;
  --berry: #ff6989;
  --shadow: 0 22px 60px rgba(60, 104, 144, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 209, 129, 0.48), transparent 30%),
    radial-gradient(circle at bottom right, rgba(71, 199, 183, 0.24), transparent 28%),
    linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  color: var(--text-main);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
  transition: opacity 220ms ease, transform 280ms ease;
}

.panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.card {
  width: min(950px, 100%);
  background:
    radial-gradient(circle at top right, rgba(50, 167, 255, 0.12), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 203, 79, 0.14), transparent 28%),
    linear-gradient(180deg, var(--surface-strong), rgba(255, 255, 255, 0.88));
  border: 1px solid var(--border);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  padding: 38px;
}

.wide-card {
  padding: 28px;
}

.modal-card {
  max-width: 660px;
  padding: 30px 32px;
  text-align: center;
}

.challenge-card {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(50, 167, 255, 0.14);
  color: #14679f;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1,
h2,
.level-card h3,
.stat-box strong {
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

h1,
h2 {
  margin: 14px 0 10px;
  line-height: 0.95;
}

h1 {
  font-size: clamp(3.2rem, 9vw, 5.1rem);
}

h2 {
  font-size: clamp(2rem, 6vw, 3rem);
}

.lead,
.card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
  font-size: 1.06rem;
}

.controls-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(28, 79, 109, 0.08);
  background: rgba(248, 252, 255, 0.92);
}

.controls-card div {
  padding: 12px;
  border-radius: 18px;
  background: rgba(235, 247, 255, 0.95);
}

.toggle-row,
.hero-actions,
.modal-actions,
.panel-header,
.hud,
.hud-actions {
  display: flex;
  align-items: center;
}

.toggle-row {
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(28, 79, 109, 0.08);
  font-weight: 800;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.hero-actions,
.modal-actions {
  gap: 14px;
  margin-top: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.primary-btn,
.secondary-btn,
.small-btn,
.choice-btn {
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.small-btn:hover,
.choice-btn:hover {
  transform: translateY(-2px);
}

.primary-btn {
  padding: 14px 22px;
  background: linear-gradient(180deg, var(--blue), #1b85d9);
  color: white;
  box-shadow: 0 14px 28px rgba(50, 167, 255, 0.26);
  font-weight: 800;
}

.secondary-btn {
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.94);
  color: #17699f;
  border: 1px solid rgba(23, 105, 159, 0.12);
  font-weight: 800;
}

.secondary-btn.compact {
  padding: 12px 16px;
}

.small-btn {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: #17699f;
  font-weight: 800;
}

.small-btn.alt {
  background: rgba(255, 244, 225, 0.96);
  color: #9f6a0e;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.level-card {
  padding: 18px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 251, 255, 0.92));
  border: 1px solid rgba(28, 79, 109, 0.08);
}

.level-card h3 {
  margin: 10px 0 8px;
  font-size: 1.5rem;
}

.level-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(50, 167, 255, 0.12);
  color: #17699f;
  font-size: 0.82rem;
  font-weight: 800;
}

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  justify-content: space-between;
  gap: 12px;
  z-index: 3;
}

.hud.hidden,
.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(28, 79, 109, 0.08);
  box-shadow: 0 10px 20px rgba(24, 71, 108, 0.1);
  font-weight: 800;
}

.hud-actions {
  gap: 10px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 0);
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  color: #17699f;
  box-shadow: 0 18px 34px rgba(24, 71, 108, 0.12);
  border: 1px solid rgba(28, 79, 109, 0.08);
  font-weight: 800;
  z-index: 4;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.choice-btn {
  padding: 14px 16px;
  background: rgba(244, 251, 255, 0.96);
  color: var(--text-main);
  border: 1px solid rgba(28, 79, 109, 0.1);
  text-align: left;
  font-weight: 800;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.stat-box {
  padding: 16px 12px;
  border-radius: 20px;
  background: rgba(242, 250, 255, 0.96);
  border: 1px solid rgba(28, 79, 109, 0.08);
}

.stat-box span {
  display: block;
  font-size: 0.86rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

.challenge-note {
  margin-top: 18px;
}

@media (max-width: 960px) {
  .controls-card,
  .choice-grid,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .hud {
    top: 12px;
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 14px;
  }

  .hero-card,
  .wide-card,
  .modal-card {
    padding: 22px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-pill,
  .hud-actions {
    width: 100%;
    justify-content: center;
  }
}
