:root {
  --ink: #eef1f6;
  --ink-2: #a9b2c2;
  --ink-3: #6f7a8c;
  --glass: rgba(20, 24, 31, 0.72);
  --glass-2: rgba(34, 40, 51, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --cyan: #7fd8ff;
  --gold: #f2c46d;
  --ok: #6fe0a0;
  --warn: #ffb15a;
  --bad: #ff6b5a;
  --radius: 16px;
  --font: 'Manrope', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --brand: 'Fredoka', 'Manrope', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: var(--font); background: #14171d; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* Cielo detras del canvas (cambia con la hora desde JS) */
#sky { position: fixed; inset: 0; z-index: 0; background: radial-gradient(ellipse at 50% 30%, var(--sky-a, #3b4a63), var(--sky-b, #12151b) 70%); }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; z-index: 1; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.2px; color: var(--ink-3); text-transform: uppercase; font-weight: 500; }
.hint-sm { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 5; padding: calc(env(safe-area-inset-top) + 10px) 10px 0; display: flex; gap: 8px; align-items: stretch; justify-content: space-between; pointer-events: none; }
#hud > * { pointer-events: auto; }
.clock { display: flex; align-items: center; gap: 9px; padding: 7px 12px 7px 10px; }
.clock .ico { color: var(--gold); width: 22px; height: 22px; }
.clock b { display: block; font-family: var(--mono); font-size: 17px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.1; }
.clock small { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 1.2px; }
.speeds { display: flex; padding: 4px; gap: 2px; }
.speeds button { width: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--ink-2); }
.speeds button svg { width: 16px; height: 16px; }
.speeds button.on { color: #0b1a24; background: linear-gradient(180deg, #b4ecff, var(--cyan)); box-shadow: 0 0 14px rgba(127, 216, 255, 0.45); }
.money { display: flex; align-items: center; padding: 0 13px; font-family: var(--mono); font-weight: 700; font-size: 15.5px; color: var(--gold); }
.money.bump { animation: bump 0.5s; }
@keyframes bump { 40% { transform: scale(1.12); } }

#tools { position: fixed; right: 10px; top: calc(env(safe-area-inset-top) + 68px); z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.tool { width: 46px; min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink); border-radius: 14px; }
.tool small { font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.6px; color: var(--cyan); }
.tool.off { color: var(--bad); }

/* ---------- Cola ---------- */
#queue { position: fixed; left: 10px; top: calc(env(safe-area-inset-top) + 68px); display: flex; flex-direction: column; gap: 6px; z-index: 4; max-width: 46vw; }
#queue .q { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12px; font-weight: 700; text-align: left; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); animation: pop 0.25s; }
#queue .q:first-child { border-color: rgba(127, 216, 255, 0.5); }
#queue .q .bar { flex: 1; min-width: 26px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#queue .q .bar i { display: block; height: 100%; background: var(--cyan); }
#queue .q .x { color: var(--ink-3); font-size: 14px; line-height: 1; }

/* ---------- Avisos ---------- */
#toasts { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 68px); transform: translateX(-50%); width: min(62vw, 360px); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 6; pointer-events: none; }
.toast { padding: 9px 13px; font-size: 13px; font-weight: 700; text-align: center; background: var(--glass-2); border: 1px solid var(--line-2); border-radius: 12px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: pop 0.3s, fade 0.5s 3.4s forwards; }
.toast.big { border-color: rgba(242, 196, 109, 0.55); }
.toast.warn { border-color: rgba(255, 107, 90, 0.6); }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
@keyframes fade { to { opacity: 0; transform: translateY(-8px); } }
.float-money { position: fixed; font-family: var(--mono); font-weight: 700; font-size: 17px; pointer-events: none; z-index: 7; animation: rise 1.4s forwards; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
@keyframes rise { to { transform: translateY(-46px); opacity: 0; } }

/* ---------- Globo sobre la cabeza ---------- */
#bubble { position: fixed; z-index: 4; transform: translate(-50%, -100%); width: 44px; height: 40px; border-radius: 15px; display: grid; place-items: center; background: #fbfaf6; color: var(--bad); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); pointer-events: none; animation: pop 0.25s; }
#bubble::after { content: ''; position: absolute; left: 10px; bottom: -7px; width: 9px; height: 9px; border-radius: 50%; background: #fbfaf6; }
#bubble.talk { color: #2c7fd0; }
#bubble svg { width: 24px; height: 24px; }

/* ---------- Menu circular ---------- */
#pie { position: fixed; inset: 0; z-index: 8; background: radial-gradient(circle at var(--px, 50%) var(--py, 50%), rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.35) 60%); }
#pie .face { position: absolute; width: 60px; height: 60px; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 4px rgba(127, 216, 255, 0.35), 0 10px 24px rgba(0, 0, 0, 0.45); background: radial-gradient(circle at 35% 30%, #d8eef8, #8fb8cf); animation: pieIn 0.2s backwards; }
#pie .core { position: absolute; transform: translate(-50%, -50%); padding: 4px 10px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--cyan); white-space: nowrap; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
#pie .opt { position: absolute; transform: translate(-50%, -50%); min-width: 104px; padding: 10px 14px; border-radius: 999px; font-weight: 800; font-size: 13.5px; text-align: center; color: var(--ink); background: var(--glass-2); border: 1px solid var(--line-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4); animation: pieIn 0.22s backwards; }
#pie .opt small { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--gold); font-weight: 500; }
#pie .opt.danger { border-color: rgba(255, 107, 90, 0.6); }
#pie .opt:active { background: rgba(127, 216, 255, 0.25); }
@keyframes pieIn { from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } }

/* ---------- Colocar ---------- */
#placebar { position: fixed; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 12px; }
.round { width: 62px; height: 62px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 800; }
.round.ok { color: #06281a; background: linear-gradient(180deg, #a6f5c9, var(--ok)); box-shadow: 0 0 18px rgba(111, 224, 160, 0.45); }
.round.ok:disabled { filter: grayscale(1) brightness(0.6); box-shadow: none; }
.round.no { color: var(--bad); }

/* ---------- Dock ---------- */
#dock { position: fixed; left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 5; max-width: 560px; margin: 0 auto; padding: 4px 12px 12px; border-radius: 22px; transition: transform 0.3s; }
#dock.min { transform: translateY(calc(100% - 62px)); }
#grip { width: 100%; height: 14px; display: grid; place-items: center; }
#grip i { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); }
.tabs { display: flex; gap: 4px; padding: 3px; margin-bottom: 10px; background: rgba(0, 0, 0, 0.25); border-radius: 13px; }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; height: 36px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.tab svg { width: 16px; height: 16px; }
.tab.active { color: #0b1a24; background: #f3f5f8; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }

.who { display: grid; grid-template-columns: 50px 1fr; column-gap: 11px; row-gap: 8px; align-items: center; margin-bottom: 12px; }
.avatar { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 35% 30%, #d8eef8, #8fb8cf); border: 2px solid var(--mood, #6fe0a0); box-shadow: 0 0 14px var(--mood, #6fe0a0); }
.avatar img { width: 100%; height: 100%; display: block; }
.who-txt { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.who-txt b { font-size: 16px; font-weight: 800; }
.who-txt small { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-txt .job { display: flex; align-items: center; gap: 5px; color: var(--gold); font-family: var(--mono); font-size: 10.5px; }
.who-txt .job svg { width: 12px; height: 12px; }
.mood { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.mood .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.mood .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--bad), var(--warn), var(--ok)); background-size: 300% 100%; transition: width 0.4s; }

.needs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.need { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; }
.need .ic { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.06); color: var(--ink-2); }
.need .ic svg { width: 15px; height: 15px; }
.need .lbl { display: block; margin-bottom: 4px; }
.need .track { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.need .fill { height: 100%; border-radius: 3px; transition: width 0.3s linear; }
.need.low .ic { color: var(--bad); background: rgba(255, 107, 90, 0.16); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

/* Comprar */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--ink-2); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); white-space: nowrap; }
.chip.on { color: #0b1a24; background: var(--cyan); border-color: transparent; }
.catalog { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.catalog::-webkit-scrollbar { display: none; }
.card { flex: none; width: 116px; scroll-snap-align: start; padding: 6px 6px 9px; border-radius: 14px; text-align: left; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.card .thumb { width: 100%; aspect-ratio: 1.15; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #3a4250, #1b1f27); display: block; object-fit: contain; }
.card b { display: block; margin: 6px 3px 2px; font-size: 12px; font-weight: 700; line-height: 1.2; min-height: 29px; }
.card span { margin-left: 3px; font-family: var(--mono); font-size: 11.5px; color: var(--gold); }
.card.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.card.poor span { color: var(--bad); }

/* Decorar */
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.mat-tabs .chip.on { background: #f3f5f8; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 8px; max-height: 210px; overflow-y: auto; padding: 2px; }
.sw { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; color: var(--ink-2); text-align: center; line-height: 1.15; }
.sw img { width: 56px; height: 56px; border-radius: 12px; display: block; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); border: 2px solid transparent; }
.sw.on img { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(127, 216, 255, 0.25); }
.sw.on { color: var(--ink); }

/* Luz */
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset { padding: 10px 6px; border-radius: 13px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.preset svg { width: 22px; height: 22px; color: var(--gold); }
.preset b { font-size: 12px; }
.preset small { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.preset.on { border-color: var(--cyan); }
.sunbar { position: relative; height: 6px; margin: 16px 4px 10px; border-radius: 3px; background: linear-gradient(90deg, #1d2742, #f7b96b 22%, #fff3d6 50%, #f39a5b 78%, #1d2742); }
.sunbar i { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%); background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.5); }

/* ---------- Portada ---------- */
#title { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 30%, rgba(127, 216, 255, 0.18), transparent 55%), linear-gradient(160deg, #1b1f2a, #12151b 60%, #0c0e12); transition: opacity 0.5s; }
#title.out { opacity: 0; pointer-events: none; }
.title-inner { text-align: center; padding: 24px; }
.logo-mark { width: min(42vw, 180px); border-radius: 22%; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6)); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.wordmark { margin: 16px 0 0; font-family: var(--brand); font-weight: 700; font-size: clamp(40px, 12vw, 70px); letter-spacing: 4px; line-height: 1; color: var(--cyan); text-shadow: 0 0 30px rgba(127, 216, 255, 0.35); }
.tagline { margin: 10px 0 30px; font-family: var(--mono); font-size: 11.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--ink-2); }
.cta { display: block; margin: 0 auto 12px; width: 220px; height: 54px; border-radius: 16px; font-weight: 800; font-size: 17px; color: #0b1a24; background: linear-gradient(180deg, #c7f0ff, var(--cyan)); box-shadow: 0 0 30px rgba(127, 216, 255, 0.35); }
.cta:active { transform: scale(0.97); }
.ghost { display: block; margin: 0 auto; padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--ink-2); border: 1px solid var(--line-2); }
.hint { margin-top: 26px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }
.err { margin-top: 14px; color: var(--bad); font-weight: 700; font-size: 13px; }
