:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --panel2: #0f1830;
  --red: #e94560;
  --orange: #ff6b35;
  --yellow: #ffd23f;
  --navy: #3a4a7a;
  --gray: #5a5a6e;
  --dim: #8a8aa0;
  --ok: #4ade80;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: #fff;
  font-family: 'VT323', monospace;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  overflow-x: hidden;
}

img { image-rendering: pixelated; }

/* pixel font utility */
.gm-title, .gm-subtitle, .panel-title, .section-label, .pix-btn,
.meat-name, .meat-select-tag, .temp-label, .temp-val, .interval-label,
.flip-counter, .preset-chip, .adj-btn, .unit-btn, .lcd-time, .flip-banner,
.tip-label, .achievement, .remix-link, .load-bar-outer + div, .blink,
.gm-footer span, .mute-btn { font-family: 'Press Start 2P', monospace; }

/* ===== Background atmosphere ===== */
body {
  background:
    radial-gradient(circle at 50% -10%, rgba(255,107,53,0.22), transparent 55%),
    repeating-linear-gradient(0deg, #1a1a2e 0px, #1a1a2e 8px, #191930 8px, #191930 16px);
  min-height: 100vh;
}

.scanlines {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0px, rgba(0,0,0,0.18) 1px, transparent 2px, transparent 4px);
  mix-blend-mode: multiply;
}

/* ===== Loading ===== */
.loading-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  font-family: 'Press Start 2P', monospace; padding: 20px;
}
.load-bar-outer {
  width: 240px; max-width: 80vw; height: 22px; background: var(--panel2);
  border: 3px solid var(--orange); padding: 3px;
}
.load-bar-inner {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--orange) 0, var(--orange) 6px, var(--yellow) 6px, var(--yellow) 12px);
  transition: width 0.18s steps(4);
}

/* ===== App layout ===== */
.app-wrap { max-width: 1000px; margin: 0 auto; padding: 16px 12px 40px; }

.gm-header { text-align: center; margin-bottom: 14px; position: relative; }
.grill-mascot { width: 96px; height: 96px; margin: 0 auto 6px; display: block; }
.gm-title {
  font-size: 30px; color: var(--yellow); line-height: 1.2;
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(0,0,0,0.5);
  letter-spacing: 2px;
}
.gm-subtitle { font-size: 9px; color: var(--orange); margin-top: 10px; }

.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ===== Tip bubble ===== */
.tip-bubble {
  background: var(--panel); border: 3px solid var(--navy);
  box-shadow: 5px 5px 0 rgba(0,0,0,0.5); padding: 10px 12px;
  margin: 0 auto 18px; max-width: 620px; text-align: center;
}
.tip-label { font-size: 8px; color: var(--yellow); display: block; margin-bottom: 6px; }
.tip-text { font-family: 'VT323', monospace; font-size: 20px; color: #cdd6f4; line-height: 1.1; }

/* ===== Main grid ===== */
.main-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 780px) { .main-grid { grid-template-columns: 1fr; } }

.section-label { font-size: 10px; color: var(--dim); text-align: center; margin-bottom: 12px; letter-spacing: 1px; }

/* ===== Meat grid ===== */
.meat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px;
}
@media (max-width: 420px) { .meat-grid { grid-template-columns: repeat(2, 1fr); } }

.meat-card {
  background: var(--panel); border: 3px solid #2a3560;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.45); padding: 8px 6px 6px;
  text-align: center; cursor: pointer; transition: transform 0.08s;
}
.meat-card:hover { transform: translate(-1px,-1px); }
.meat-card:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 rgba(0,0,0,0.45); }
.meat-card-sel {
  border-color: var(--orange);
  box-shadow: 4px 4px 0 var(--red);
  background: #21294a;
}
.meat-sprite-box { height: 64px; display: flex; align-items: center; justify-content: center; }
.meat-sprite { width: 60px; height: 60px; }
.meat-emoji { font-size: 40px; }
.meat-name { font-size: 8px; color: #fff; margin-top: 6px; line-height: 1.3; }
.meat-select-tag { font-size: 7px; color: var(--dim); margin-top: 5px; }
.meat-card-sel .meat-select-tag { color: var(--yellow); }

/* ===== HUD panels ===== */
.hud-panel {
  background: var(--panel2); border: 4px solid var(--navy);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5); padding: 14px; position: relative;
}
.panel-title { font-size: 11px; color: var(--yellow); margin-bottom: 12px; text-align: center; }

