@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/PressStart2P-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/PressStart2P-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: #1a1a2e;
  font-family: 'Press Start 2P', 'Courier New', monospace;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── HUD Header ── */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

#hud::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(40, 22, 12, 0.92) 0%,
    rgba(35, 18, 8, 0.88) 100%
  );
}

#hud-wedge {
  position: absolute;
  top: 0;
  right: 0;
  width: 45%;
  height: 100%;
  background: rgba(20, 8, 2, 0.5);
  clip-path: polygon(30% 0, 100% 0, 100% 100%, 0% 100%);
}

#hud-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  height: 100%;
  padding: 14px 20px 10px;
  padding-top: max(14px, env(safe-area-inset-top));
}

/* ── HUD Left Column ── */

#hud-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex-shrink: 1;
}

#order-line {
  font-size: 0.65rem;
  color: #fff;
  white-space: nowrap;
  line-height: 1.4;
}

.hud-label {
  color: #fff;
}

#order-value {
  color: #ffc832;
  margin-left: 2px;
}

#doneness-display {
  font-size: 0.5rem;
  color: #bbb;
  white-space: nowrap;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

/* ── Cook Progress Bar ── */

#cook-bar-wrap {
  position: relative;
  width: 160px;
  max-width: 40vw;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  margin-top: 3px;
}

#cook-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffc832, #ffb300);
  border-radius: 1px;
  transition: width 0.15s linear, background 0.3s ease;
}

#cook-bar-fill.zone-raw {
  background: linear-gradient(90deg, #f5e6c8, #e8d9a8);
}
#cook-bar-fill.zone-golden {
  background: linear-gradient(90deg, #ffc832, #ffb300);
}
#cook-bar-fill.zone-browned {
  background: linear-gradient(90deg, #d4882a, #b86e1a);
}
#cook-bar-fill.zone-burnt {
  background: linear-gradient(90deg, #cc3300, #aa1100);
}

#cook-bar-shimmer {
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.25),
    transparent
  );
  animation: shimmer 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { left: -40%; }
  100% { left: 140%; }
}

/* ── HUD Center ── */

#hud-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 14px;
  top: max(14px, env(safe-area-inset-top));
  text-align: center;
  pointer-events: none;
}

#game-title {
  font-size: 0.85rem;
  color: #ffc832;
  letter-spacing: 3px;
  text-shadow:
    0 0 8px rgba(255, 200, 50, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  line-height: 1.3;
}

/* ── HUD Right ── */

#hud-right {
  text-align: right;
  flex-shrink: 0;
}

#score-display {
  font-size: 0.65rem;
  color: #fff;
  white-space: nowrap;
  line-height: 1.4;
}

#score-value {
  color: #ffc832;
}

/* ── Popups ── */

.popup {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 32px;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'Press Start 2P', monospace;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.popup.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px) scale(0.8);
}

.popup.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

#flip-popup {
  top: 38%;
  background: rgba(255, 160, 0, 0.92);
  color: #fff;
  border: 3px solid #fff;
}

#result-popup {
  top: 46%;
  font-size: 1.2rem;
}

#result-popup.success {
  background: rgba(40, 180, 80, 0.92);
  color: #fff;
  border: 3px solid #fff;
}

#result-popup.fail {
  background: rgba(200, 50, 50, 0.92);
  color: #fff;
  border: 3px solid #fff;
}

/* ── Serve Button ── */

#serve-btn {
  position: fixed;
  bottom: 28px;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 44px;
  font-size: 0.85rem;
  font-family: 'Press Start 2P', monospace;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #ff6b35, #ff4500);
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  z-index: 10;
  touch-action: manipulation;
  box-shadow: 0 4px 20px rgba(255, 69, 0, 0.4);
  transition: transform 0.1s ease;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

#serve-btn:active {
  transform: translateX(-50%) scale(0.94);
}

/* ── Responsive ── */

@media (max-width: 520px) {
  #hud { height: 100px; }
  #hud-content { padding: 10px 12px 8px; }
  #game-title { font-size: 0.55rem; letter-spacing: 1px; }
  #order-line { font-size: 0.5rem; }
  #doneness-display { font-size: 0.42rem; }
  #score-display { font-size: 0.5rem; }
  #cook-bar-wrap { width: 120px; height: 12px; }
  .popup { font-size: 0.8rem; padding: 10px 22px; }
  #serve-btn { font-size: 0.7rem; padding: 12px 32px; }
}

@media (min-width: 900px) {
  #hud { height: 120px; }
  #game-title { font-size: 1.1rem; letter-spacing: 5px; }
  #order-line { font-size: 0.75rem; }
  #doneness-display { font-size: 0.6rem; }
  #score-display { font-size: 0.75rem; }
  #cook-bar-wrap { width: 200px; height: 16px; }
}
