/* Bite2Go — Clean, modern game UI */

:root {
  --bg: #0d0d0f;
  --surface: #16161a;
  --surface-hover: #1e1e24;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #f97316;
  --accent-glow: rgba(249, 115, 22, 0.4);
  --success: #22c55e;
  --combo: #eab308;
  --radius: 16px;
  --font: 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* ——— Vending machine frame ——— */
#vending-frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 24px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 1;
}

#vending-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 2px solid rgba(255, 255, 255, 0.06);
}

#header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.btn-icon:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.hidden {
  display: none !important;
}

.btn-icon-ghost {
  background: transparent;
  border-color: transparent;
  font-size: 1.25rem;
}

.start-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 13, 15, 0.95);
  backdrop-filter: blur(12px);
}

.overlay.hidden {
  display: none !important;
}

.overlay-content {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 28px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.overlay-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.overlay-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.overlay-pause .btn-primary,
.overlay-pause .btn-secondary {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}

.setting-hint,
.pause-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.setting-row label {
  font-size: 1rem;
  cursor: pointer;
}

.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-small {
  margin-bottom: 12px;
  padding: 10px 20px;
  font-size: 0.9rem;
}

.ach-heading {
  font-size: 1rem;
  margin: 0.5rem 0 0.25rem;
  color: var(--text-muted);
}

.ach-list {
  text-align: left;
  margin: 1rem 0;
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  font-size: 0.9rem;
  max-height: 160px;
  overflow-y: auto;
}

.ach-item {
  padding: 4px 0;
  color: var(--text-muted);
}

.ach-item.unlocked {
  color: var(--combo);
}

#final-vs-best.hidden {
  display: none !important;
}

.achievements-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--combo);
}

.achievements-row.hidden {
  display: none !important;
}

.achievement-badge {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 8px;
  padding: 4px 10px;
}

#btn-try-other.hidden {
  display: none !important;
}

#vending-title {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

#vending-display {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 8px 14px;
  background: rgba(13, 13, 15, 0.95);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

#vending-window {
  position: relative;
  flex: 1;
  min-height: 200px;
  background: var(--bg);
  border-radius: 0 0 17px 17px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
}
#vending-window::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0 0 17px 17px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.15) 100%);
  pointer-events: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  border-radius: 0 0 14px 14px;
}

#vending-display #score {
  color: var(--text);
  transition: transform 0.15s ease;
}

#vending-display #score.score-pop {
  transform: scale(1.15);
}

#vending-display .combo-pop {
  transform: scale(1.1);
}

#vending-display #combo {
  color: var(--combo);
  font-size: 0.95rem;
  opacity: 1;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

#vending-display #combo.combo-hidden {
  opacity: 0;
  transform: scale(0.9);
}

#vending-display #timer {
  color: var(--text-muted);
  font-weight: 600;
  min-width: 2ch;
  text-align: right;
}

#vending-display #timer.warning {
  color: var(--accent);
  animation: pulse 0.8s ease-in-out infinite;
}

#high-score-wrap {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.vending-label {
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.85;
  margin-right: 2px;
}

#high-score-wrap #high-score {
  color: var(--text);
}

#phase-indicator.phase-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 1ch;
}

#phase-indicator.phase-num[data-phase="2"],
#phase-indicator.phase-num[data-phase="3"],
#phase-indicator.phase-num[data-phase="4"] {
  color: var(--accent);
}

@keyframes pulse {
  50% { opacity: 0.7; }
}

/* ——— Screens ——— */
#screen-start,
#screen-end {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 13, 15, 0.94);
  backdrop-filter: blur(20px);
  z-index: 10;
  text-align: center;
}

.screen-content {
  max-width: 320px;
}

#screen-start h1,
#screen-end h2 {
  font-weight: 800;
  font-size: clamp(2.5rem, 10vw, 4rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.logo .accent {
  color: var(--accent);
}

.age-badge {
  display: inline-block;
  font-size: 0.5em;
  font-weight: 700;
  vertical-align: middle;
  padding: 0.15em 0.4em;
  margin-left: 0.25em;
  background: var(--accent);
  color: var(--bg);
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.age-badge-small {
  font-size: 0.45em;
  padding: 0.1em 0.3em;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  font-weight: 500;
}

#mode-select {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 280px;
}

.btn-mode {
  flex: 1;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.btn-mode:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-mode.btn-mode-active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.mode-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  min-height: 2.5em;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 1.5rem;
  max-width: 280px;
  line-height: 1.4;
}

#lives-wrap {
  font-size: 1rem;
  font-weight: 700;
  color: #ef4444;
}

#lives-wrap.hidden {
  display: none !important;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 1rem;
  width: 100%;
  max-width: 240px;
}

.btn-secondary {
  pointer-events: auto;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
  pointer-events: auto;
  padding: 16px 40px;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.btn-primary:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 32px var(--accent-glow);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-mode:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#screen-end h2 {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  margin-bottom: 0.25rem;
}

#final-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0.5rem 0;
}

#final-bites.sub,
#final-combo.sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

#final-combo.sub {
  margin-bottom: 1.5rem;
}

.final-new-high {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

#final-survived {
  margin-bottom: 0.25rem;
}

#final-survived.hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}
