/* ============================================================
   PRISM PROTOCOL — Vortaxis Studio
   Premium dark arcade theme: deep navy, cyan/violet neon.
   ============================================================ */

:root {
  --bg: #070b16;
  --bg-2: #0b1122;
  --panel: #101a33;
  --panel-2: #0d1528;
  --line: #1d2c52;
  --cyan: #22e6ff;
  --cyan-soft: rgba(34, 230, 255, 0.16);
  --violet: #b46bff;
  --violet-soft: rgba(180, 107, 255, 0.14);
  --pink: #ff6ec7;
  --amber: #ffd166;
  --green: #4dffa8;
  --red: #ff5d7a;
  --text: #eaf2ff;
  --text-dim: #8fa3c8;
  --text-faint: #5d6f96;
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: manipulation;
}

.app { height: 100%; width: 100%; }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(34, 230, 255, 0.10), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, rgba(180, 107, 255, 0.12), transparent 60%),
    var(--bg);
}
.screen[aria-hidden="true"] { display: none; }

/* ---------- buttons ---------- */
.btn {
  font: 700 15px/1 var(--font);
  letter-spacing: 0.06em;
  color: var(--text);
  background: linear-gradient(180deg, #16224a, #101a36);
  border: 1px solid #2a3f78;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}
.btn:hover { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(34,230,255,.25), 0 6px 18px rgba(0,0,0,.4); }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn:focus-visible, .btn-icon:focus-visible, .lv-btn:focus-visible, #board:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.btn-primary {
  background: linear-gradient(180deg, #1ad9f5, #0e9fd4);
  border-color: #6ef0ff;
  color: #04121e;
  text-shadow: none;
}
.btn-primary:hover { box-shadow: 0 0 18px rgba(34, 230, 255, 0.45), 0 8px 20px rgba(0,0,0,.45); }
.btn-icon { padding: 9px 13px; font-size: 17px; }
.btn-fire {
  background: linear-gradient(180deg, #c982ff, #8a3ff0);
  border-color: #d9aaff;
  color: #fff;
  min-width: 92px;
  box-shadow: 0 0 14px rgba(180, 107, 255, 0.35);
  flex: none;
}
.btn-fire:disabled { filter: saturate(0.25) brightness(0.7); cursor: default; box-shadow: none; }
kbd {
  font: 700 12px/1 var(--font-mono);
  background: #0a1329;
  border: 1px solid #2a3f78;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--cyan);
}

/* ---------- title screen ---------- */
.screen-title { align-items: center; justify-content: center; overflow: hidden; }
.title-bg { position: absolute; inset: 0; }
.title-bg canvas { width: 100%; height: 100%; display: block; }
.title-inner {
  position: relative;
  text-align: center;
  padding: 24px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.brand {
  font: 700 13px/1 var(--font);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan), 0 0 22px rgba(34,230,255,.5);
  display: inline-block;
}
.game-title {
  font: 800 clamp(38px, 9vw, 74px)/1.02 var(--font);
  letter-spacing: 0.08em;
  color: var(--text);
  text-shadow:
    0 0 14px rgba(34, 230, 255, 0.55),
    0 0 42px rgba(34, 230, 255, 0.28),
    0 0 90px rgba(180, 107, 255, 0.22);
}
.title-dot {
  display: inline-block;
  width: 0.16em; height: 0.16em;
  margin: 0 0.18em;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 12px var(--violet);
  vertical-align: 0.42em;
}
.tagline { color: var(--text-dim); font-size: 15px; max-width: 40ch; margin: 0 auto; }
.title-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.title-actions .btn-primary { padding: 13px 34px; font-size: 17px; }
.title-foot {
  margin-top: 18px;
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: no-preference) {
  .game-title { animation: titleGlow 3.2s ease-in-out infinite; }
  @keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 14px rgba(34,230,255,.55), 0 0 42px rgba(34,230,255,.28), 0 0 90px rgba(180,107,255,.22); }
    50% { text-shadow: 0 0 20px rgba(34,230,255,.8), 0 0 60px rgba(34,230,255,.4), 0 0 120px rgba(180,107,255,.35); }
  }
}

/* ---------- shared panel header ---------- */
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 28, 0.7);
  backdrop-filter: blur(6px);
}
.panel-head h2 {
  font: 800 19px/1 var(--font);
  letter-spacing: 0.16em;
  flex: 1;
  text-align: center;
  color: var(--text);
}
.head-spacer { width: 44px; }

