* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
:root {
  --accent: #4ade80;
  --accent2: #facc15;
  --bg: #0b1018;
  --panel: rgba(14, 21, 33, 0.92);
  --text: #f8fafc;
  --border: rgba(255, 255, 255, 0.18);
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.screen { position: fixed; inset: 0; display: none; z-index: 1; }
.screen.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* 3D WORLD & HUD */
#room-canvas-wrap { position: absolute; inset: 0; touch-action: none; }
.room-hud-top {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; z-index: 10; pointer-events: none; flex-wrap: wrap;
}
.hud-left, .hud-stats { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hud-pill {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; background: var(--panel);
  border: 1.5px solid var(--border); backdrop-filter: blur(8px);
  color: #fff; font-size: 13px; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.hud-loc { border-color: var(--accent2); color: #fef08a; }
.pill-dim { color: #94a3b8; font-size: 11px; }
.hud-btn { cursor: pointer; transition: transform 0.12s; }
.hud-btn:active { transform: scale(0.94); }
.bag-btn { border-color: #38bdf8; }
.badge-dot {
  background: #ef4444; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px;
}

/* Toast */
.toast-banner {
  position: absolute; top: 62px; left: 50%; transform: translateX(-50%);
  z-index: 45; background: rgba(16, 24, 39, 0.96); border: 2px solid #facc15;
  color: #fef08a; padding: 10px 18px; border-radius: 999px; font-weight: 800;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); text-align: center;
  max-width: 90vw;
}

/* Contextual Prompts */
.world-prompt, .coin-slot-hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 12; background: rgba(11, 17, 28, 0.94); border: 2px solid var(--accent);
  border-radius: 18px; padding: 12px 18px; text-align: center;
  min-width: 250px; max-width: 88vw; box-shadow: 0 12px 34px rgba(0,0,0,0.65);
}
.coin-slot-hint { border-color: #facc15; pointer-events: none; }
.prompt-badge, .slot-hint-classic {
  font-size: 11px; font-weight: 900; letter-spacing: 1.5px; color: #facc15; margin-bottom: 2px;
}
.prompt-title, .slot-hint-title { font-size: 18px; font-weight: 900; }
.prompt-sub, .slot-hint-sub { font-size: 12px; color: #cbd5e1; margin: 4px 0 8px; }
.action-btn-gold {
  width: 100%; padding: 11px 16px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #facc15, #f97316); color: #111;
  font-weight: 900; font-size: 15px; cursor: pointer; box-shadow: 0 4px 0 #9a3412;
}
.action-btn-gold:active { transform: translateY(2px); }

/* Touch Joystick */
.room-controls {
  position: absolute; bottom: 18px; left: 18px; right: 18px;
  pointer-events: none; z-index: 10; display: flex; justify-content: space-between; align-items: flex-end;
}
.touch-stick { pointer-events: auto; position: relative; width: 112px; height: 112px; touch-action: none; }
.stick-base {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.28);
}
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
  margin-left: -23px; margin-top: -23px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #94a3b8); box-shadow: 0 4px 12px rgba(0,0,0,0.45);
}
.stick-label {
  position: absolute; bottom: -17px; width: 100%; text-align: center;
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: rgba(255,255,255,0.75);
}
.room-hint {
  font-size: 11px; color: rgba(255,255,255,0.78); background: rgba(0,0,0,0.5);
  padding: 6px 12px; border-radius: 999px;
}

/* OVERLAY PANELS (Desk, Change, Reward Counter, Bag, Map) */
.overlay-panel {
  position: fixed; inset: 0; z-index: 35; background: rgba(6, 10, 18, 0.88);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
  padding: 14px; overflow-y: auto;
}
.panel-card {
  width: min(96vw, 560px); max-height: 90vh; overflow-y: auto;
  background: #111827; border: 2px solid rgba(255,255,255,0.2);
  border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.wide-card { width: min(96vw, 920px); }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.panel-header h2 { font-size: 19px; font-weight: 900; color: #facc15; }
.panel-desc { font-size: 13px; color: #cbd5e1; margin-bottom: 12px; line-height: 1.4; }
.close-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: rgba(255,255,255,0.1); color: #fff; font-size: 18px; cursor: pointer;
}

/* Front Desk */
.desk-bubble {
  background: #1e293b; border: 2px solid #38bdf8; border-radius: 16px;
  padding: 14px; font-size: 15px; line-height: 1.45; margin-bottom: 12px; color: #f8fafc;
}
.desk-phone { text-align: center; padding: 20px 10px; background: #1e293b; border-radius: 16px; }
.desk-quest-box {
  background: rgba(250, 204, 21, 0.12); border: 1.5px solid #facc15; border-radius: 14px;
  padding: 10px 12px; margin-bottom: 12px; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px;
}
.desk-btn-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px;
}
.big-simple-btn {
  padding: 13px 12px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.18);
  background: #1f2937; color: #fff; font-weight: 900; font-size: 14px; cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.big-simple-btn:hover, .big-simple-btn:active { border-color: #facc15; transform: scale(0.98); }
.big-simple-btn.green { background: #16a34a; border-color: #86efac; }
.big-simple-btn.gold  { background: #eab308; color: #111; border-color: #fef08a; }
.big-simple-btn.pink  { background: #db2777; border-color: #f9a8d4; }
.desk-detail {
  margin-top: 12px; background: #0f172a; border: 1.5px solid #4ade80;
  border-radius: 14px; padding: 12px; font-size: 14px; line-height: 1.5;
}

/* Change Machine */
.change-visual {
  background: #0f172a; border: 2px solid #4ade80; border-radius: 16px;
  padding: 18px; text-align: center; margin-bottom: 14px;
}
.bill-slot {
  display: inline-block; padding: 10px 20px; border-radius: 10px;
  background: #14532d; border: 2px solid #4ade80; color: #bbf7d0;
  font-weight: 900; font-size: 16px; margin-bottom: 10px;
}
.change-readout { font-family: monospace; font-size: 16px; font-weight: 900; color: #facc15; }

/* Reward Counter & Bag */
.reward-grid, .drawer-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 10px;
}
.reward-card, .drawer-item {
  background: #1e293b; border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 14px; padding: 11px; display: flex; flex-direction: column; gap: 6px;
}
.reward-icon { font-size: 32px; }
.reward-name { font-weight: 900; font-size: 14px; }
.reward-desc { font-size: 11px; color: #cbd5e1; flex: 1; }
.reward-buy-btn {
  padding: 8px; border: none; border-radius: 10px; font-weight: 900; font-size: 12px;
  background: #facc15; color: #111; cursor: pointer;
}
.reward-buy-btn.owned { background: #22c55e; color: #052e16; }
.reward-buy-btn.equipped { background: #38bdf8; color: #082f49; }
.bag-stickers-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px;
  font-size: 20px; min-height: 24px;
}
.bag-toy-stage {
  background: #0f172a; border: 2px solid #38bdf8; border-radius: 16px;
  padding: 14px; margin-bottom: 12px; text-align: center;
}
.popit-grid {
  display: grid; grid-template-columns: repeat(5, 44px); gap: 8px; justify-content: center; margin: 10px auto;
}
.popit-dot {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3);
  cursor: pointer; transition: transform 0.08s;
}
.popit-dot.popped { transform: scale(0.8); filter: brightness(0.55); box-shadow: inset 0 4px 8px rgba(0,0,0,0.6); }

.drawer-section-title { font-size: 12px; font-weight: 900; letter-spacing: 1.5px; color: #facc15; margin: 14px 0 8px; }
.drawer-item-title { font-weight: 800; font-size: 14px; }
.drawer-item-sub { font-size: 11px; color: #94a3b8; }
.mini-btn { padding: 7px 10px; border-radius: 8px; border: none; font-weight: 800; font-size: 11px; cursor: pointer; background: var(--accent); color: #052e16; }

/* ACTIVE GAME MODAL */
#game-modal { background: #070a10; z-index: 25; }
.game-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; background: rgba(14, 20, 30, 0.96);
  border-bottom: 1.5px solid var(--border); gap: 8px; flex-wrap: wrap;
}
.game-topbar-left, .game-topbar-right { display: flex; align-items: center; gap: 10px; }
.top-action-btn {
  padding: 7px 12px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08); color: #fff; font-weight: 800; font-size: 12px; cursor: pointer;
}
.active-game-title { font-weight: 900; font-size: 15px; }
.active-game-sub { font-size: 11px; color: #94a3b8; }
.active-game-hud {
  font-family: monospace; font-weight: 800; font-size: 13px; color: #facc15;
  background: rgba(0,0,0,0.5); padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(250,204,21,0.35);
}
.game-stage {
  flex: 1; position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; overflow: hidden; padding: 6px; touch-action: none;
}

/* Retro CRT & Pads */
.crt-frame {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 100%; height: 100%; gap: 6px;
}
.crt-canvas {
  background: #000; border: 4px solid #334155; border-radius: 14px;
  box-shadow: 0 0 32px rgba(0,0,0,0.8); image-rendering: pixelated;
  max-width: 100%; max-height: calc(100% - 92px); touch-action: none;
}
.pad-bar {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; max-width: 720px; gap: 8px; padding: 4px;
}
.pad-bar.rotated { transform: rotate(180deg); }
.pad-group { display: flex; gap: 8px; align-items: center; }
.pad-btn {
  min-width: 56px; height: 50px; padding: 0 14px; border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.22); background: rgba(30, 41, 59, 0.92);
  color: #fff; font-weight: 900; font-size: 15px; cursor: pointer; touch-action: none;
}
.pad-btn:active, .pad-btn.pressed { background: var(--accent); color: #052e16; transform: scale(0.95); }
.pad-btn.fire { background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: #fca5a5; min-width: 82px; }
.pad-btn.alt  { background: linear-gradient(135deg, #3b82f6, #1d4ed8); border-color: #93c5fd; }

/* Pac-Man Virtual Joystick */
.game-joystick {
  position: relative; width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle, #1e293b, #0f172a);
  border: 3px solid #facc15; touch-action: none; box-shadow: inset 0 0 14px rgba(0,0,0,0.7);
}
.game-joy-knob {
  position: absolute; left: 50%; top: 50%; width: 40px; height: 40px;
  margin-left: -20px; margin-top: -20px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #b91c1c);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6); pointer-events: none;
}

/* 3D Floor Games UI */
.floor3d-wrap { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.floor3d-canvas { width: 100%; height: 100%; border-radius: 12px; overflow: hidden; touch-action: none; }
.floor-overlay-ui {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 10; width: min(95%, 580px); pointer-events: none;
}
.floor-overlay-ui > * { pointer-events: auto; }
.meter-card {
  width: 100%; background: rgba(10, 15, 24, 0.9); border: 2px solid rgba(255,255,255,0.2);
  border-radius: 16px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px;
}
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-label { font-size: 11px; font-weight: 900; width: 64px; letter-spacing: 1px; color: #cbd5e1; }
.meter-track {
  position: relative; flex: 1; height: 18px; border-radius: 999px;
  background: #1e293b; overflow: hidden; border: 1.5px solid rgba(255,255,255,0.2);
}
.meter-sweet { position: absolute; top: 0; bottom: 0; left: 38%; width: 24%; background: rgba(74, 222, 128, 0.32); }
.meter-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0%; background: linear-gradient(90deg, #38bdf8, #4ade80, #facc15, #ef4444); }
.meter-needle { position: absolute; top: -2px; bottom: -2px; width: 8px; margin-left: -4px; border-radius: 4px; background: #fff; box-shadow: 0 0 10px #fff; left: 50%; }
.mode-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mode-pill {
  padding: 7px 12px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(15, 23, 42, 0.9); color: #fff; font-weight: 800; font-size: 12px; cursor: pointer;
}
.mode-pill.active { background: #facc15; color: #111; border-color: #facc15; }
