:root {
  --amber: #e9ae62;
  --amber-2: #ffd49a;
  --amber-dim: rgba(233, 174, 98, .25);
  --text: #f4e7d2;
  --muted: #bda78a;
  --danger: #ff6b3d;
  --radius: 14px;
  --font-display: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --font-ui: 'Rajdhani', 'Avenir Next Condensed', 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #140d08;
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

body.no-gl #stage { background: linear-gradient(#2a2b5a, #ff8a50 42%, #c98a55 43%, #7a4a2a); }

button { font: inherit; color: inherit; }

/* ---------- Stage ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 5, 2, .32), transparent 16%),
    radial-gradient(130% 95% at 50% 42%, transparent 52%, rgba(12, 6, 2, .6) 100%);
}

#grain {
  position: absolute; inset: -50%; pointer-events: none;
  opacity: .075; mix-blend-mode: overlay;
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

#flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 62%, rgba(255, 226, 180, .95), rgba(255, 180, 110, .35) 55%, transparent 100%);
  mix-blend-mode: screen;
}

.letterbox {
  position: absolute; left: 0; right: 0; height: 0; z-index: 2;
  background: #000; pointer-events: none;
  transition: height 1.4s cubic-bezier(.6, 0, .2, 1);
}
.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }
body.bars .letterbox { height: 9vh; }

#title-card {
  position: absolute; left: 0; right: 0; top: 12.5vh; z-index: 3;
  text-align: center; pointer-events: none; opacity: 0;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(26px, 4.6vw, 68px);
  letter-spacing: .45em; text-indent: .45em;
  color: #fbe6c6;
  text-shadow: 0 0 34px rgba(255, 140, 50, .55), 0 2px 3px rgba(0, 0, 0, .7);
  transition: opacity 1.8s ease, letter-spacing 7s ease-out;
}
body.titled #title-card { opacity: .94; letter-spacing: .7em; text-indent: .7em; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  transition: opacity .7s ease;
}
#hud > * { pointer-events: auto; }
#brand, #seismo, #sensor, #console { transition: opacity .7s ease; }
body.cine #brand, body.cine #seismo, body.cine #sensor, body.cine #console,
body.bars #brand, body.bars #seismo, body.bars #sensor, body.bars #console { opacity: 0; pointer-events: none; }
.btn.up svg { transform: rotate(180deg); }

.panel {
  position: absolute;
  background: linear-gradient(180deg, rgba(36, 24, 14, .56), rgba(14, 9, 6, .7));
  border: 1px solid rgba(233, 174, 98, .2);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 225, 180, .07);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
}
.panel::before {
  content: ""; position: absolute; inset: 5px; border-radius: 10px; pointer-events: none; opacity: .6;
  background:
    linear-gradient(var(--amber), var(--amber)) top left / 12px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top left / 1px 12px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top right / 12px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top right / 1px 12px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom left / 12px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom left / 1px 12px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 12px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 1px 12px no-repeat;
}

.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase;
  color: var(--muted);
}
.panel-head span:last-child { color: var(--amber); letter-spacing: .12em; font-variant-numeric: tabular-nums; }

#brand {
  position: absolute; top: 22px; left: 26px;
  display: flex; align-items: center; gap: 14px;
  pointer-events: none; color: var(--amber);
}
.brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 0 8px rgba(233, 174, 98, .35)); }
#brand h1 {
  font-family: var(--font-display); font-weight: 600; font-size: 25px;
  letter-spacing: .42em; color: #f8e7cd; text-transform: uppercase;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .55);
}
#brand p {
  font-size: 11.5px; font-weight: 500; letter-spacing: .36em; text-transform: uppercase;
  color: var(--muted); margin-top: 3px; text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
}

#seismo { top: 88px; left: 22px; width: 330px; padding: 12px 14px 10px; }
#seis { display: block; width: 100%; height: 74px; margin-top: 8px; }

#sensor { top: 22px; right: 22px; width: 262px; padding: 14px 16px 14px; }
#radar { display: block; width: 228px; height: 228px; margin: 10px auto 6px; }

.readouts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px;
  margin-top: 4px; padding-top: 10px; border-top: 1px solid rgba(233, 174, 98, .14);
}
.readouts .wide { grid-column: 1 / -1; }
.readouts dt { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.readouts dd {
  font-size: 17px; font-weight: 600; letter-spacing: .04em; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#r-status { font-family: var(--font-display); font-size: 15px; letter-spacing: .18em; text-transform: uppercase; }
#r-status.warn { color: #ffb070; text-shadow: 0 0 12px rgba(255, 120, 50, .6); }
#r-status.danger { color: #ff8a5c; text-shadow: 0 0 14px rgba(255, 70, 30, .8); animation: blink .7s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }

.lure { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.lure span { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
.lure .bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(233, 174, 98, .14); overflow: hidden; }
.lure i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #a8662c, var(--amber), #ffdca8);
  box-shadow: 0 0 10px rgba(255, 170, 80, .7);
  transition: width .3s ease;
}

#alert {
  position: absolute; top: 15vh; left: 50%; transform: translateX(-50%);
  pointer-events: none; opacity: 0; transition: opacity .6s ease; white-space: nowrap;
}
#alert.show { opacity: 1; }
#alert span {
  display: block;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(24px, 3.8vw, 50px);
  letter-spacing: .6em; text-indent: .6em; text-transform: uppercase;
  color: #ffd8b0;
  text-shadow: 0 0 18px rgba(255, 90, 40, .9), 0 0 50px rgba(255, 60, 20, .5);
  animation: alertPulse 1.1s ease-in-out infinite;
}
@keyframes alertPulse { 50% { opacity: .55; filter: blur(.4px); } }

#toasts {
  position: absolute; left: 50%; bottom: 168px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: min(640px, 90vw);
}
.toast {
  font-family: var(--font-display); font-size: 15px; letter-spacing: .08em; text-align: center;
  color: #f8e6cb; padding: 7px 18px; border-radius: 30px;
  background: rgba(16, 10, 6, .55); border: 1px solid rgba(233, 174, 98, .18);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
  animation: toastIn .6s cubic-bezier(.2, .8, .2, 1) both;
  transition: opacity .8s ease, transform .8s ease;
}
.toast.warn { color: #ffcf9e; border-color: rgba(255, 120, 60, .4); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Console ---------- */
#console {
  left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(1120px, calc(100vw - 36px));
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px;
  padding: 14px 20px;
}

