/* KreepCore arcade layer (F1.8) - full-screen ship console */
.kc-arcade {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 4, 10, 0.92);
  padding: 0;
}
/* iOS Safari: 100% of a fixed inset-0 element tracks the layout viewport,
   so the frame bottom (and anything anchored there) can end up underneath
   the collapsed browser toolbar. Dynamic viewport units track what is
   actually visible. */
@supports (height: 100dvh) {
  .kc-arcade { height: 100dvh; bottom: auto; }
}
.kc-arcade-frame {
  position: relative;
  width: min(100%, 460px);
  height: min(100%, 860px);
  display: flex;
  flex-direction: column;
  background: #060811;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
.kc-arcade-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(120, 200, 240, 0.22);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--cyan, #7fd8ff);
}
.kc-arcade-cam { flex: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc-arcade-crt-toggle {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-secondary, #9ab);
  background: rgba(6, 10, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  padding: 3px 8px;
  min-height: 24px;
  cursor: pointer;
}
.kc-arcade-crt-toggle[aria-pressed="true"] { color: var(--cyan, #7fd8ff); border-color: rgba(120, 200, 240, 0.5); }
.kc-arcade-close {
  background: none;
  border: none;
  color: var(--text-secondary, #9ab);
  font-size: 26px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}
.kc-arcade-stage { position: relative; flex: 1; min-height: 0; }
.kc-arcade-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; transition: filter 220ms ease; }
.kc-arcade-canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(125, 220, 255, 0.72); }
.kc-arcade--hold-paused .kc-arcade-canvas { filter: blur(1.4px) saturate(0.72) brightness(0.72); }

/* Touch AFK gate. The simulation time scale eases to zero in JS while this
   glass panel makes the paused state explicit without blocking the next hold. */
.kc-arcade-hold {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
  color: var(--text-primary, #dfe9f2);
  font-family: var(--font-mono);
  background: radial-gradient(circle at center, rgba(8, 18, 32, 0.46), rgba(3, 6, 14, 0.72));
  opacity: 1;
  transition: opacity 180ms ease, backdrop-filter 220ms ease;
  backdrop-filter: blur(1px);
}
.kc-arcade-hold[hidden] { display: none; }
.kc-arcade-hold b { color: var(--cyan, #7fd8ff); font-size: 18px; letter-spacing: 0.11em; text-transform: uppercase; }
.kc-arcade-hold span { max-width: 300px; color: var(--text-secondary, #9ab); font-size: 13.5px; line-height: 1.45; }
.kc-arcade-hold-icon {
  width: 38px;
  height: 48px;
  border: 2px solid rgba(150, 225, 255, 0.8);
  border-radius: 22px 22px 16px 16px;
  box-shadow: 0 0 18px rgba(100, 205, 255, 0.25);
  position: relative;
}
.kc-arcade-hold-icon::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 7px;
  width: 8px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 8px;
  transform: translateX(-50%);
  animation: kc-hold-pulse 1s ease-in-out infinite alternate;
}
@keyframes kc-hold-pulse { from { opacity: 0.35; transform: translateX(-50%) translateY(2px); } to { opacity: 1; transform: translateX(-50%) translateY(-1px); } }

/* CRT overlay: static vignette + scanlines, zero per-frame cost */
.kc-arcade-crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.38) 100%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0.05) 1px 3px);
  mix-blend-mode: normal;
}
.kc-arcade--nocrt .kc-arcade-crt { display: none; }

/* HUD */
.kc-arcade-hud {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-primary, #dfe9f2);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.kc-arcade-ore { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.kc-arcade-ore svg { width: 15px; height: 15px; color: var(--ore-color, #d9a45b); }
.kc-arcade-combo {
  flex: none;
  padding: 2px 5px;
  border: 1px solid rgba(130, 225, 190, 0.48);
  border-radius: 3px;
  color: #a8f0cd;
  font-size: 11px;
  letter-spacing: 0.04em;
  background: rgba(10, 35, 31, 0.72);
  animation: kc-arcade-combo-in 0.18s ease-out;
}
.kc-arcade-combo[hidden] { display: none; }
.kc-arcade-combo.hot { color: #d9f7ff; border-color: rgba(150, 225, 255, 0.72); box-shadow: 0 0 10px rgba(100, 210, 255, 0.28); }
@keyframes kc-arcade-combo-in { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.kc-arcade-shields { display: inline-flex; align-items: center; gap: 3px; color: var(--cyan, #7fd8ff); }
.kc-arcade-pip { width: 15px; height: 15px; opacity: 0.35; }
.kc-arcade-pip.on { opacity: 1; }
.kc-arcade-pip-count { font-size: 13px; margin-left: 2px; }
.kc-arcade-progress {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 15px;
  border: 1px solid rgba(120, 200, 240, 0.5);
  border-radius: 8px;
  background: rgba(10, 20, 40, 0.6);
  overflow: visible;
}
.kc-arcade-progress i {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  border-radius: 7px;
  background: var(--cyan, #7fd8ff);
  box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.28);
}
.kc-arcade-progress span { font-size: 13px; width: 38px; text-align: right; flex: none; margin-left: 4px; }

/* Phase banner: brief centered callout on each phase change */
.kc-arcade-phase {
  position: absolute;
  top: 18%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan, #7fd8ff);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  opacity: 0;
}
.kc-arcade-phase.show { animation: kc-arcade-phase 2.6s ease-out forwards; }
@keyframes kc-arcade-phase {
  0% { opacity: 0; transform: translateY(6px); }
  12% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* Ore counter pop on pickup */
.kc-arcade-ore.pop { animation: kc-arcade-orepop 0.25s ease-out; }
@keyframes kc-arcade-orepop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* End / reduced-motion message */
.kc-arcade-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  text-align: center;
  padding: 24px;
  background: rgba(4, 6, 14, 0.82);
  font-family: var(--font-mono);
  color: var(--text-primary, #dfe9f2);
  overflow-y: auto;
}
.kc-arcade-msg > :first-child { margin-top: auto; }
.kc-arcade-msg > :last-child { margin-bottom: auto; }
.kc-arcade-msg[hidden] { display: none; }
.kc-arcade-msg-title { font-size: 22px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan, #7fd8ff); }
.kc-arcade-msg-sub { font-size: 17px; }
.kc-arcade-msg-note { font-size: 13.5px; color: var(--text-secondary, #9ab); max-width: 340px; }
.kc-arcade-msg-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* Performance rank on end panels: 1-3 filled marks, staggered entrance */
.kc-sim-rank { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 2px 0; }
.kc-sim-rank-marks { font-size: 26px; line-height: 1; letter-spacing: 8px; padding-left: 8px; }
.kc-sim-rank-marks b { font-weight: 400; display: inline-block; animation: kc-sim-mark-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; }
.kc-sim-rank-marks b:nth-child(2) { animation-delay: 0.14s; }
.kc-sim-rank-marks b:nth-child(3) { animation-delay: 0.28s; }
@keyframes kc-sim-mark-in { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.kc-sim-rank-label { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; }

/* Final-seconds urgency: the countdown pulses by size, not tone */
.kc-arcade-progress span.urgent { animation: kc-sim-urgent 0.5s ease-in-out infinite alternate; transform-origin: right center; }
@keyframes kc-sim-urgent { from { transform: scale(1); } to { transform: scale(1.24); } }

@media (max-width: 390px) {
  .kc-arcade-hud { left: 7px; right: 7px; gap: 6px; font-size: 13px; }
  .kc-arcade-shields { gap: 1px; }
  .kc-arcade-pip { width: 12px; height: 12px; }
  .kc-arcade-pip-count { display: none; }
  .kc-arcade-progress span { width: 32px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .kc-arcade-combo { animation: none; }
  .kc-arcade-canvas { transition: none; }
  .kc-arcade-hold-icon::before { animation: none; }
  .kc-sim-rank-marks b { animation: none; }
  .kc-arcade-progress span.urgent { animation: none; }
}

/* Minigame end-screen buttons: legible tap targets on phones */
.kc-arcade .btn { font-size: 0.85rem; min-height: 40px; padding: 8px 16px; }

/* Real settlement block appended to end ceremonies (rewards granted server-side) */
.kc-mini-rewards { margin-top: 10px; font-family: var(--font-mono); font-size: 14px; width: min(320px, 86%); }
.kc-mini-rewards-title { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-secondary, #9ab); margin-bottom: 6px; }
.kc-mini-rewards-wait { font-size: 13px; color: var(--text-secondary, #9ab); }
.kc-mini-rewards-err { font-size: 13px; color: var(--red, #ef4444); }
.kc-mini-reward { display: flex; justify-content: space-between; gap: 10px; }
.kc-mini-reward i { font-style: normal; color: var(--text-secondary, #9ab); }
.kc-mini-levelup { margin-top: 6px; font-size: 15px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; animation: kc-sim-mark-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; }

/* Console juice: staged entrance, soft exit, message stagger */
@keyframes kc-arcade-in { from { opacity: 0; transform: scale(0.965); } to { opacity: 1; transform: scale(1); } }
@keyframes kc-arcade-out { to { opacity: 0; transform: scale(0.97); } }
.kc-arcade .kc-arcade-frame { animation: kc-arcade-in 0.2s cubic-bezier(0.2, 1.4, 0.4, 1); }
.kc-arcade--closing .kc-arcade-frame { animation: kc-arcade-out 0.16s ease-in forwards; }
.kc-arcade--closing { pointer-events: none; }
@keyframes kc-arcade-msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.kc-arcade-msg > * { animation: kc-arcade-msg-in 0.28s cubic-bezier(0.2, 1, 0.4, 1) backwards; }
.kc-arcade-msg > *:nth-child(2) { animation-delay: 0.05s; }
.kc-arcade-msg > *:nth-child(3) { animation-delay: 0.1s; }
.kc-arcade-msg > *:nth-child(4) { animation-delay: 0.15s; }
.kc-arcade-msg > *:nth-child(5) { animation-delay: 0.2s; }
.kc-arcade-msg > *:nth-child(6) { animation-delay: 0.25s; }
@media (prefers-reduced-motion: reduce) {
  .kc-arcade .kc-arcade-frame, .kc-arcade--closing .kc-arcade-frame, .kc-arcade-msg > * { animation: none; }
}

/* Cinematic hero band atop console panels */
.kc-mini-hero {
  width: min(420px, 92vw);
  aspect-ratio: 3 / 1;
  border: 1px solid rgba(130, 177, 189, 0.3);
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}
