:root {
  --obsidian: #0a0b10;
  --gold: #d4af37;
  --gold-light: #f3d77a;
  --marble: #f4f1ea;
  --ink: #1a1712;
  --serif: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--obsidian); color: var(--marble); font-family: var(--sans); }
#app { position: fixed; inset: 0; }
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.ui-layer { position: absolute; inset: 0; pointer-events: none; user-select: none; }
.ui-layer button, .ui-layer input, .ui-layer select, .ui-layer a, .menu-backdrop, .title-screen, .intro, .ending, .dialog { pointer-events: auto; }
.hidden { display: none !important; }
kbd { font-family: var(--sans); font-size: 0.78em; padding: 1px 6px; border: 1px solid rgba(212,175,55,.6); border-radius: 4px; background: rgba(0,0,0,.45); color: var(--gold-light); }

#boot { position: fixed; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; font-family: var(--serif); color: var(--gold); letter-spacing: .2em; background: var(--obsidian); }
.boot-eye { font-size: 64px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.94); } }
.fatal { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; font-family: var(--body); font-size: 20px; }

/* ---------------- HUD */
.hud { position: absolute; inset: 0; }
.hud-tl { position: absolute; top: 18px; left: 22px; display: flex; flex-direction: column; gap: 8px; }
.lvl-stats { display: flex; gap: 16px; }
.stat { display: flex; align-items: center; gap: 6px; font-family: var(--serif); font-weight: 700; font-size: 26px; color: var(--gold-light); text-shadow: 0 2px 6px rgba(0,0,0,.8), 0 0 18px rgba(212,175,55,.35); }
.stat small { font-size: 15px; opacity: .7; font-weight: 500; }
.stat.done { color: #9fffc0; }
.stat-frag { font-size: 34px; }
.ico { width: 1.15em; height: 1.15em; color: var(--gold); filter: drop-shadow(0 0 6px rgba(212,175,55,.6)); }
.hud-tr { position: absolute; top: 18px; right: 22px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.powers { display: flex; gap: 8px; }
.power { position: relative; width: 54px; height: 60px; border: 1px solid rgba(212,175,55,.7); background: linear-gradient(180deg, rgba(20,18,30,.85), rgba(6,6,10,.9)); border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.power .p-ico { font-size: 22px; color: var(--gold-light); }
.power .p-key { font-size: 10px; color: var(--marble); opacity: .8; margin-top: -10px; text-align: center; line-height: 1; }
.power.locked { opacity: .38; filter: grayscale(1); }
.power.active { box-shadow: 0 0 16px rgba(95,240,255,.9); border-color: #5ff0ff; }
.p-cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); }
.energy { width: 238px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.55); border: 1px solid rgba(212,175,55,.5); overflow: hidden; }
.energy-fill { height: 100%; background: linear-gradient(90deg, #5ff0ff, var(--gold)); transition: width .1s linear; }
.banner { position: absolute; top: 18%; left: 50%; transform: translate(-50%, -10px); text-align: center; opacity: 0; transition: opacity .6s, transform .6s; }
.banner.on { opacity: 1; transform: translate(-50%, 0); }
.b-title { font-family: var(--serif); font-size: clamp(28px, 4.4vw, 56px); font-weight: 900; letter-spacing: .08em; color: var(--marble); text-shadow: 0 0 30px rgba(212,175,55,.6), 0 4px 10px #000; }
.b-sub { font-family: var(--serif); letter-spacing: .35em; text-transform: uppercase; font-size: 13px; color: var(--gold); }
.toast { position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%); max-width: min(680px, 90vw); text-align: center; padding: 12px 22px; font-family: var(--body); font-size: 21px; background: rgba(8,8,14,.82); border: 1px solid rgba(212,175,55,.55); border-radius: 10px; opacity: 0; transition: opacity .35s; }
.toast.on { opacity: 1; }
.prompt { position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%); font-family: var(--body); font-size: 20px; padding: 6px 16px; background: rgba(0,0,0,.6); border-radius: 30px; border: 1px solid rgba(212,175,55,.4); }
.timer { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-family: var(--serif); font-size: 34px; font-weight: 700; color: var(--gold-light); text-shadow: 0 2px 8px #000; }
.timer small { font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--marble); }
.timer.low { color: #ff6a6a; }
.boss { position: absolute; bottom: 5%; left: 50%; transform: translateX(-50%); width: min(560px, 80vw); text-align: center; }
.boss-name { font-family: var(--serif); letter-spacing: .2em; color: #ff9a7a; margin-bottom: 6px; }
.boss-track { height: 12px; background: rgba(0,0,0,.6); border: 1px solid #ff7a5a; border-radius: 6px; overflow: hidden; }
.boss-fill { height: 100%; background: linear-gradient(90deg, #ff3050, #ffb040); transition: width .4s; }
.celebrate { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.celebrate.anim { animation: celebrate 2.6s ease forwards; }
.cel-eye .ico { width: 120px; height: 120px; }
.cel-title { font-family: var(--serif); font-weight: 900; font-size: clamp(26px, 4vw, 52px); letter-spacing: .06em; color: var(--gold-light); text-shadow: 0 0 40px rgba(255,200,80,.9), 0 4px 10px #000; }
.cel-sub { font-family: var(--body); font-style: italic; font-size: 24px; }
@keyframes celebrate { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.05); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.04); } }
.fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .4s; pointer-events: none; }
.fade.on { opacity: 1; }

/* ---------------- DIÁLOGO (mármore + ouro) */
.dialog { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); width: min(820px, 94vw); padding: 22px 30px 18px; color: var(--ink);
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(255,255,255,.9), transparent 60%),
    repeating-linear-gradient(115deg, rgba(150,140,120,.10) 0 2px, transparent 2px 22px),
    linear-gradient(160deg, #f7f3ea, #e6dfcf);
  border: 3px solid var(--gold); border-radius: 6px; box-shadow: 0 0 0 1px #7a5c10 inset, 0 0 0 6px rgba(10,11,16,.85), 0 20px 60px rgba(0,0,0,.6), 0 0 40px rgba(212,175,55,.35); }
.dialog::before, .dialog::after { content: '◆'; position: absolute; top: -13px; color: var(--gold); font-size: 20px; }
.dialog::before { left: 18px; } .dialog::after { right: 18px; }
.dialog-name { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); padding: 3px 18px; font-family: var(--serif); font-weight: 700; letter-spacing: .12em; font-size: 14px; color: var(--gold-light); background: var(--obsidian); border: 1px solid var(--gold); border-radius: 3px; white-space: nowrap; }
.dialog-text { font-family: var(--body); font-size: 23px; line-height: 1.35; min-height: 62px; white-space: pre-line; font-weight: 600; }
.dialog-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dialog-choices button { text-align: left; font-family: var(--body); font-size: 20px; font-weight: 600; padding: 6px 12px; border: 1px solid rgba(122,92,16,.6); background: rgba(255,255,255,.4); color: var(--ink); border-radius: 4px; cursor: pointer; }
.dialog-choices button span { display: inline-block; width: 22px; color: #7a5c10; font-family: var(--serif); }
.dialog-choices button.sel, .dialog-choices button:hover { background: var(--obsidian); color: var(--gold-light); }
.dialog-hint { text-align: right; font-size: 12px; opacity: .55; margin-top: 6px; }

/* ---------------- MENUS */
.btn { font-family: var(--serif); font-weight: 700; letter-spacing: .1em; font-size: 15px; padding: 12px 26px; min-width: 220px; color: var(--marble); background: rgba(10,11,16,.75); border: 1px solid rgba(212,175,55,.65); border-radius: 3px; cursor: pointer; transition: all .2s; }
.btn:hover, .btn:focus-visible { background: rgba(212,175,55,.18); color: var(--gold-light); box-shadow: 0 0 22px rgba(212,175,55,.35); outline: none; }
.btn.primary { background: linear-gradient(180deg, #e8c860, #b08a20); color: #1a1206; border-color: #ffe39a; }
.btn.primary:hover { filter: brightness(1.1); color: #000; }
.btn.danger { border-color: #c04040; color: #ff9a9a; }
.title-screen, .ending { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; background: radial-gradient(60% 60% at 50% 45%, rgba(10,11,16,.2), rgba(10,11,16,.85)); }
.title-eye .ico { width: 92px; height: 92px; animation: pulse 3s ease-in-out infinite; }
.title-screen h1, .ending h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(44px, 9vw, 112px); letter-spacing: .14em; margin: 6px 0 0; color: var(--marble); text-shadow: 0 0 40px rgba(212,175,55,.55), 0 6px 18px #000; }
.title-screen h2 { font-family: var(--serif); font-weight: 500; letter-spacing: .45em; text-transform: uppercase; font-size: clamp(13px, 1.8vw, 20px); color: var(--gold); margin: 4px 0 18px; }
.title-tag { font-family: var(--body); font-style: italic; font-size: 21px; max-width: 560px; opacity: .9; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.title-foot { position: absolute; bottom: 16px; font-size: 13px; opacity: .6; }
.title-foot a { color: var(--gold); }
.ending p { font-family: var(--body); font-size: 22px; max-width: 640px; }
.menu-backdrop { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4,4,8,.72); backdrop-filter: blur(4px); padding: 16px; }
.menu-panel { width: min(640px, 96vw); max-height: 90vh; overflow: auto; padding: 28px 32px; background: linear-gradient(180deg, rgba(20,18,28,.96), rgba(8,8,12,.97)); border: 1px solid rgba(212,175,55,.6); border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.menu-panel h3 { font-family: var(--serif); font-size: 28px; letter-spacing: .08em; margin: 0 0 4px; color: var(--gold-light); text-align: center; }
.menu-panel .sub { text-align: center; font-size: 13px; opacity: .7; margin-bottom: 14px; }
.menu-panel label { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 0; border-bottom: 1px solid rgba(212,175,55,.15); font-size: 15px; }
.menu-panel label.check { justify-content: flex-start; }
.menu-panel input[type=range] { width: 50%; accent-color: var(--gold); }
.menu-panel select { background: #111; color: var(--marble); border: 1px solid var(--gold); padding: 4px 8px; }
.col { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 16px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.missions { display: grid; gap: 6px; margin: 12px 0; }
.mission { font-family: var(--body); font-size: 19px; display: flex; gap: 10px; align-items: center; opacity: .75; }
.mission span { color: var(--gold); width: 18px; }
.mission.done { opacity: 1; color: var(--gold-light); }
.hint { font-family: var(--body); font-style: italic; font-size: 17px; opacity: .8; }
.controls-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; margin-top: 12px; }
.controls-grid > div:nth-child(odd) { color: var(--gold-light); }
.journal h4 { font-family: var(--serif); color: var(--gold); margin: 16px 0 4px; }
.journal p { font-family: var(--body); font-size: 18px; margin: 4px 0; }
.intro { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4,4,8,.6); padding: 16px; }
.intro-card { width: min(620px, 96vw); text-align: center; padding: 30px 34px; background: linear-gradient(180deg, rgba(20,18,28,.95), rgba(8,8,12,.96)); border: 1px solid var(--gold); border-radius: 4px; }
.intro-grade { font-family: var(--serif); letter-spacing: .35em; text-transform: uppercase; color: var(--gold); font-size: 12px; }
.intro-card h2 { font-family: var(--serif); font-size: clamp(26px, 4vw, 40px); margin: 8px 0; }
.intro-card p { font-family: var(--body); font-size: 20px; }
.intro-card .missions { text-align: left; max-width: 420px; margin: 12px auto 20px; }
@media (max-width: 640px) {
  .stat { font-size: 20px; } .stat-frag { font-size: 24px; }
  .power { width: 42px; height: 48px; } .energy { width: 186px; }
  .dialog-text { font-size: 19px; }
}
