:root {
  --bg: #1b1426;
  --wood: #c98a4b;
  --cream: #fff3d6;
  --ink: #2a1b2e;
  --pink: #ff7fa8;
  --mint: #9be8c9;
  --yellow: #ffd866;
  --red: #ff4d5e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: min(100vw, calc(100vh * 1.6));
  height: auto;
  aspect-ratio: 320 / 200;
  display: block;
  cursor: crosshair;
}

/* HUD */
#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

#dish-name {
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  font-size: 12px;
}

#timers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timer {
  background: var(--ink);
  border: 2px solid var(--cream);
  padding: 4px 6px;
  color: var(--cream);
  min-width: 160px;
}
.timer.golden { border-color: var(--yellow); color: var(--yellow); }
.timer.dead { color: var(--red); border-color: var(--red); }
.timer .lbl { opacity: .6; margin-right: 6px; }

#burns {
  color: var(--red);
  text-shadow: 2px 2px 0 var(--ink);
}

/* Sous-chef */
#chef {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 260px;
  pointer-events: none;
}
.chef-sprite {
  width: 32px; height: 32px;
  background: var(--pink);
  border: 3px solid var(--ink);
  border-radius: 6px 6px 2px 2px;
  flex: none;
  position: relative;
}
.chef-sprite::before {
  content: '';
  position: absolute; left: -3px; right: -3px; top: -12px; height: 12px;
  background: var(--cream); border: 3px solid var(--ink); border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.chef-sprite::after {
  content: '';
  position: absolute; left: 6px; top: 10px; width: 4px; height: 4px;
  background: var(--ink); box-shadow: 12px 0 0 var(--ink);
}
.bubble {
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  padding: 8px;
  line-height: 1.6;
  border-radius: 4px;
  position: relative;
}
.bubble::before {
  content: '';
  position: absolute; left: -9px; top: 10px;
  border: 6px solid transparent; border-right-color: var(--ink); border-left: 0;
}

/* Actions */
#actions {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font-family: inherit;
  font-size: 10px;
  background: var(--yellow);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  text-transform: uppercase;
}
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.danger { background: var(--red); color: var(--cream); }
button.cool { background: var(--mint); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Overlay */
#overlay {
  position: absolute; inset: 0;
  background: rgba(27, 20, 38, .86);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
#overlay-box {
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 24px;
  max-width: 480px;
  text-align: center;
  line-height: 1.8;
}
#overlay-box h1 { font-size: 14px; margin: 0 0 12px; color: var(--ink); }
#overlay-box p { margin: 0 0 14px; }
#overlay-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#overlay-extra canvas { image-rendering: pixelated; border: 3px solid var(--ink); margin-bottom: 12px; }

.hidden { display: none !important; }

/* Smoke alarm */
#alarm {
  position: absolute; inset: 0;
  z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--red);
  animation: strobe .25s steps(2) infinite;
}
@keyframes strobe { 0% { background: var(--red); } 100% { background: #7a0f1c; } }
.alarm-text { font-size: 24px; color: var(--cream); text-shadow: 3px 3px 0 var(--ink); }
.alarm-sub { color: var(--cream); }
#alarm-btn { background: var(--cream); font-size: 14px; padding: 16px 24px; }
#alarm-bar { width: 240px; height: 14px; border: 3px solid var(--ink); background: var(--cream); }
#alarm-fill { height: 100%; width: 0; background: var(--ink); }

/* Dev */
#dev {
  position: fixed; top: 4px; left: 50%; transform: translateX(-50%);
  font-size: 8px; opacity: .5; z-index: 40;
}
#dev button { font-size: 8px; padding: 4px 6px; box-shadow: none; margin-left: 4px; }
#dev:hover { opacity: 1; }

@media (max-width: 600px) {
  #chef { max-width: 160px; }
  .timer { min-width: 120px; }
}

#overlay-extra input {
  font-family: inherit; font-size: 12px; letter-spacing: 4px; text-transform: uppercase;
  background: #fff; color: var(--ink); border: 3px solid var(--ink); padding: 10px; width: 240px; max-width: 100%;
  text-align: center; margin-bottom: 14px; outline: none;
}