/* ===== Temp panel ===== */
.unit-toggle-row { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 12px; }
.unit-btn {
  font-size: 9px; padding: 6px 10px; background: var(--panel); color: var(--dim);
  border: 2px solid var(--navy); cursor: pointer;
}
.unit-on { background: var(--orange); color: #fff; border-color: var(--orange); }
.temp-list { display: flex; flex-direction: column; gap: 10px; }
.temp-row { background: var(--panel); border: 2px solid #2a3560; padding: 8px; }
.temp-row-top { display: flex; justify-content: space-between; align-items: center; }
.temp-label { font-size: 8px; color: #cdd6f4; }
.temp-safe { color: var(--ok); }
.temp-val { font-size: 11px; color: var(--yellow); }
.thermo-bar { height: 10px; background: #0a0e1f; border: 1px solid #2a3560; margin-top: 6px; }
.thermo-fill {
  height: 100%;
  background: linear-gradient(90deg, #3a4a7a, var(--yellow), var(--orange), var(--red));
  transition: width 0.3s steps(6);
}
.temp-note { font-family: 'VT323', monospace; font-size: 15px; color: var(--dim); margin-top: 4px; }

/* ===== Timer panel ===== */
.timer-panel { text-align: center; }
.timer-panel.flash { animation: flashbg 0.3s steps(2) 3; }
@keyframes flashbg { 50% { background: var(--red); } }

.flame-stage { position: relative; padding: 14px 0 4px; margin-bottom: 14px; }
.flames { position: absolute; bottom: 0; left: 0; right: 0; height: 40px; display: flex; justify-content: center; gap: 14px; opacity: 0.35; }
.flames-on { opacity: 1; }
.flame { width: 14px; height: 26px; background: var(--orange); border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  box-shadow: 0 0 12px var(--orange); align-self: flex-end; }
.flames-on .flame { animation: flick 0.45s ease-in-out infinite alternate; }
.flame.f2, .flame.f4 { background: var(--yellow); box-shadow: 0 0 10px var(--yellow); height: 20px; }
.flame.f2 { animation-delay: 0.1s; } .flame.f3 { animation-delay: 0.2s; }
.flame.f4 { animation-delay: 0.15s; } .flame.f5 { animation-delay: 0.05s; }
@keyframes flick { from { transform: scaleY(0.8) translateY(3px); } to { transform: scaleY(1.15) translateY(-4px); } }

.lcd-display {
  position: relative; z-index: 2; background: #0a1020; border: 4px solid var(--orange);
  box-shadow: inset 0 0 16px rgba(255,107,53,0.35); padding: 18px 10px; margin: 0 auto; max-width: 300px;
}
.lcd-time { font-size: 42px; color: var(--yellow); text-shadow: 0 0 12px rgba(255,210,63,0.6); letter-spacing: 3px; }
.flip-banner { font-size: 26px; color: var(--red); animation: pop 0.3s steps(2) infinite; }
@keyframes pop { 50% { transform: scale(1.15); color: var(--yellow); } }

.interval-controls { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.adj-btn {
  width: 40px; height: 40px; font-size: 18px; background: var(--navy); color: #fff;
  border: 3px solid #1e2a52; box-shadow: 3px 3px 0 rgba(0,0,0,0.5); cursor: pointer;
}
.adj-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 rgba(0,0,0,0.5); }
.interval-label { font-size: 10px; color: #cdd6f4; min-width: 130px; }

.preset-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.preset-chip {
  font-size: 9px; padding: 6px 9px; background: var(--panel); color: var(--dim);
  border: 2px solid var(--navy); cursor: pointer;
}
.preset-on { background: var(--yellow); color: var(--bg); border-color: var(--yellow); }

.timer-btn-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }

.score-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.flip-counter { font-size: 11px; color: var(--ok); text-shadow: 0 0 8px rgba(74,222,128,0.5); }
.mute-btn { font-size: 8px; padding: 6px 8px; background: var(--panel); color: var(--dim); border: 2px solid var(--navy); cursor: pointer; }

.achievement {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--yellow); color: var(--bg); font-size: 8px; padding: 8px 12px;
  border: 3px solid var(--orange); box-shadow: 3px 3px 0 rgba(0,0,0,0.5); white-space: nowrap; z-index: 10;
  animation: achpop 0.4s steps(3);
}
@keyframes achpop { from { transform: translateX(-50%) scale(0); } to { transform: translateX(-50%) scale(1); } }

/* ===== Pixel Button ===== */
.pix-btn {
  border: 3px solid rgba(0,0,0,0.4); font-family: 'Press Start 2P', monospace;
  cursor: pointer; box-shadow: 4px 4px 0 rgba(0,0,0,0.5); transition: transform 0.06s;
  line-height: 1.4;
}
.pix-btn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 rgba(0,0,0,0.5); }

/* ===== Footer ===== */
.gm-footer {
  margin-top: 30px; padding-top: 16px; border-top: 3px dashed var(--navy);
  text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.gm-footer span { font-size: 8px; color: var(--dim); }
.remix-link {
  font-size: 9px; color: var(--yellow); text-decoration: none;
  border: 2px solid var(--yellow); padding: 8px 14px; box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
}
.remix-link:active { transform: translate(2px,2px); }

/* mobile timer font scaling */
@media (max-width: 480px) {
  .gm-title { font-size: 22px; }
  .lcd-time { font-size: 34px; }
}