/* ============================================================
   DOPA PLINKO — Screens, HUD, overlays
   ============================================================ */
#app { position: fixed; inset: 0; z-index: 2; }

.screen {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  opacity: 1; transition: opacity 0.5s ease;
}
.screen.hidden { display: none; }
.screen.fade { opacity: 0; }

/* ===================== TITLE ===================== */
#screen-title {
  align-items: center; justify-content: center; text-align: center;
  background: #06040a url('../assets/quantum-drop-hero.png') center center / cover no-repeat;
}
.title-content {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 24px; margin-top: 5vh;
}
.title-content::before {
  content: ''; position: absolute; inset: -16% -18% -12%;
  background: radial-gradient(56% 56% at 50% 46%, rgba(6,4,10,0.55), rgba(6,4,10,0.22) 55%, rgba(6,4,10,0) 80%);
  z-index: -1; filter: blur(10px); pointer-events: none;
}
.title-eyebrow {
  font-family: var(--f-ui); font-size: clamp(10px, 1.5vw, 13px); font-weight: 600;
  letter-spacing: 0.34em; text-transform: uppercase; color: var(--quantum);
  text-shadow: 0 0 16px rgba(68,230,212,0.6); margin-bottom: 16px;
}
@keyframes pulse { 0%,100%{ transform: scale(1); opacity:.92 } 50%{ transform: scale(1.12); opacity:1 } }
.title-logo {
  font-family: var(--f-display); font-weight: 800; line-height: 0.84; letter-spacing: 0.05em;
}
.title-logo .q-quantum {
  display: block; font-size: clamp(24px, 5.2vw, 52px); font-weight: 700;
  letter-spacing: 0.4em; padding-left: 0.4em; color: var(--cream);
  text-shadow: 0 0 22px rgba(68,230,212,0.55), 0 2px 12px rgba(0,0,0,0.7);
}
.title-logo .q-drop {
  display: block; font-size: clamp(64px, 14vw, 156px); font-weight: 900; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #cffff8 0%, var(--quantum) 48%, #1aa093 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 34px rgba(68,230,212,0.7)) drop-shadow(0 4px 18px rgba(0,0,0,0.6));
}
.title-sub {
  font-family: var(--f-flavor); font-style: italic; font-size: clamp(15px, 2.4vw, 22px);
  color: var(--cream); opacity: 0.88; margin-top: 18px; max-width: 34ch;
  text-shadow: 0 2px 14px rgba(0,0,0,0.92);
}
.btn {
  font-family: var(--f-ui); font-weight: 600; letter-spacing: 0.04em;
  border: none; cursor: pointer; border-radius: var(--r-md);
  padding: 14px 30px; font-size: 15px; transition: transform .12s, box-shadow .2s, background .2s;
}
.btn-primary {
  background: linear-gradient(180deg, #ff2d42, var(--red) 60%, var(--red-deep));
  color: #fff; box-shadow: 0 10px 30px -8px var(--red-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -8px var(--red-glow); }
.btn-ghost {
  background: rgba(255,255,255,0.04); color: var(--cream);
  border: 1px solid rgba(212,175,55,0.3);
}
.btn-ghost:hover { background: rgba(212,175,55,0.12); }
.btn:active { transform: translateY(0) scale(.98); }
.title-actions { display: flex; gap: 14px; margin-top: 34px; flex-wrap: wrap; justify-content: center; }
.title-foot { position: absolute; bottom: 22px; font-size: 11px; letter-spacing: .25em; color: var(--faint); text-transform: uppercase; }

/* ===================== TOP HUD ===================== */
.hud {
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(12px, 3vw, 28px);
  background: linear-gradient(180deg, rgba(10,5,8,0.92), rgba(10,5,8,0.4));
  border-bottom: 1px solid rgba(212,175,55,0.18);
  backdrop-filter: blur(6px);
}
.hud .brand { font-family: var(--f-display); font-weight: 700; font-size: 16px; color: var(--gold); letter-spacing: .08em; }
.hud .brand b { color: var(--red); }
.cores { display: flex; gap: 5px; align-items: center; }
.core-pip {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #9af6ec 45%, #138d80);
  box-shadow: 0 0 10px var(--quantum-glow);
}
.core-pip.dead { background: #2a1820; box-shadow: none; border: 1px solid #3a2530; }
.hud-spacer { flex: 1; }
.hud-stat { display: flex; flex-direction: column; line-height: 1.05; }
.hud-stat .k { font-size: 9px; letter-spacing: .2em; color: var(--faint); text-transform: uppercase; }
.hud-stat .v { font-size: 17px; font-weight: 700; color: var(--cream); font-variant-numeric: tabular-nums; }
.hud-stat .v.gold { color: var(--gold); }

/* energy meter (round) */
.objective-bar { flex: 1; min-width: 140px; max-width: 460px; }
.objective-bar .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.objective-bar .label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.objective-bar .nums { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.objective-bar .nums .cur { color: var(--quantum); }
.objective-bar .nums .tgt { color: var(--faint); }
.meter { height: 9px; border-radius: 6px; background: #1c1014; overflow: hidden; border: 1px solid rgba(212,175,55,0.15); position: relative; }
.meter .fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--quantum-dk), var(--quantum));
  box-shadow: 0 0 12px var(--quantum-glow); transition: width .25s ease;
}
.meter.done .fill { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); box-shadow: 0 0 14px rgba(212,175,55,0.6); }

/* ===================== ROUND BODY ===================== */
#screen-round { overflow: hidden; }
.round-body {
  flex: 1; display: flex; gap: clamp(10px, 2vw, 22px);
  padding: clamp(10px, 2vw, 22px); align-items: stretch; justify-content: center;
  min-height: 0;
}
.panel {
  width: 210px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
}
.panel h3 { font-family: var(--f-ui); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.deck { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; padding-right: 2px; }
.chip {
  display: flex; gap: 9px; align-items: center; padding: 8px 10px;
  background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.06);
  border-left-width: 3px; border-radius: var(--r-sm); cursor: default;
}
.chip .ic { width: 22px; height: 22px; flex-shrink: 0; }
.chip .nm { font-size: 12px; font-weight: 600; line-height: 1.1; }
.chip .rt { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }
.chip.empty { justify-content: center; color: var(--faint); font-size: 11px; font-style: italic; border-style: dashed; }

.board-wrap {
  flex: 0 1 auto; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
}
.board-inner {
  position: relative; height: 100%;
  aspect-ratio: 62 / 80; max-height: 100%;
  display: flex;
}
#board { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.board-hint {
  position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: var(--muted); letter-spacing: .08em; pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.corrupt-banner {
  position: absolute; top: 14px; left: 50%; transform: translate(-50%, -8px);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 18px; border-radius: 8px; pointer-events: none; text-align: center;
  background: rgba(120,8,20,0.88); border: 1px solid var(--red);
  opacity: 0; visibility: hidden; z-index: 6;
  transition: opacity .16s ease, transform .16s ease;
}
.corrupt-banner.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); animation: corruptPulse .7s infinite; }
.corrupt-banner .cb-flash { font-weight: 800; font-size: 14px; letter-spacing: .12em; color: #fff; }
.corrupt-banner .cb-sub { font-size: 11px; color: #ffd0d6; letter-spacing: .03em; }
@keyframes corruptPulse {
  0%, 100% { box-shadow: 0 0 22px rgba(229,21,43,0.55); }
  50%      { box-shadow: 0 0 40px rgba(229,21,43,0.95); }
}
.balls-rail { display: flex; gap: 6px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.ball-pip { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #9af6ec 45%, #138d80); box-shadow: 0 0 8px var(--quantum-glow); }
.ball-pip.spent { background: #241620; box-shadow: none; }

/* ===================== BOSS PANEL ===================== */
.boss-card {
  width: 250px; flex-shrink: 0; border-radius: var(--r-lg); overflow: hidden;
  background: var(--ink-3); border: 1px solid rgba(229,21,43,0.3);
  box-shadow: var(--shadow-card); display: flex; flex-direction: column;
}
.boss-portrait { position: relative; aspect-ratio: 3/4; background: #000; overflow: hidden; }
.boss-portrait img {
  width: 100%; height: 100%; object-fit: cover; object-position: top center;
  transform-origin: 50% 35%; will-change: transform, filter;
  animation: bossBreath 4.4s ease-in-out infinite;
}
.boss-portrait::after { content:''; position:absolute; inset:0; z-index: 1; background: linear-gradient(180deg, transparent 50%, rgba(12,5,9,0.95)); }

/* --- atmospheric FX overlays on the portrait --- */
.boss-fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .7s ease; }
.boss-fx.rage {
  background: radial-gradient(62% 50% at 50% 36%, rgba(255,46,46,0.55), rgba(180,12,28,0.18) 58%, transparent 78%);
  mix-blend-mode: overlay;
}
.boss-fx.glow {
  background: linear-gradient(180deg, rgba(255,64,52,0.6), transparent 46%);
  mix-blend-mode: screen; animation: emberPulse 2.1s ease-in-out infinite;
}
.boss-fx.corrupt {
  background:
    radial-gradient(34% 22% at 41% 27%, rgba(120,70,255,0.5), transparent 70%),
    radial-gradient(38% 24% at 56% 27%, rgba(70,230,212,0.45), transparent 70%);
  mix-blend-mode: screen; animation: corruptFlicker 1.5s steps(6) infinite;
}

/* --- breathing / idle motion --- */
@keyframes bossBreath {
  0%, 100% { transform: scale(1.03) translateY(0); }
  50%      { transform: scale(1.045) translateY(-0.5%); }
}
@keyframes bossBreathHard {
  0%, 100% { transform: scale(1.04) translateY(0) rotate(-0.3deg); }
  50%      { transform: scale(1.075) translateY(-0.9%) rotate(0.4deg); }
}
@keyframes emberPulse { 0%, 100% { filter: brightness(0.75); } 50% { filter: brightness(1.45); } }
@keyframes corruptFlicker { 0%,100% { filter: brightness(0.7); } 30% { filter: brightness(1.3); } 60% { filter: brightness(0.9); } }

/* --- EXPRESSIONS (driven by data-expr on .boss-card) --- */
.boss-card[data-expr="calm"]    .boss-fx.glow { opacity: 0.22; }
.boss-card[data-expr="smug"]    .boss-fx.rage { opacity: 0.16; }
.boss-card[data-expr="smug"]    .boss-fx.glow { opacity: 0.42; }
.boss-card[data-expr="angry"]   .boss-fx.rage { opacity: 0.5; }
.boss-card[data-expr="angry"]   .boss-fx.glow { opacity: 0.7; }
.boss-card[data-expr="angry"]   .boss-portrait img { animation-duration: 2.6s; }
.boss-card[data-expr="furious"] .boss-fx.rage    { opacity: 0.72; }
.boss-card[data-expr="furious"] .boss-fx.glow    { opacity: 0.92; }
.boss-card[data-expr="furious"] .boss-fx.corrupt { opacity: 0.6; }
.boss-card[data-expr="furious"] .boss-portrait img { animation: bossBreathHard 1.7s ease-in-out infinite; }
.boss-card[data-expr="enraged"] .boss-fx.rage    { opacity: 0.95; }
.boss-card[data-expr="enraged"] .boss-fx.glow    { opacity: 1; }
.boss-card[data-expr="enraged"] .boss-fx.corrupt { opacity: 0.9; }
.boss-card[data-expr="enraged"] .boss-portrait img { animation: bossBreathHard 1.15s ease-in-out infinite; }
.boss-card[data-expr="enraged"] { animation: bossRageLoop 2.6s ease-in-out infinite; }
.boss-card[data-expr="defeat"]  .boss-fx { opacity: 0 !important; }
.boss-card[data-expr="defeat"]  .boss-portrait img { animation: none; filter: grayscale(0.95) brightness(0.45); transform: scale(1.02); }
@keyframes bossRageLoop { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-1.6px); } 75% { transform: translateX(1.6px); } }

/* fury card chrome — angrier, hotter border */
.boss-card.fury { border-color: rgba(229,21,43,0.62); box-shadow: 0 0 30px rgba(229,21,43,0.4), var(--shadow-card); }
.boss-card.fury .boss-name .nm { color: #ffd7b0; text-shadow: 0 0 14px rgba(229,21,43,0.8); }
.boss-card.fury .boss-name .ti { color: var(--quantum); }

/* OMEGA REGINALD — chromed, mechanical, cold cyan. Built on the fury portrait. */
.boss-card.omega {
  border-color: rgba(68,230,212,0.6);
  box-shadow: 0 0 34px rgba(68,230,212,0.4), 0 0 18px rgba(229,21,43,0.28), var(--shadow-card);
}
.boss-card.omega .boss-portrait img {
  filter: grayscale(0.5) contrast(1.4) brightness(0.9) hue-rotate(132deg) saturate(1.5);
}
.boss-card.omega .boss-portrait::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.30) 2px 3px);
  mix-blend-mode: multiply; opacity: 0.6;
}
.boss-card.omega .boss-portrait::after {
  background: linear-gradient(180deg, rgba(68,230,212,0.20) 0%, transparent 28%, transparent 50%, rgba(6,12,14,0.96));
}
.boss-card.omega .boss-fx.rage {
  background: radial-gradient(62% 50% at 50% 40%, rgba(68,230,212,0.55), rgba(20,120,140,0.16) 58%, transparent 78%);
}
.boss-card.omega .boss-fx.glow {
  background: linear-gradient(180deg, rgba(68,230,212,0.6), transparent 46%);
}
.boss-card.omega .boss-name .nm { color: #d7fbf5; text-shadow: 0 0 14px rgba(68,230,212,0.9); letter-spacing: .04em; }
.boss-card.omega .boss-name .ti { color: var(--quantum); }
.boss-card.omega .hpbar { border-color: rgba(68,230,212,0.4); }
.boss-card.omega .hpbar .fill { background: linear-gradient(90deg, var(--quantum-dk), var(--quantum)); box-shadow: 0 0 12px var(--quantum-glow); }

.boss-intent .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.4s infinite; }

/* player ability: Interferencia (jam) */
.board-actions { display: flex; }
.board-actions[hidden] { display: none; }
.ability-btn {
  flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 9px 11px; border-radius: var(--r-sm); text-align: left;
  background: linear-gradient(180deg, rgba(68,230,212,0.16), rgba(68,230,212,0.05));
  border: 1px solid rgba(68,230,212,0.5); color: var(--cream);
  font-family: var(--f-ui); transition: transform .1s ease, box-shadow .2s ease, opacity .2s ease;
  position: relative; overflow: hidden;
}
.ability-btn .ab-icon { font-size: 20px; line-height: 1; filter: drop-shadow(0 0 6px var(--quantum-glow)); }
.ability-btn .ab-text { display: flex; flex-direction: column; line-height: 1.15; flex: 1; }
.ability-btn .ab-label { font-weight: 700; font-size: 13px; color: var(--quantum); letter-spacing: .02em; }
.ability-btn .ab-sub { font-size: 10px; color: var(--muted); }
.ability-btn .ab-cd { font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.ability-btn.ready { box-shadow: 0 0 16px rgba(68,230,212,0.35); animation: jamReady 1.8s ease-in-out infinite; }
.ability-btn.ready .ab-cd { color: var(--quantum); }
.ability-btn.ready:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(68,230,212,0.6); }
.ability-btn.ready:active { transform: translateY(0); }
.ability-btn.cooling { cursor: default; opacity: 0.55; border-color: rgba(154,138,134,0.4); background: rgba(154,138,134,0.08); animation: none; }
.ability-btn.cooling .ab-label, .ability-btn.cooling .ab-icon { color: var(--muted); filter: none; }
.ability-btn.cooling .ab-cd { color: var(--gold); }
@keyframes jamReady { 0%,100% { box-shadow: 0 0 12px rgba(68,230,212,0.3); } 50% { box-shadow: 0 0 22px rgba(68,230,212,0.6); } }
.boss-card.react-hit .boss-portrait img { animation: bossFlinch .26s ease; }
.boss-card.react-cast .boss-intent { background: rgba(229,21,43,0.24); border-color: rgba(229,21,43,0.6); }
.boss-card.react-attack .boss-portrait img { animation: bossLunge .44s cubic-bezier(.3,1.4,.5,1); }
.boss-card.react-phase .boss-portrait img { animation: bossPunch .55s ease; }
.boss-card.react-phase { animation: bossFlash .5s ease; }
.boss-card.react-defeat { animation: bossDefeat 2s ease forwards; }
@keyframes bossFlinch { 0%,100% { transform: scale(1.03) translateX(0); } 35% { transform: scale(1.05) translateX(5px); } 65% { transform: scale(1.04) translateX(-3px); } }
@keyframes bossLunge { 0% { transform: scale(1.03); } 40% { transform: scale(1.16) translateY(-1.6%); } 100% { transform: scale(1.03); } }
@keyframes bossPunch { 0% { transform: scale(1.03); filter: none; } 22% { transform: scale(1.2); filter: brightness(1.9) saturate(1.4); } 100% { transform: scale(1.03); filter: none; } }
@keyframes bossFlash { 0%,100% { box-shadow: var(--shadow-card); } 50% { box-shadow: 0 0 38px var(--red-glow), var(--shadow-card); } }
@keyframes bossDefeat { 0% { filter: none; opacity: 1; } 100% { filter: grayscale(1) brightness(.5); opacity: .68; } }
.boss-name { position: absolute; bottom: 10px; left: 12px; right: 12px; z-index: 2; }
.boss-name .ti { font-size: 9px; letter-spacing: .25em; text-transform: uppercase; color: var(--red); }
.boss-name .nm { font-family: var(--f-display); font-weight: 700; font-size: 18px; line-height: 1; color: var(--cream); }
.boss-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.hpbar { height: 14px; border-radius: 7px; background: #1c1014; border: 1px solid rgba(229,21,43,0.3); overflow: hidden; position: relative; }
.hpbar .fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red-deep), var(--red)); box-shadow: 0 0 12px var(--red-glow); transition: width .35s cubic-bezier(.2,.8,.2,1); }
.hpbar .txt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
.boss-phase { font-size: 11px; color: var(--gold); font-weight: 600; letter-spacing: .04em; }
.boss-quip { font-family: var(--f-flavor); font-style: italic; font-size: 14px; color: var(--muted); min-height: 38px; }
.boss-intent {
  display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--cream);
  padding: 7px 9px; border-radius: var(--r-sm); background: rgba(229,21,43,0.1); border: 1px solid rgba(229,21,43,0.25);
}
.boss-intent .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.4s infinite; }

