:root {
  color-scheme: dark;
  --bg: #120e0b;
  --panel: #1e1814;
  --panel-2: #2a221c;
  --text: #f6efe4;
  --muted: #c4b5a0;
  --accent: #f0d36a;
  --accent-dim: #8a7340;
  --green: #6db86a;
  --stone: #8a827a;
  --danger: #c97868;
  --btn: #352b24;
  --line: #4a3d32;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 50% -10%, #3a2a18 0%, transparent 50%),
    radial-gradient(circle at 80% 110%, #1a2a18 0%, var(--bg) 45%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 12px;
}

.shell {
  position: relative;
}

.panel {
  width: min(880px, 96vw);
  padding: 24px 24px 20px;
  background: linear-gradient(180deg, #261e18, var(--panel));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(240, 211, 106, 0.08);
}

.splash h1,
.modal h1 {
  margin: 6px 0 12px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.kicker {
  margin: 0;
  letter-spacing: 0.22em;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  line-height: 1.5;
  max-width: 42rem;
}

.lead em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.best {
  display: inline-block;
  margin: 16px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #2f261e;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.92rem;
}

.splash-legend,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.splash-legend {
  margin-top: 20px;
}

.legend {
  margin: 4px 0 0;
  padding-top: 4px;
  border-top: 1px solid rgba(74, 61, 50, 0.6);
}

.lg {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border-radius: 4px;
}

.lg-hatch {
  background: #1a1410;
  border: 2px solid #c9a227;
  border-radius: 50%;
}

.lg-cocoon {
  background: #f3e6c4;
  border: 2px solid #d4b36a;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.lg-stone {
  background: var(--stone);
}

.lg-hedge {
  background: var(--green);
}

.lg-path {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  height: 4px;
  width: 18px;
  vertical-align: 2px;
  border-radius: 2px;
}

.lg-worm {
  background: #e8b86d;
  border-radius: 50%;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 8px 0 16px;
}

.step {
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.step h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.step-n {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: #3d3220;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.keys-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
}

button.primary {
  background: linear-gradient(180deg, #6a5820, #4a3c14);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

button.primary.wide {
  flex: 1 1 220px;
}

button.danger {
  border-color: #6a3a32;
  color: #f0c2b8;
}

button:hover:not(:disabled) {
  filter: brightness(1.1);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.playfield {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat.accent {
  border-color: var(--accent-dim);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat strong {
  font-size: 1.25rem;
  font-weight: 700;
}

.lives {
  letter-spacing: 0.12em;
  color: var(--accent);
}

.star-row {
  display: grid;
  gap: 6px;
}

.star-bar {
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: #2c241c;
  overflow: hidden;
}

.star-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c9a227, var(--accent));
  border-radius: inherit;
  transition: width 0.15s ease;
}

.star-marks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.path-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #2a231c;
  color: var(--text);
  font-size: 0.95rem;
}

.status.warn {
  background: #3a241c;
  color: #f3cbb8;
}

.status.go {
  background: #2a2818;
  color: var(--accent);
}

canvas {
  display: block;
  width: 100%;
  max-width: 800px;
  background: #241c16;
  border-radius: 12px;
  outline: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

canvas:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 8, 6, 0.62);
  border-radius: 20px;
}

.modal {
  width: min(420px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal .actions {
  justify-content: center;
}

.stars-big {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.2em;
  color: var(--accent);
}

@media (max-width: 640px) {
  .stat-bar {
    grid-template-columns: 1fr 1fr;
  }
}
