/* 8-bit Retro Cafe — pure CSS pixel art style */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg:         #1a1a2e;
  --panel:      #16213e;
  --panel2:     #0f3460;
  --accent:     #e94560;
  --gold:       #f5a623;
  --green:      #4caf50;
  --text:       #eaeaea;
  --shadow:     #000;
  --pixel:      3px solid #000;
}

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

body {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  image-rendering: pixelated;
}

/* ── HUD ── */
#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: var(--pixel);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel2);
  border: 2px solid #000;
  padding: 4px 8px;
  box-shadow: 2px 2px 0 #000;
}

.hud-item span { color: var(--gold); }

#hud-store-name {
  font-size: 8px;
  color: #aaa;
  margin-left: auto;
}

.hud-btn-group { display: flex; gap: 6px; margin-left: auto; }

/* ── Main scene ── */
#cafe-scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: var(--pixel);
  transition: background 0.5s;
  min-height: 0;
  overflow: hidden;
}

.scene--level-0 { background: #1a0a00; }
.scene--level-1 { background: #2d1b00; }
.scene--level-2 { background: #3d2b10; }
.scene--level-3 {
  background: #4a3520;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 8px, rgba(255,255,255,0.03) 8px, rgba(255,255,255,0.03) 9px),
    repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(255,255,255,0.03) 8px, rgba(255,255,255,0.03) 9px);
}

/* Pixel-art counter shelf */
#cafe-scene::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: #5c3d1a;
  border-top: 4px solid #3a2000;
  box-shadow: inset 0 4px 0 #7a5030;
}

/* ── Customer sprite ── */
.customer-sprite {
  font-size: 40px;
  line-height: 1;
  animation: customer-enter 0.3s steps(3) forwards;
  position: relative;
  z-index: 2;
  filter: drop-shadow(2px 2px 0 #000);
}
.customer-sprite.hidden { display: none; }

.customer-sprite--jinsang  { animation: shake 0.4s steps(2) infinite; }
.customer-sprite--influencer { animation: glow-pulse 1s steps(2) infinite; }

@keyframes customer-enter {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(-4px); }
}
@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px #f5a623) drop-shadow(2px 2px 0 #000); }
  50%       { filter: drop-shadow(0 0 12px #f5a623) drop-shadow(2px 2px 0 #000); }
}

/* ── Speech bubble ── */
#speech-bubble {
  position: relative;
  background: #fff;
  color: #000;
  padding: 6px 10px;
  border: 3px solid #000;
  margin-bottom: 8px;
  max-width: 220px;
  text-align: center;
  z-index: 2;
  box-shadow: 3px 3px 0 #000;
}
#speech-bubble.hidden { display: none; }
#speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 20px;
  border: 6px solid transparent;
  border-top-color: #000;
}
#speech-bubble.bubble-pop {
  animation: pop 0.3s steps(3);
}
@keyframes pop {
  0%   { transform: scale(0.8); }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.bubble-text { display: block; margin-bottom: 4px; font-size: 9px; }

/* Patience bar */
.patience-bar {
  height: 4px;
  background: #ddd;
  border: 1px solid #000;
  overflow: hidden;
}
.patience-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  animation: patience-drain linear forwards;
}
@keyframes patience-drain { to { width: 0%; } }

/* ── Outcome message ── */
.outcome-msg {
  position: absolute;
  top: 30%;
  font-size: 11px;
  pointer-events: none;
  text-align: center;
  z-index: 10;
  animation: pop-up 2s ease-out forwards;
}
.msg--success { color: var(--gold); }
.msg--fail    { color: var(--accent); }
.msg--info    { color: #8af; }

@keyframes pop-up {
  0%   { opacity: 1; transform: translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-50px); }
}

/* ── Controls footer ── */
#controls {
  background: var(--panel);
  border-top: var(--pixel);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  max-height: 45vh;
  overflow-y: auto;
}

/* ── Menu buttons ── */
#menu-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
#menu-buttons.hidden { display: none; }

.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  min-width: 80px;
}
.menu-name  { font-size: 8px; }
.menu-price { font-size: 7px; color: var(--gold); }

.menu-btn--active {
  background: var(--accent) !important;
  animation: btn-pulse 0.6s steps(2) infinite;
}
@keyframes btn-pulse {
  0%, 100% { box-shadow: 4px 4px 0 #000, 0 0 0 2px var(--gold); }
  50%       { box-shadow: 4px 4px 0 #000, 0 0 0 4px var(--gold); }
}

/* ── Pixel button base ── */
.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  border: none;
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  box-shadow: 4px 4px 0 #000, inset 0 0 0 2px rgba(255,255,255,0.1);
  transition: box-shadow 0.05s, transform 0.05s;
  padding: 6px 10px;
  image-rendering: pixelated;
}
.pixel-btn:hover:not(:disabled) {
  background: #1a4a7a;
  box-shadow: 4px 4px 0 #000, 0 0 0 2px var(--gold);
}
.pixel-btn:active:not(:disabled) {
  box-shadow: 1px 1px 0 #000;
  transform: translate(3px, 3px);
}
.pixel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pixel-btn.cant-afford {
  opacity: 0.5;
}

/* ── Event panel ── */
#event-panel {
  background: #200a00;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px #000, 4px 4px 0 #000;
  padding: 10px;
  animation: event-enter 0.3s steps(4) forwards;
}
#event-panel.hidden { display: none; }

@keyframes event-enter {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

#event-title {
  font-size: 10px;
  color: var(--accent);
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
}
#event-desc {
  font-size: 8px;
  color: #ccc;
  margin-bottom: 8px;
  line-height: 1.6;
}
#event-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.choice-btn {
  flex: 1;
  min-width: 120px;
  font-size: 7px;
  padding: 6px 8px;
  border: 2px solid var(--accent);
  background: #3a0a10;
  line-height: 1.5;
}
.choice-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #000;
}

/* ── Upgrade panel ── */
#upgrade-panel {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.upgrade-section {
  background: var(--panel2);
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
  padding: 6px 8px;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upgrade-header {
  display: flex;
  align-items: center;
  gap: 4px;
}
.upgrade-icon  { font-size: 14px; }
.upgrade-label { font-size: 7px; flex: 1; }
.upgrade-level { font-size: 7px; color: var(--gold); }
.upgrade-desc  { font-size: 6px; color: #aaa; line-height: 1.4; min-height: 18px; }
.upgrade-btn   { font-size: 7px; width: 100%; padding: 5px 4px; }
.upgrade-cost  { color: var(--gold); }

/* ── HUD save/reset buttons ── */
.hud-btn {
  font-size: 7px;
  padding: 4px 6px;
}

/* Scrollbar styling */
#controls::-webkit-scrollbar { width: 4px; }
#controls::-webkit-scrollbar-track { background: var(--panel); }
#controls::-webkit-scrollbar-thumb { background: var(--panel2); }