/* boss meta: timer + quantum reserve */
.boss-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.boss-timer {
  font-family: var(--f-display); font-weight: 700; font-size: 22px; line-height: 1;
  color: var(--cream); letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.boss-timer.low { color: var(--red); animation: pulse 0.9s infinite; }
.boss-qbox { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.boss-qbox .q { font-family: var(--f-display); font-weight: 700; font-size: 16px; color: var(--quantum); }
.boss-qbox .qc { font-size: 9px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.boss-qbox .qc b { color: var(--gold); }
.boss-qbox .qballs b { color: var(--quantum); }
.boss-qbox .qballs b.low { color: var(--red); }

/* boss reaction animations */
.boss-card.react-hit { animation: bossHit .26s ease; }
.boss-card.react-cast .boss-intent { background: rgba(229,21,43,0.22); border-color: rgba(229,21,43,0.55); }
.boss-card.react-attack { animation: bossShake .42s ease; }
.boss-card.react-phase { animation: bossFlash .5s ease; }
.boss-card.react-defeat { animation: bossDefeat 2s ease forwards; }
@keyframes bossHit { 0%,100% { transform: translateX(0); } 30% { transform: translateX(4px); } 60% { transform: translateX(-3px); } }
@keyframes bossShake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes bossFlash { 0%,100% { box-shadow: var(--shadow-card); } 50% { box-shadow: 0 0 32px var(--red-glow), var(--shadow-card); } }
@keyframes bossDefeat { 0% { filter: none; opacity: 1; } 100% { filter: grayscale(1) brightness(.5); opacity: .65; } }

@media (max-width: 880px) {
  .round-body { flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; }
  .panel { width: 100%; flex-direction: column; }
  .panel .deck { flex-direction: row; overflow-x: auto; overflow-y: visible; padding-bottom: 4px; }
  .chip { min-width: 150px; }
  .board-wrap { order: -1; }
  .board-inner { height: auto; width: 100%; max-width: min(70vh, 100%); aspect-ratio: 62/80; }
  .boss-card { width: 100%; flex-direction: row; }
  .boss-portrait { width: 120px; aspect-ratio: auto; flex-shrink: 0; }
  .boss-body { flex: 1; }
}