/* ---------- level select ---------- */
.screen-levels { min-height: 0; }
.levels-progress {
  text-align: center;
  color: var(--text-dim);
  font: 600 13px/1.4 var(--font-mono);
  padding: 12px 16px 4px;
  letter-spacing: 0.08em;
}
.level-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  align-content: start;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.lv-btn {
  position: relative;
  background: linear-gradient(180deg, #131e42, #0d1630);
  border: 1px solid #26386e;
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  min-height: 76px;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.lv-btn:hover { border-color: var(--cyan); box-shadow: 0 0 16px rgba(34,230,255,.18); transform: translateY(-1px); }
.lv-btn .lv-num { font: 800 11px/1 var(--font-mono); color: var(--cyan); letter-spacing: 0.14em; }
.lv-btn .lv-name { display: block; font: 700 15px/1.25 var(--font); margin-top: 6px; }
.lv-btn .lv-tag { display: block; font: 600 11px/1.3 var(--font); color: var(--text-dim); margin-top: 5px; letter-spacing: 0.04em; }
.lv-btn .lv-stars { display: block; margin-top: 8px; font-size: 13px; letter-spacing: 2px; color: var(--amber); }
.lv-btn .lv-stars .off { color: #2c3a63; }
.lv-btn.locked { opacity: 0.45; cursor: default; filter: saturate(0.4); }
.lv-btn.locked:hover { border-color: #26386e; box-shadow: none; transform: none; }
.lv-btn .lv-lock { position: absolute; top: 10px; right: 12px; font-size: 14px; }
.lv-btn.current { border-color: var(--violet); box-shadow: 0 0 16px rgba(180,107,255,.25); }

/* ---------- help ---------- */
.screen-help { min-height: 0; }
.help-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.help-card {
  background: linear-gradient(180deg, rgba(19, 30, 66, 0.75), rgba(13, 21, 48, 0.75));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.help-card h3 {
  font: 800 13px/1 var(--font);
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 9px;
}
.help-card p { color: var(--text-dim); font-size: 14px; line-height: 1.55; }
.help-card b { color: var(--text); }
.help-list { list-style: none; margin-top: 9px; display: flex; flex-direction: column; gap: 9px; }
.help-list li { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; line-height: 1.45; flex-wrap: wrap; }
.glyph { display: inline-block; width: 22px; height: 22px; border-radius: 5px; flex: none; background: #0a1329; border: 1px solid #2a3f78; position: relative; }
.glyph-core { border-radius: 50%; border-color: var(--green); box-shadow: inset 0 0 6px rgba(77,255,168,.5); }
.glyph-core::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.glyph-mirror-l, .glyph-mirror-r { border: none; }
.glyph-mirror-l::before { content: ""; position: absolute; left: 3px; top: 17px; width: 20px; height: 3px; background: var(--cyan); transform: rotate(-45deg); transform-origin: left top; border-radius: 2px; box-shadow: 0 0 8px var(--cyan); }
.glyph-mirror-r::before { content: ""; position: absolute; left: 3px; top: 2px; width: 20px; height: 3px; background: var(--cyan); transform: rotate(45deg); transform-origin: left top; border-radius: 2px; box-shadow: 0 0 8px var(--cyan); }
.glyph-split { border-color: var(--violet); }
.glyph-split::before, .glyph-split::after { content: ""; position: absolute; background: var(--violet); box-shadow: 0 0 6px var(--violet); }
.glyph-split::before { left: 3px; right: 3px; top: 9.5px; height: 3px; border-radius: 2px; }
.glyph-split::after { top: 3px; bottom: 3px; left: 9.5px; width: 3px; border-radius: 2px; }
.glyph-rotor { border-color: var(--amber); }
.glyph-rotor::before { content: ""; position: absolute; left: 3px; top: 16px; width: 16px; height: 3px; background: var(--amber); transform: rotate(-45deg); transform-origin: left top; border-radius: 2px; box-shadow: 0 0 8px var(--amber); }
.glyph-portal { border-radius: 50%; border-color: var(--pink); box-shadow: inset 0 0 8px rgba(255,110,199,.6); }
.glyph-pickup { border-color: var(--amber); }
.glyph-pickup::before { content: ""; position: absolute; left: 10px; top: 4px; bottom: 4px; width: 2px; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.glyph-pickup::after { content: ""; position: absolute; left: 6px; right: 6px; top: 10px; height: 2px; background: var(--amber); box-shadow: 0 0 6px var(--amber); }

/* ---------- game screen ---------- */
.screen-game { min-height: 0; }
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 28, 0.7);
}
.hud-mid { flex: 1; min-width: 0; text-align: center; }
.hud-level { font: 800 14px/1.2 var(--font); letter-spacing: 0.12em; color: var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-goal { font: 600 12px/1.3 var(--font); color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hud-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 34, 0.6);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.hud-strip::-webkit-scrollbar { display: none; }
.meter { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.meter-label { font: 800 10px/1 var(--font); letter-spacing: 0.18em; color: var(--text-dim); }
.meter-track {
  flex: 1;
  height: 10px;
  min-width: 70px;
  background: #0a1329;
  border: 1px solid #223462;
  border-radius: 99px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), #6ef0ff);
  box-shadow: 0 0 10px rgba(34, 230, 255, 0.55);
  transition: width 0.15s linear, background 0.3s ease;
}
.meter-fill.low { background: linear-gradient(90deg, #ff9d5d, var(--red)); box-shadow: 0 0 10px rgba(255, 93, 122, 0.6); }
.meter-num { font: 700 13px/1 var(--font-mono); color: var(--cyan); min-width: 3ch; }
.meter-num.low { color: var(--red); }
.core-dots { display: flex; gap: 7px; align-items: center; }
.core-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #2c3a63;
  transition: all 0.25s ease;
}
.core-dot.on {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}
.palette { display: flex; gap: 8px; align-items: center; }
.pal-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0a1329;
  border: 1px solid #223462;
  border-radius: 9px;
  padding: 5px 9px;
  font: 700 12px/1 var(--font-mono);
  color: var(--text-dim);
}
.pal-item .pal-shape {
  width: 16px; height: 16px; border-radius: 4px; position: relative; flex: none;
  background: #0d1630; border: 1px solid #2a3f78;
}
.pal-item .pal-count { color: var(--text); }
.pal-item.empty { opacity: 0.45; }
.pal-item.empty .pal-count { color: var(--red); }
.pal-item .pal-shape.pm::before { content: ""; position: absolute; left: 2px; top: 12px; width: 14px; height: 2.5px; background: var(--cyan); transform: rotate(-45deg); transform-origin: left top; border-radius: 2px; box-shadow: 0 0 6px var(--cyan); }
.pal-item .pal-shape.ps::before, .pal-item .pal-shape.ps::after { content: ""; position: absolute; background: var(--violet); box-shadow: 0 0 5px var(--violet); }
.pal-item .pal-shape.ps::before { left: 2px; right: 2px; top: 7px; height: 2.5px; }
.pal-item .pal-shape.ps::after { top: 2px; bottom: 2px; left: 7px; width: 2.5px; }

.board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
#board {
  display: block;
  border-radius: 12px;
  touch-action: none;
  background: #080d1c;
}
#board:focus-visible { outline-offset: 4px; }
.board-msg {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  font: 700 13px/1 var(--font);
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: rgba(9, 14, 28, 0.85);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 99px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-msg.show { opacity: 1; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 18, 0.72);
  backdrop-filter: blur(4px);
  z-index: 30;
  padding: 18px;
}
.overlay[aria-hidden="true"] { display: none; }
.overlay-card {
  background: linear-gradient(180deg, #14204a, #0d1631);
  border: 1px solid #2a3f78;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overlay-kicker { font: 800 11px/1 var(--font); letter-spacing: 0.3em; color: var(--violet); }
.overlay-card h3 { font: 800 24px/1.15 var(--font); letter-spacing: 0.04em; }
.overlay-brief { color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.overlay-hint { color: var(--text-faint); font-size: 12.5px; line-height: 1.5; }
.overlay-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.stars { display: flex; gap: 10px; justify-content: center; font-size: 26px; min-height: 32px; }
.stars .st { color: #2c3a63; }
.stars .st.on { color: var(--amber); text-shadow: 0 0 12px rgba(255, 209, 102, 0.7); }

@media (prefers-reduced-motion: no-preference) {
  .overlay-card { animation: cardIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
  @keyframes cardIn { from { transform: translateY(14px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ---------- responsive: portrait / small ---------- */
@media (max-width: 620px) {
  .hud-goal { display: none; }
  .hud-level { font-size: 12px; }
  .meter { min-width: 100px; }
  .meter-label { display: none; }
  .hud-strip { gap: 10px; flex-wrap: wrap; }
  .btn-fire { order: -1; }
  .board-wrap { padding: 8px; }
  .overlay-card { padding: 20px 18px 16px; }
  .btn { padding: 10px 14px; font-size: 14px; }
}
@media (max-height: 560px) {
  .hud-strip { flex-wrap: wrap; }
}