.actions { display: flex; align-items: center; gap: 14px; }

.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 74px; height: 66px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, rgba(233, 174, 98, .12), rgba(233, 174, 98, .04));
  border: 1px solid rgba(233, 174, 98, .3);
  transition: background .2s, border-color .2s, transform .1s, opacity .2s;
  position: relative;
}
.btn svg { width: 22px; height: 22px; fill: none; stroke: var(--amber-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn .lbl { font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.btn kbd { position: absolute; top: 4px; right: 6px; font-size: 9px; opacity: .45; font-family: var(--font-ui); }
.btn:hover:not(:disabled) { background: linear-gradient(180deg, rgba(233, 174, 98, .24), rgba(233, 174, 98, .08)); border-color: rgba(255, 200, 130, .6); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled, .btn-main:disabled { opacity: .35; cursor: not-allowed; }
.btn.hint { animation: hint 1.6s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 0 0 4px rgba(233, 174, 98, .2), 0 0 24px rgba(255, 170, 80, .5); border-color: var(--amber-2); } }

.btn-main {
  position: relative; width: 92px; height: 92px; border-radius: 50%; cursor: pointer;
  border: none; background: none; display: grid; place-items: center;
}
.btn-main .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(233, 174, 98, .55);
  box-shadow: inset 0 0 0 4px rgba(20, 12, 6, .6), inset 0 0 0 5px rgba(233, 174, 98, .25);
}
.btn-main .core {
  position: absolute; inset: 9px; border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #7a5634, #3a2513 60%, #1d120a);
  box-shadow: inset 0 2px 3px rgba(255, 220, 170, .25), inset 0 -6px 12px rgba(0, 0, 0, .5), 0 6px 18px rgba(0, 0, 0, .45);
  transition: background .3s, box-shadow .3s;
}
.btn-main .lbl {
  position: relative; font-size: 12px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber-2); text-indent: .2em;
}
.btn-main:hover:not(:disabled) .core { background: radial-gradient(circle at 38% 30%, #8d6540, #45301a 60%, #22150b); }
.btn-main.active .core {
  background: radial-gradient(circle at 40% 32%, #ffd28e, #e0802f 45%, #7a3410);
  box-shadow: inset 0 2px 4px rgba(255, 245, 220, .6), inset 0 -6px 12px rgba(80, 20, 0, .5), 0 0 30px rgba(255, 140, 50, .55);
}
.btn-main.active .lbl { color: #2a1206; }
.btn-main.beat .ring { animation: beat .7s ease-out; }
@keyframes beat {
  0% { box-shadow: inset 0 0 0 4px rgba(20, 12, 6, .6), 0 0 0 0 rgba(255, 170, 80, .75); }
  100% { box-shadow: inset 0 0 0 4px rgba(20, 12, 6, .6), 0 0 0 22px rgba(255, 170, 80, 0); }
}

.controls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 26px; }
.ctrl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ctrl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.ctrl-head b { font-size: 11px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.ctrl-head output { font-size: 14px; font-weight: 600; color: var(--amber-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 20px;
  background: transparent; cursor: pointer; --p: 50%;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--amber) var(--p), rgba(233, 174, 98, .18) var(--p));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px;
  transform: rotate(45deg); background: #ffdcaa; border: 1px solid #7a4b1f;
  box-shadow: 0 0 10px rgba(255, 180, 90, .7);
}
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(255, 210, 150, .35), 0 0 12px rgba(255, 180, 90, .9); }
input[type=range]::-moz-range-track { height: 2px; background: rgba(233, 174, 98, .18); }
input[type=range]::-moz-range-progress { height: 2px; background: var(--amber); }
input[type=range]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 0; transform: rotate(45deg);
  background: #ffdcaa; border: 1px solid #7a4b1f; box-shadow: 0 0 10px rgba(255, 180, 90, .7);
}

.side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.toggles { display: flex; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 20px; cursor: pointer;
  font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  background: rgba(233, 174, 98, .06); border: 1px solid rgba(233, 174, 98, .25); color: var(--muted);
  transition: all .2s;
}
.chip:hover { border-color: rgba(255, 200, 130, .6); color: var(--text); }
.chip.on { background: rgba(233, 174, 98, .2); color: var(--amber-2); border-color: rgba(233, 174, 98, .55); }
.stats { display: flex; gap: 14px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.stats b { color: var(--amber-2); font-size: 14px; letter-spacing: .05em; margin-left: 4px; font-variant-numeric: tabular-nums; }

button:focus-visible { outline: 1px solid var(--amber-2); outline-offset: 3px; }

/* ---------- Help ---------- */
#help {
  position: fixed; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, 90vw); padding: 18px 22px 20px;
}
#help[hidden] { display: none; }
#help ul { list-style: none; margin: 14px 0; display: grid; gap: 9px; font-size: 15px; }
#help p { font-size: 14px; line-height: 1.45; color: var(--muted); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 4px; text-align: center;
  font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--amber-2);
  border: 1px solid rgba(233, 174, 98, .35); border-radius: 5px; background: rgba(233, 174, 98, .08);
}

