:root {
  color-scheme: light;
  --ink: #263044;
  --muted: #64708b;
  --berry: #ff5f95;
  --orange: #ff9b45;
  --butter: #ffe36e;
  --mint: #54d799;
  --sky: #63d4ff;
  --blue: #526eff;
  --paper: rgba(255, 255, 255, 0.88);
  --shadow: 0 18px 38px rgba(41, 58, 96, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Comic Sans MS", system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 18px, transparent 18px 36px),
    linear-gradient(135deg, #8ee9ff 0%, #fff0a6 35%, #ffb5d4 68%, #b8f5c5 100%);
}

button,
a {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  text-decoration: none;
}

.game-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(9px, 1.8vw, 14px);
  width: min(1220px, 100vw);
  height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 18px);
}

.topbar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(118px, auto);
  align-items: center;
  gap: 12px;
}

.home-link {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 0 rgba(38, 48, 68, 0.14), var(--shadow);
  font-size: 1.45rem;
  font-weight: 1000;
}

.eyebrow,
h1 {
  margin: 0;
}

.eyebrow {
  color: #215a9a;
  font-size: clamp(0.72rem, 1.8vw, 0.9rem);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.7rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.58);
}

.status-pill {
  min-width: 118px;
  max-width: 230px;
  padding: 11px 12px;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  color: #35415f;
  font-size: clamp(0.86rem, 2vw, 1.04rem);
  font-weight: 950;
  line-height: 1.08;
  text-align: center;
}

.hud {
  display: grid;
  grid-template-columns: minmax(86px, 0.75fr) minmax(220px, 2fr) minmax(100px, 0.75fr) minmax(86px, 0.75fr);
  gap: 10px;
}

.hud-card {
  display: grid;
  align-content: center;
  min-height: 64px;
  padding: 8px 12px;
  border: 4px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.hud-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud-card strong {
  color: #263044;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1;
}

.recipe-card {
  gap: 7px;
}

.recipe-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 32px;
}

.recipe-slot {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 36px;
  border-radius: 8px;
  background: rgba(38, 48, 68, 0.08);
  color: #2f3852;
  font-size: clamp(0.78rem, 1.8vw, 0.98rem);
  font-weight: 950;
  line-height: 1;
}

.recipe-slot.done {
  background: linear-gradient(180deg, #76e5a4, #2dbb75);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.14) 52%, rgba(255, 255, 255, 0.1) 100%),
    linear-gradient(180deg, #83dbff 0%, #d9f8ff 54%, #fceab0 100%);
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 46, 70, 0.16);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(440px, 100%);
  padding: clamp(18px, 4vw, 28px);
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  text-align: center;
}

.badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #eaf9ff;
  color: #215a9a;
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.panel p:not(.badge) {
  margin: 14px auto 18px;
  color: #56627b;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  font-weight: 800;
  line-height: 1.28;
}

.primary-button,
.control-button {
  min-height: 58px;
  border: 4px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  color: #fff;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.16), 0 8px 0 rgba(38, 48, 68, 0.14);
  font-weight: 1000;
}

.primary-button {
  min-width: 190px;
  padding: 0 18px;
  background: linear-gradient(180deg, #ff78a8, #f23e85);
  font-size: 1.1rem;
}

.controls {
  display: grid;
  grid-template-columns: minmax(72px, 0.6fr) minmax(180px, 1.4fr) minmax(72px, 0.6fr);
  gap: 10px;
}

.control-button {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0 10px;
  font-size: clamp(1rem, 3vw, 1.2rem);
}

.arrow-button {
  background: linear-gradient(180deg, #6bdcff, #3387f5);
  font-size: clamp(1.45rem, 4vw, 2rem);
}

.bake-button {
  background: linear-gradient(180deg, #ffb74f, #f36b32);
}

.primary-button:active,
.control-button:active,
.control-button.is-pressed {
  transform: translateY(4px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 4px 0 rgba(38, 48, 68, 0.14);
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid #263044;
  outline-offset: 3px;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100svh;
    height: auto;
  }

  .topbar {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .home-link {
    width: 48px;
    height: 48px;
  }

  .status-pill {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-card {
    grid-column: 1 / -1;
    order: -1;
  }

  .stage {
    height: min(58svh, 520px);
    min-height: 360px;
  }
}
