* {
  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.9); --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, 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 & MINIMAL HUD */
#room-canvas-wrap { position: absolute; inset: 0; touch-action: none; }
.room-hud-top {
  position: absolute; top: 6px; left: 6px; right: 6px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 5px; z-index: 10; pointer-events: none; flex-wrap: wrap;
}
.hud-left, .hud-stats { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.hud-pill {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: 999px; background: var(--panel);
  border: 1.5px solid var(--border); color: #fff; font-size: 12px; font-weight: 800;
}
.hud-loc { border-color: var(--accent2); color: #fef08a; }
.pill-dim { color: #94a3b8; font-size: 10px; }
.hud-btn { cursor: pointer; }
.hud-btn:active { transform: scale(0.92); }
.bag-btn { border-color: #38bdf8; }
.badge-dot { background: #ef4444; color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 999px; }

.toast-banner {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  z-index: 45; background: rgba(15,23,42,0.95); border: 2px solid #facc15;
  color: #fef08a; padding: 7px 14px; border-radius: 999px; font-weight: 800;
  font-size: 13px; text-align: center; max-width: 90vw; pointer-events: none;
}
.broke-banner {
  position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: rgba(127,29,29,0.96); border: 2px solid #facc15;
  color: #fff; padding: 8px 14px; border-radius: 14px; font-weight: 800;
  font-size: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 92vw;
}

.room-controls { position: absolute; bottom: 16px; left: 16px; pointer-events: none; z-index: 10; }
.touch-stick { pointer-events: auto; position: relative; width: 106px; height: 106px; touch-action: none; }
.stick-base { position: absolute; inset: 0; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.28); }
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #94a3b8);
}

/* OVERLAY PANELS */
.overlay-panel {
  position: fixed; inset: 0; z-index: 35; background: rgba(6,10,18,0.88);
  display: flex; align-items: center; justify-content: center; padding: 12px; 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: 20px; padding: 16px;
}
.wide-card { width: min(96vw, 940px); }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.panel-header h2 { font-size: 17px; font-weight: 900; color: #facc15; }
.close-btn { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--border); background: rgba(255,255,255,0.1); color: #fff; font-size: 18px; cursor: pointer; }

/* Customizer */
.cust-row { margin-bottom: 12px; }
.cust-row label { display: block; font-size: 12px; font-weight: 800; color: #94a3b8; margin-bottom: 6px; text-transform: uppercase; }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.active { border-color: #fff; transform: scale(1.12); }

/* Front Desk */
.desk-bubble { background: #1e293b; border: 2px solid #38bdf8; border-radius: 14px; padding: 12px; font-size: 14px; line-height: 1.45; margin-bottom: 10px; }
.call-mom-box { background: rgba(22,163,74,0.18); border: 2px solid #4ade80; border-radius: 14px; padding: 12px; text-align: center; margin-bottom: 10px; }
.desk-phone { text-align: center; padding: 18px 10px; background: #1e293b; border-radius: 14px; }
.desk-quest-box, .desk-diff-box {
  background: rgba(250,204,21,0.12); border: 1.5px solid #facc15; border-radius: 12px;
  padding: 9px 11px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px;
}
.desk-diff-box { background: rgba(56,189,248,0.12); border-color: #38bdf8; }
.desk-btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 7px; }
.big-simple-btn {
  padding: 11px 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.18);
  background: #1f2937; color: #fff; font-weight: 900; font-size: 13px; cursor: pointer;
}
.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; }
.big-simple-btn.red   { background: #dc2626; border-color: #fca5a5; }
.desk-detail { margin-top: 10px; background: #0f172a; border: 1.5px solid #4ade80; border-radius: 12px; padding: 10px; font-size: 13px; line-height: 1.45; }

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

/* Reward Counter & Bag */
.reward-grid, .drawer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.reward-card, .drawer-item { background: #1e293b; border: 1.5px solid rgba(255,255,255,0.14); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 5px; }
.reward-icon { font-size: 28px; }
.reward-name { font-weight: 900; font-size: 13px; }
.reward-desc { font-size: 11px; color: #cbd5e1; flex: 1; }
.reward-buy-btn { padding: 7px; border: none; border-radius: 9px; font-weight: 900; font-size: 11px; 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: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; font-size: 18px; }
.bag-toy-stage { background: #0f172a; border: 2px solid #38bdf8; border-radius: 14px; padding: 12px; margin-bottom: 10px; text-align: center; }
.popit-grid { display: grid; grid-template-columns: repeat(5, 40px); gap: 7px; justify-content: center; margin: 8px auto; }
.popit-dot { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3); cursor: pointer; }
.popit-dot.popped { transform: scale(0.8); filter: brightness(0.5); }

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

/* ACTIVE GAME MODAL (Minimal Top Bar!) */
#game-modal { background: #070a10; z-index: 25; }
.game-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px; background: rgba(14,20,30,0.96);
  border-bottom: 1.5px solid var(--border); gap: 6px;
}
.game-topbar-left, .game-topbar-right { display: flex; align-items: center; gap: 8px; }
.top-action-btn { padding: 6px 10px; border-radius: 9px; 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: 13px; }
.active-game-hud { font-family: monospace; font-weight: 800; font-size: 12px; color: #facc15; background: rgba(0,0,0,0.5); padding: 4px 8px; border-radius: 7px; }
.game-stage { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: 4px; touch-action: none; }

/* Big Winner Notice Overlay */
.win-banner {
  position: absolute; inset: 0; z-index: 40; background: rgba(5,8,16,0.82);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.win-banner-card {
  background: linear-gradient(145deg, #1e1b4b, #0f172a); border: 4px solid #facc15;
  border-radius: 24px; padding: 28px 34px; text-align: center; max-width: 90vw;
  box-shadow: 0 0 50px rgba(250,204,21,0.5); animation: popWin 0.25s ease-out;
}
@keyframes popWin { from { transform: scale(0.75); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-banner-title { font-size: clamp(26px, 6vw, 44px); font-weight: 900; color: #facc15; text-shadow: 0 3px 0 #000; }
.win-banner-sub { font-size: 15px; color: #e2e8f0; margin-top: 6px; font-weight: 700; }

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

.game-joystick { position: relative; width: 88px; height: 88px; border-radius: 50%; background: radial-gradient(circle, #1e293b, #0f172a); border: 3px solid #facc15; touch-action: none; }
.game-joy-knob { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #ff6b6b, #b91c1c); 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: 10px; overflow: hidden; touch-action: none; }
.floor-overlay-ui { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 10; width: min(95%, 580px); pointer-events: none; }
.floor-overlay-ui > * { pointer-events: auto; }
.action-btn-gold { width: 100%; padding: 10px 14px; border: none; border-radius: 12px; background: linear-gradient(135deg, #facc15, #f97316); color: #111; font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: 0 3px 0 #9a3412; }
.meter-card { width: 100%; background: rgba(10,15,24,0.88); border: 2px solid rgba(255,255,255,0.2); border-radius: 14px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.meter-row { display: flex; align-items: center; gap: 8px; }
.meter-label { font-size: 10px; font-weight: 900; width: 56px; color: #cbd5e1; }
.meter-track { position: relative; flex: 1; height: 16px; 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: 42%; width: 16%; background: rgba(74,222,128,0.35); }
.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; left: 50%; }
.mode-pills { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.mode-pill { padding: 6px 10px; border-radius: 999px; border: 1.5px solid rgba(255,255,255,0.25); background: rgba(15,23,42,0.92); color: #fff; font-weight: 800; font-size: 11px; cursor: pointer; }
.mode-pill.active { background: #facc15; color: #111; border-color: #facc15; }