/* ---------- Intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: auto;
  background: radial-gradient(ellipse at 50% 42%, rgba(30, 18, 10, .25), rgba(8, 5, 3, .86) 78%);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  transition: opacity 1.4s ease, visibility 1.4s;
}
#intro.gone { opacity: 0; visibility: hidden; }
.intro-inner { max-width: 760px; padding: 40px 28px; text-align: center; animation: introIn 2.2s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes introIn { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }
.kicker { font-size: 12px; letter-spacing: .5em; text-transform: uppercase; color: var(--amber); text-indent: .5em; }
.intro-inner h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(48px, 9vw, 112px); letter-spacing: .32em; text-indent: .32em;
  text-transform: uppercase; color: #fbe9cf; margin: 10px 0 2px;
  text-shadow: 0 0 40px rgba(255, 150, 60, .35), 0 4px 30px rgba(0, 0, 0, .6);
}
.sub { font-size: 14px; letter-spacing: .42em; text-transform: uppercase; color: var(--muted); text-indent: .42em; }
blockquote {
  font-family: var(--font-display); font-style: normal; font-size: clamp(16px, 2vw, 20px);
  color: #f1dcbc; margin: 30px auto 30px; max-width: 560px; line-height: 1.5; opacity: .9;
}
.steps {
  list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin: 0 auto 34px; text-align: left; counter-reset: s;
}
.steps li {
  counter-increment: s; padding: 14px 14px 12px; border-radius: 12px;
  background: rgba(233, 174, 98, .06); border: 1px solid rgba(233, 174, 98, .16);
}
.steps li::before {
  content: "0" counter(s); display: block; font-size: 11px; letter-spacing: .2em; color: var(--amber); margin-bottom: 6px;
}
.steps b { display: block; font-family: var(--font-display); font-size: 15px; letter-spacing: .14em; color: #f8e6cb; text-transform: uppercase; }
.steps span { display: block; font-size: 14px; line-height: 1.35; color: var(--muted); margin-top: 4px; }
#enter {
  cursor: pointer; padding: 15px 42px; border-radius: 40px;
  font-family: var(--font-display); font-size: 15px; letter-spacing: .32em; text-transform: uppercase;
  color: #2a1406; background: linear-gradient(180deg, #ffd99c, #e39a48 60%, #b8682a);
  border: 1px solid #ffe3b5;
  box-shadow: 0 10px 40px rgba(255, 140, 50, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .2s, box-shadow .2s;
}
#enter:hover { transform: translateY(-1px); box-shadow: 0 14px 50px rgba(255, 140, 50, .5), inset 0 1px 0 rgba(255, 255, 255, .5); }
.hint { margin-top: 16px; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); opacity: .75; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
  #toasts { bottom: 214px; }
}
@media (max-width: 900px) {
  #console { grid-template-columns: 1fr; gap: 12px; padding: 12px 14px; }
  .actions { justify-content: center; }
  .side { flex-direction: row; justify-content: space-between; align-items: center; }
  #seismo { display: none; }
  #sensor { width: 196px; padding: 10px 12px; }
  #radar { width: 150px; height: 150px; }
  .readouts dd { font-size: 14px; }
  #toasts { bottom: 330px; }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  #brand h1 { font-size: 18px; }
  #brand p { display: none; }
  #sensor .readouts div:not(.wide), #sensor .lure { display: none; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { width: 64px; height: 58px; }
  .btn-main { width: 80px; height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  #grain, #alert span, .btn.hint { animation: none; }
}
