:root {
  --bg: #0d0d12;
  --panel: rgba(10, 10, 18, 0.92);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #f5c542;
  --accent2: #e67e22;
  --green: #4caf50;
  --red: #f44336;
  --blue: #42a5f5;
  --text: #f0f0f0;
  --text-dim: rgba(240, 240, 240, 0.55);
  --text-muted: rgba(240, 240, 240, 0.3);
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.7);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #87ceeb; }
body { font-family: 'Inter', sans-serif; color: var(--text); user-select: none; }
.hidden { display: none !important; }

#gameCanvas { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: block; outline: none; cursor: crosshair; }

/* Loading */
#loading-screen { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.loading-content { text-align: center; }
.loading-icon { font-size: 64px; animation: spin 1s linear infinite; display: block; }
.loading-title { font-family: 'Press Start 2P', monospace; font-size: 22px; color: var(--accent); margin: 16px 0 4px; }
.loading-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.loading-bar { width: 280px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; margin: 0 auto 12px; overflow: hidden; }
.loading-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; width: 0%; }
.loading-tip { color: var(--text-muted); font-size: 11px; font-style: italic; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Login */
#login-screen, #title-screen { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 50%, rgba(26,21,48,0.8) 0%, rgba(13,13,18,0.95) 80%); backdrop-filter: blur(4px); }
.login-content, .title-content { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 32px; width: 380px; max-width: 90%; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.login-logo, .title-logo { font-size: 56px; filter: drop-shadow(0 0 24px rgba(245,197,66,0.4)); }
.login-title, .game-title { font-family: 'Press Start 2P', monospace; font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.login-tagline, .game-subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.login-tabs { display: flex; gap: 4px; }
.login-tab { flex: 1; padding: 8px; background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.login-tab.active { background: var(--accent); color: #0d0d12; border-color: var(--accent); font-weight: 700; }
#login-form, #register-form { display: flex; flex-direction: column; gap: 10px; }
input[type=text], input[type=password] { padding: 10px 12px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); color: var(--text); border-radius: var(--radius); font-size: 14px; font-family: inherit; }
input:focus { outline: none; border-color: var(--accent); }
.btn-auth, .btn-title { padding: 12px; background: var(--accent); color: #0d0d12; border: none; border-radius: var(--radius); font-weight: 700; cursor: pointer; transition: transform 0.15s; font-family: inherit; font-size: 14px; }
.btn-auth:hover, .btn-title:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,197,66,0.4); }
.btn-auth-skip { padding: 10px; background: transparent; color: var(--text-dim); border: 1px solid var(--panel-border); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-family: inherit; }
.btn-auth-skip:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }
.auth-error { color: var(--red); font-size: 12px; min-height: 16px; }
.login-divider { color: var(--text-muted); font-size: 11px; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-title.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--panel-border); }
.title-hint { color: var(--text-muted); font-size: 11px; margin-top: 8px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
#hud-top-left { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
#hud-money, #hud-rep, #profile-badge { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 6px 12px; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; backdrop-filter: blur(8px); }
.money-val { color: var(--accent); font-family: 'VT323', monospace; font-size: 18px; }
#profile-badge { color: var(--blue); font-size: 12px; }
#hud-top-center { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hud-time-block { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 6px 18px; display: flex; gap: 14px; align-items: center; backdrop-filter: blur(8px); }
#hud-day { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
#hud-clock { font-family: 'VT323', monospace; font-size: 22px; color: var(--accent); }
#hud-district-name { font-size: 10px; color: var(--text-muted); letter-spacing: 2px; text-transform: uppercase; }
#hud-top-right { position: absolute; top: 12px; right: 12px; pointer-events: auto; }
#online-wrap { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 8px 12px; display: flex; gap: 10px; align-items: center; backdrop-filter: blur(8px); }
#online-indicator { color: var(--green); font-weight: 700; font-size: 12px; }
.btn-mini { background: rgba(255,255,255,0.1); border: 1px solid var(--panel-border); color: var(--text); padding: 2px 8px; border-radius: 3px; font-size: 10px; cursor: pointer; }
#players-panel { position: absolute; top: 60px; right: 12px; width: 200px; max-height: 300px; overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 10px; backdrop-filter: blur(8px); pointer-events: auto; transform: translateX(220px); transition: transform 0.3s; }
#players-panel.open { transform: translateX(0); }
.players-header { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.online-self, .online-other { font-size: 12px; padding: 4px 6px; border-radius: 3px; }
.online-self { background: rgba(127,255,175,0.1); color: #7fffaf; font-weight: 700; }
.online-other { color: var(--text-dim); }
#hud-bottom-left { position: absolute; bottom: 70px; left: 12px; pointer-events: auto; }
#mode-display { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 5px 12px; font-size: 12px; color: var(--blue); backdrop-filter: blur(8px); }
#hud-bottom-right { position: absolute; bottom: 70px; right: 12px; display: flex; gap: 6px; pointer-events: auto; }
.btn-hud-mini { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 8px 12px; font-size: 18px; cursor: pointer; color: var(--text); backdrop-filter: blur(8px); transition: all 0.15s; }
.btn-hud-mini:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); transform: translateY(-2px); }
#hud-stats-bar { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 8px 14px; display: flex; gap: 14px; align-items: center; backdrop-filter: blur(8px); }
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-icon { font-size: 14px; }
.stat-track { width: 70px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.stat-fill.health { background: var(--red); }
.stat-fill.energy { background: var(--blue); }
.stat-fill.hunger { background: var(--accent2); }
.stat-fill.happiness { background: #ec407a; }

#interact-hint { position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px 16px; font-size: 13px; animation: pulse-border 1.5s ease-in-out infinite; pointer-events: none; }
#interact-hint kbd { background: var(--accent); color: #0d0d12; padding: 2px 7px; border-radius: 3px; font-weight: 700; font-family: monospace; margin-right: 4px; }
@keyframes pulse-border { 0%, 100% { box-shadow: 0 0 0 0 rgba(245,197,66,0.4); } 50% { box-shadow: 0 0 0 6px rgba(245,197,66,0); } }

#crosshair { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: rgba(255,255,255,0.7); font-size: 20px; pointer-events: none; }

/* Click-to-play hint (corner, non-blocking) */
#click-to-play {
  position: fixed; bottom: 140px; left: 50%; transform: translateX(-50%);
  z-index: 90; cursor: pointer; pointer-events: auto;
}
.ctp-box { text-align: center; padding: 10px 20px; background: var(--panel); border: 1px solid var(--accent); border-radius: 24px;
  display: flex; gap: 10px; align-items: center;
  box-shadow: 0 0 0 1px rgba(245,197,66,0.3), 0 4px 16px rgba(0,0,0,0.5);
  animation: ctp-pulse 2s ease-in-out infinite;
}
.ctp-icon { font-size: 22px; animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes ctp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245,197,66,0.3), 0 4px 16px rgba(0,0,0,0.5); } 50% { box-shadow: 0 0 0 6px rgba(245,197,66,0), 0 4px 16px rgba(0,0,0,0.5); } }
.ctp-text { font-size: 13px; font-weight: 700; color: var(--accent); }
.ctp-sub { font-size: 10px; color: var(--text-dim); }

/* Notifications */
#notifications { position: fixed; top: 80px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.notif { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 10px 16px; font-size: 13px; max-width: 280px; backdrop-filter: blur(8px); animation: notif-in 0.3s ease, notif-out 0.3s ease forwards; animation-delay: 0s, 2.7s; }
.notif.success { border-color: var(--green); }
.notif.error { border-color: var(--red); }
.notif.money { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.notif.info { border-color: var(--blue); }
@keyframes notif-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes notif-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* Inventory */
#inventory-overlay, #help-overlay, #building-modal, #pause-menu { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.inv-window, .help-window, .modal-box, .pause-box { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 24px; max-width: 600px; width: 90%; max-height: 85vh; overflow-y: auto; }
.inv-header, .help-header { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.inv-header h2, .help-header h2 { font-size: 18px; color: var(--accent); }
.inv-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-dim); margin-left: auto; }
.btn-close-x { background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); width: 28px; height: 28px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.btn-close-x:hover { color: var(--red); border-color: var(--red); }
.inv-filters { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.inv-filter { padding: 4px 10px; background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); border-radius: var(--radius); font-size: 11px; cursor: pointer; }
.inv-filter.active { background: var(--accent); color: #0d0d12; border-color: var(--accent); font-weight: 700; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
.inv-slot { aspect-ratio: 1; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: all 0.15s; }
.inv-slot.filled:hover { border-color: var(--accent); transform: scale(1.05); }
.inv-slot.empty { opacity: 0.5; cursor: default; }
.inv-icon { font-size: 28px; }
.inv-count { position: absolute; bottom: 2px; right: 4px; font-size: 10px; background: rgba(0,0,0,0.7); padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.inv-hint { font-size: 11px; color: var(--text-muted); text-align: center; }

.help-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.help-row { display: flex; gap: 10px; padding: 6px 10px; background: rgba(255,255,255,0.04); border-radius: var(--radius); font-size: 12px; align-items: center; }
.help-row kbd { background: var(--accent); color: #0d0d12; padding: 2px 8px; border-radius: 3px; font-weight: 700; font-family: monospace; font-size: 11px; min-width: 60px; text-align: center; }

.modal-title { font-size: 20px; color: var(--accent); margin-bottom: 16px; }
.modal-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--panel-border); }
.modal-item-name { font-size: 14px; }
.modal-item-price { font-size: 14px; color: var(--accent); font-weight: 700; }
.btn-modal-action { padding: 6px 14px; background: var(--green); color: white; border: none; border-radius: var(--radius); font-size: 12px; cursor: pointer; }
.btn-modal-action:disabled { background: rgba(255,255,255,0.1); color: var(--text-muted); cursor: not-allowed; }
.btn-modal-close { margin-top: 16px; padding: 10px 20px; background: transparent; border: 1px solid var(--panel-border); color: var(--text-dim); border-radius: var(--radius); cursor: pointer; width: 100%; }

.pause-box { display: flex; flex-direction: column; gap: 12px; min-width: 260px; max-width: 320px; }
.pause-title { font-family: 'Press Start 2P', monospace; font-size: 18px; text-align: center; margin-bottom: 8px; }
.btn-pause-item { padding: 12px 20px; background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); color: var(--text); border-radius: var(--radius); font-size: 14px; cursor: pointer; }
.btn-pause-item:hover { background: rgba(255,255,255,0.12); }
.btn-pause-item.save-main { background: var(--accent); color: #0d0d12; font-weight: 700; }

/* Shop */
#shop-overlay { position: fixed; inset: 0; z-index: 250; background: #0a0a12; display: flex; flex-direction: column; }
.shop-header { background: rgba(0,0,0,0.6); border-bottom: 1px solid var(--panel-border); }
.shop-title-bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.shop-name { font-family: 'Press Start 2P', monospace; font-size: 14px; color: var(--accent); }
.shop-header-stats { margin-left: auto; display: flex; gap: 20px; font-family: 'VT323', monospace; font-size: 18px; }
.btn-exit-shop { padding: 6px 14px; background: transparent; border: 1px solid rgba(255,255,255,0.2); color: var(--text-dim); cursor: pointer; border-radius: var(--radius); font-size: 12px; }
.btn-exit-shop:hover { border-color: var(--red); color: var(--red); }
.shop-body { display: flex; flex: 1; min-height: 0; }
.shop-col { flex: 1; padding: 16px; border-right: 1px solid var(--panel-border); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.shop-col:last-child { border-right: none; }
.col-title { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); padding-bottom: 8px; border-bottom: 1px solid var(--panel-border); }
.no-customer-icon { font-size: 40px; text-align: center; }
.no-customer-text { text-align: center; color: var(--text-dim); font-size: 14px; }
.next-customer-hint { text-align: center; color: var(--text-muted); font-size: 12px; }
.customer-header { display: flex; gap: 12px; align-items: center; }
.customer-avatar { font-size: 40px; }
.customer-name { font-size: 16px; font-weight: 700; }
.customer-type { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.speech-bubble { background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); border-radius: 12px; border-top-left-radius: 2px; padding: 12px; font-size: 13px; font-style: italic; }
.patience-wrap { display: flex; align-items: center; gap: 8px; }
.patience-label { font-size: 11px; color: var(--text-muted); }
.patience-track { flex: 1; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.patience-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.5s; }
.order-checklist { background: rgba(0,0,0,0.3); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; display: flex; flex-direction: column; gap: 5px; }
.check-item.done { color: var(--green); }
.check-item.wrong { color: var(--red); }
.sandwich-visual { background: rgba(255,255,255,0.03); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-height: 200px; }
.sw-top-bun, .sw-bottom-bun { background: linear-gradient(135deg, #c8a052, #a07030); border-radius: 20px; padding: 8px 14px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: #3a2000; }
.sw-row { padding: 5px 12px; font-size: 12px; color: var(--text-dim); min-height: 26px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw-row.filled { color: var(--text); }
.sw-tag { background: rgba(255,255,255,0.1); border-radius: 4px; padding: 2px 8px; font-size: 11px; }
.builder-actions { display: flex; gap: 8px; }
.btn-serve, .btn-reset { padding: 10px 18px; border: none; border-radius: var(--radius); font-size: 13px; font-weight: 700; cursor: pointer; flex: 1; }
.btn-serve { background: var(--green); color: white; }
.btn-serve:disabled { background: rgba(255,255,255,0.1); color: var(--text-muted); cursor: not-allowed; }
.btn-reset { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.ing-tabs { display: flex; gap: 4px; }
.ing-tab { padding: 5px 10px; font-size: 14px; border: 1px solid var(--panel-border); background: transparent; color: var(--text-dim); cursor: pointer; border-radius: var(--radius); flex: 1; }
.ing-tab.active { background: var(--accent); color: #0d0d12; border-color: var(--accent); }
.ing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; overflow-y: auto; }
.ing-btn { padding: 8px 10px; font-size: 12px; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.04); color: var(--text); cursor: pointer; border-radius: var(--radius); text-align: left; display: flex; align-items: center; gap: 6px; }
.ing-btn:hover { background: rgba(255,255,255,0.1); }
.ing-btn.selected { background: rgba(245,197,66,0.15); border-color: var(--accent); color: var(--accent); }
.ing-btn.order-match { box-shadow: 0 0 0 1px var(--green) inset; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
