@font-face { font-family: 'Cinzel'; src: url('./assets/fonts/Cinzel-500.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Cinzel'; src: url('./assets/fonts/Cinzel-700.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('./assets/fonts/Outfit-300.ttf') format('truetype'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('./assets/fonts/Outfit-400.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('./assets/fonts/Outfit-600.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('./assets/fonts/Outfit-700.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --ink: #080b18;
  --ink-soft: #0e1427;
  --paper: #f2f6ff;
  --muted: #9fb0cf;
  --cyan: #7ff4ff;
  --cyan-deep: #2b9fb8;
  --gold: #ffd15c;
  --gold-soft: #ffe9a8;
  --rose: #ff7fa8;
  --violet: #b28cff;
  --panel: rgba(12, 18, 38, 0.72);
  --line: rgba(157, 189, 255, 0.16);
  --display: 'Cinzel', 'Times New Roman', serif;
  --ui: 'Outfit', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05070f; }
body {
  font-family: var(--ui);
  color: var(--paper);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7em; padding: 0.12em 0.42em;
  border: 1px solid rgba(200, 222, 255, 0.28);
  border-bottom-color: rgba(200, 222, 255, 0.12);
  border-radius: 5px;
  background: rgba(15, 23, 46, 0.65);
  color: #dfe9ff; font-size: 0.72em; font-weight: 600; letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.grade-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(circle at 68% 18%, rgba(127, 244, 255, 0.05), transparent 42%),
    radial-gradient(circle at 20% 90%, rgba(178, 140, 255, 0.07), transparent 40%),
    linear-gradient(180deg, rgba(20, 42, 80, 0.12), transparent 35%, rgba(4, 6, 16, 0.26));
  mix-blend-mode: normal;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(3, 5, 14, 0.44) 100%);
}
#damage-flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 60; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(255, 42, 84, 0.5) 100%);
  transition: opacity 0.16s ease;
}
#damage-flash.active { opacity: 1; }

.screen {
  position: absolute; inset: 0; z-index: 20;
  opacity: 1; visibility: visible;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
:not(.screen).hidden { display: none !important; }
.screen.hidden .btn, .screen.hidden button { pointer-events: none; }

/* ---------- shared typography ---------- */
.eyebrow {
  margin: 0 0 14px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--gold-soft); opacity: 0.84;
}
.screen-title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(34px, 4.3vw, 62px); line-height: 1.02; margin: 0 0 18px;
  letter-spacing: 0.02em;
  color: #f5f8ff;
  text-shadow: 0 0 40px rgba(127, 244, 255, 0.18);
}
.screen-title em {
  font-style: normal;
  background: linear-gradient(100deg, var(--gold-soft), var(--gold) 50%, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.link-btn {
  margin-top: 18px; align-self: flex-start;
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); padding: 4px 0; border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.link-btn:hover { color: var(--cyan); border-color: rgba(127, 244, 255, 0.4); }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  padding: 15px 30px; border-radius: 4px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s, background 0.25s, color 0.25s;
  overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,0.2) 50%, transparent 80%);
  transform: translateX(-120%); transition: transform 0.6s ease;
}
.btn:hover::after { transform: translateX(120%); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn-primary {
  color: #171326; background: linear-gradient(105deg, #ffe9a8, #ffd15c 42%, #9ff7ff);
  box-shadow: 0 10px 40px rgba(255, 209, 92, 0.18), inset 0 1px 0 rgba(255,255,255,0.6);
}
.btn-primary:hover { box-shadow: 0 14px 50px rgba(255, 209, 92, 0.32), inset 0 1px 0 rgba(255,255,255,0.8); }
.btn-ghost {
  color: #e7efff; border: 1px solid rgba(190, 216, 255, 0.28);
  background: rgba(12, 20, 40, 0.35); backdrop-filter: blur(8px);
}
.btn-ghost:hover { border-color: rgba(127, 244, 255, 0.6); box-shadow: 0 0 30px rgba(127, 244, 255, 0.12); }
.btn-glass {
  color: #dfe9ff; border: 1px solid var(--line); background: rgba(18, 27, 52, 0.45);
  backdrop-filter: blur(10px);
}
.btn-glass:hover { border-color: rgba(255, 209, 92, 0.42); }
.btn-small { padding: 11px 18px; font-size: 10px; letter-spacing: 0.16em; }

/* ---------- loader ---------- */
#loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, #0d1732 0%, #05070f 70%);
  z-index: 100;
  transition: opacity 0.8s ease, visibility 0.8s;
}
#loader.hidden { opacity: 0; visibility: hidden; }
.loader-sigil { position: relative; width: 92px; height: 92px; margin-bottom: 28px; }
.loader-sigil span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(127, 244, 255, 0.5);
  border-top-color: transparent; border-left-color: transparent;
  animation: spin 2.6s linear infinite;
}
.loader-sigil span:nth-child(2) { inset: 10px; border-color: rgba(255, 209, 92, 0.5); border-bottom-color: transparent; animation-duration: 1.8s; animation-direction: reverse; }
.loader-sigil span:nth-child(3) { inset: 22px; border-color: rgba(178, 140, 255, 0.65); border-right-color: transparent; animation-duration: 3.4s; }
.loader-sigil::after {
  content: ''; position: absolute; inset: 38px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 30px var(--cyan), 0 0 70px rgba(127,244,255,0.4);
  animation: pulse 1.8s ease-in-out infinite;
}
.loader-title { font-family: var(--display); letter-spacing: 0.22em; font-size: 15px; color: #c7d6f6; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 0.55; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.12); } }

/* ---------- title ---------- */
.title-screen {
  display: flex; align-items: center;
  background:
    linear-gradient(90deg, rgba(4, 7, 17, 0.88) 0%, rgba(5, 9, 22, 0.62) 34%, rgba(5, 9, 22, 0.08) 64%, rgba(5, 9, 22, 0.32) 100%),
    linear-gradient(180deg, rgba(3, 6, 15, 0.55), transparent 30%, transparent 72%, rgba(3, 6, 15, 0.72));
  z-index: 30;
}
.title-content {
  position: relative; z-index: 3;
  width: min(640px, 52vw); margin-left: clamp(28px, 8vw, 132px);
  display: flex; flex-direction: column;
}
.logo {
  margin: 0; font-family: var(--display); font-weight: 700;
  line-height: 0.92; letter-spacing: 0.045em;
  display: flex; flex-direction: column; align-items: flex-start;
  filter: drop-shadow(0 16px 40px rgba(0,0,0,0.55));
}
.logo-call {
  font-size: clamp(46px, 6.6vw, 98px);
  background: linear-gradient(180deg, #ffffff 4%, #d7e9ff 42%, #7fb7db 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-left: 0.06em;
}
.logo-of {
  font-family: var(--display); font-weight: 500; font-style: italic;
  font-size: clamp(22px, 2.2vw, 33px); letter-spacing: 0.3em;
  color: var(--gold-soft); margin: -0.04em 0 0.02em 0.22em;
  opacity: 0.92;
}
.logo-mana {
  font-size: clamp(54px, 7.6vw, 116px);
  background: linear-gradient(94deg, #ffd15c 2%, #fff1bd 28%, #9ff7ff 62%, #7f8dff 100%);
  background-size: 180% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 7s ease-in-out infinite;
}
@keyframes shine { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.title-rule { display: flex; align-items: center; gap: 10px; width: min(360px, 76%); margin: 22px 0 18px; }
.title-rule i { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 209, 92, 0.55)); }
.title-rule i:last-child { background: linear-gradient(90deg, rgba(255, 209, 92, 0.55), transparent); }
.title-rule b { width: 8px; height: 8px; transform: rotate(45deg); border: 1px solid var(--gold); background: rgba(255, 209, 92, 0.2); box-shadow: 0 0 14px rgba(255, 209, 92, 0.4); }
.title-sub {
  margin: 0 0 30px; max-width: 430px;
  font-size: clamp(14px, 1.15vw, 17px); line-height: 1.75; font-weight: 300;
  color: #c4d2e9;
}
.title-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title-meta {
  display: flex; flex-wrap: wrap; gap: 14px 18px; margin-top: 28px;
  font-size: 10.5px; letter-spacing: 0.1em; color: #8697b7; text-transform: uppercase;
}
.title-meta span { display: inline-flex; align-items: center; gap: 7px; }
.title-meta kbd { font-size: 9px; padding: 3px 5px; }
.build-tag {
  position: absolute; right: 28px; bottom: 22px; z-index: 3;
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: rgba(173, 192, 224, 0.55);
}
.title-aura { position: absolute; right: -6vw; top: 50%; transform: translateY(-50%); width: min(58vw, 780px); height: min(58vw, 780px); z-index: 1; opacity: 0.9; pointer-events: none; }
.sigil-ring { position: absolute; border-radius: 50%; }
.ring-a {
  inset: 4%;
  border: 1px solid rgba(127, 244, 255, 0.24);
  box-shadow: inset 0 0 80px rgba(127, 244, 255, 0.06), 0 0 70px rgba(127, 244, 255, 0.06);
  animation: spin 70s linear infinite;
}
.ring-a::before, .ring-b::before {
  content: ''; position: absolute; inset: 3%; border-radius: 50%;
  border: 1px dashed rgba(255, 209, 92, 0.2);
}
.ring-b {
  inset: 14%;
  border: 1px solid rgba(255, 209, 92, 0.18);
  animation: spin 45s linear infinite reverse;
}
.ring-c {
  inset: 28%;
  border: 1px solid rgba(178, 140, 255, 0.16);
  background: radial-gradient(circle at 50% 50%, rgba(127, 244, 255, 0.07), transparent 62%);
  animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(0.97); opacity: 0.65; } 50% { transform: scale(1.03); opacity: 1; } }
.reveal-1, .reveal-2, .reveal-3, .reveal-4, .reveal-5 { opacity: 0; }
.title-screen:not(.hidden) .reveal-1 { animation: rise 1.1s 0.15s cubic-bezier(0.2,0.7,0.2,1) forwards; }
.title-screen:not(.hidden) .reveal-2 { animation: rise 1.2s 0.32s cubic-bezier(0.2,0.7,0.2,1) forwards; }
.title-screen:not(.hidden) .reveal-3 { animation: rise 1.2s 0.55s cubic-bezier(0.2,0.7,0.2,1) forwards; }
.title-screen:not(.hidden) .reveal-4 { animation: rise 1.2s 0.75s cubic-bezier(0.2,0.7,0.2,1) forwards; }
.title-screen:not(.hidden) .reveal-5 { animation: rise 1.2s 0.95s cubic-bezier(0.2,0.7,0.2,1) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- studio ---------- */
.studio-screen {
  z-index: 35;
  background: linear-gradient(90deg, rgba(4,8,18,0) 0%, rgba(4,8,18,0.1) 40%, rgba(4,8,18,0.8) 66%, rgba(4,8,18,0.94) 100%),
              linear-gradient(180deg, rgba(4,8,18,0.4), transparent 22%, transparent 74%, rgba(4,8,18,0.8));
  display: flex; justify-content: flex-end;
}
.studio-wrap { width: 100%; display: flex; justify-content: flex-end; align-items: center; padding: 4vh 4vw; }
.studio-copy {
  width: min(432px, 38vw);
  max-height: 92vh; overflow-y: auto; scrollbar-width: thin;
  padding: 34px 34px 28px;
  background: linear-gradient(160deg, rgba(17, 26, 50, 0.82), rgba(8, 13, 28, 0.72));
  border: 1px solid rgba(168, 198, 255, 0.16);
  border-radius: 14px;
  backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: 0 30px 100px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex; flex-direction: column;
  animation: panelIn 0.9s cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes panelIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: translateX(0); } }
.studio-copy .screen-title { font-size: clamp(30px, 3vw, 46px); }
.studio-sub { margin: 0 0 24px; font-size: 13px; line-height: 1.65; color: #a7b7d4; font-weight: 300; }
.name-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 22px; }
.name-field label { font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-soft); opacity: 0.8; }
.name-field input {
  background: rgba(8, 14, 30, 0.6); border: 1px solid rgba(160, 195, 255, 0.2);
  border-radius: 7px; padding: 12px 14px; font-size: 16px; font-family: var(--display);
  letter-spacing: 0.06em; color: #f4f8ff; outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.name-field input:focus { border-color: rgba(127, 244, 255, 0.55); box-shadow: 0 0 0 3px rgba(127, 244, 255, 0.08); }
.palette-root { display: flex; flex-direction: column; gap: 13px; margin-bottom: 24px; }
.palette-row { display: flex; align-items: center; gap: 12px; }
.palette-label { width: 48px; flex: none; font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: #8b9cbb; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 27px; height: 27px; border-radius: 50%; position: relative;
  background: var(--sw); border: 2px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.22), 0 2px 8px rgba(0,0,0,0.28);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 3px rgba(127, 244, 255, 0.32), inset 0 2px 4px rgba(255,255,255,0.25); }
.studio-actions { display: flex; gap: 10px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.studio-actions .btn-primary { flex: 1; }
.studio-wrap .studio-spacer { width: 58vw; }
.studio-screen .studio-copy::-webkit-scrollbar { width: 5px; }
.studio-screen .studio-copy::-webkit-scrollbar-thumb { background: rgba(127,244,255,0.2); border-radius: 6px; }

/* ---------- hud ---------- */
.hud { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
.hud > * { pointer-events: none; }
.hud button, .hud .interact-prompt, .hud .joystick, .hud .action-cluster { pointer-events: auto; }
.hud-top-left {
  position: absolute; top: max(20px, env(safe-area-inset-top)); left: 22px;
  display: flex; align-items: flex-start; gap: 13px;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.5));
}
.portrait-wrap { position: relative; width: 62px; height: 62px; flex: none; }
.portrait {
  position: absolute; inset: 4px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 34% 28%, var(--hair, #f4d9ad), var(--hair, #f4d9ad) 34%, var(--outfit, #4a6fd4) 76%);
  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: inset 0 -10px 20px rgba(0,0,0,0.35), 0 0 24px rgba(127, 244, 255, 0.18);
  overflow: hidden;
}
.portrait::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(140deg, rgba(255,255,255,0.35), transparent 45%);
}
.portrait span {
  font-family: var(--display); font-size: 24px; color: #10162a; font-weight: 700;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3); z-index: 1;
}
.portrait-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 10%, rgba(255,209,92,0.9) 12%, transparent 16% 35%, rgba(127,244,255,0.9) 38%, transparent 42% 68%, rgba(178,140,255,0.8) 72%, transparent 76%);
  -webkit-mask: radial-gradient(circle, transparent 59%, #000 61%, #000 70%, transparent 72%);
  mask: radial-gradient(circle, transparent 59%, #000 61%, #000 70%, transparent 72%);
  animation: spin 18s linear infinite;
  filter: drop-shadow(0 0 6px rgba(127,244,255,0.4));
}
.vitals { width: clamp(160px, 19vw, 250px); padding-top: 3px; }
.vitals-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 7px; }
.hud-name { font-family: var(--display); font-size: 17px; letter-spacing: 0.04em; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.hud-role { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-soft); opacity: 0.66; }
.bar {
  position: relative; height: 11px; margin-bottom: 5px;
  background: rgba(7, 12, 26, 0.68);
  border: 1px solid rgba(172, 204, 255, 0.18);
  border-radius: 3px; overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.45);
}
.bar i {
  display: block; height: 100%; width: 100%;
  transform-origin: left center; transition: transform 0.22s ease;
  box-shadow: 0 0 14px rgba(255,255,255,0.15);
}
.bar i::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.32), transparent 52%, rgba(0,0,0,0.18));
}
.bar span {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-size: 7.5px; font-weight: 600; letter-spacing: 0.1em; color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.bar-hp i { background: linear-gradient(90deg, #ff5f8f, #ff9a9e 55%, #ffd1a8); }
.bar-mp { height: 8px; }
.bar-mp i { background: linear-gradient(90deg, #2f8fff, #7ff4ff 70%, #d8ffff); }
.bar-st { height: 5px; }
.bar-st i { background: linear-gradient(90deg, #cfa03a, #ffe6a0); }
.hud-top-right {
  position: absolute; top: max(18px, env(safe-area-inset-top)); right: 22px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.5));
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(172, 204, 255, 0.2);
  background: rgba(9, 16, 34, 0.55); backdrop-filter: blur(10px);
  display: grid; place-items: center; color: #dfe9ff;
  transition: border-color 0.2s, background 0.2s;
  pointer-events: auto;
}
.icon-btn svg { width: 15px; height: 15px; fill: currentColor; }
.icon-btn:hover { border-color: rgba(127, 244, 255, 0.5); background: rgba(20, 34, 62, 0.7); }
.resource-chips { display: flex; gap: 8px; }
.chip, .phase-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px 0 11px; border-radius: 19px;
  background: rgba(9, 16, 34, 0.55); border: 1px solid rgba(172, 204, 255, 0.16);
  backdrop-filter: blur(10px);
}
.chip svg { width: 18px; height: 18px; }
.chip .ico-bloom { fill: #ff9bd4; filter: drop-shadow(0 0 5px rgba(255, 155, 212, 0.6)); }
.chip .ico-bloom circle { fill: #fff4c9; }
.chip .ico-aether { fill: #7ff4ff; filter: drop-shadow(0 0 5px rgba(127, 244, 255, 0.55)); }
.chip .ico-aether .inner { fill: #0d1b30; opacity: 0.55; }
.chip .ico-shard { fill: #c9a6ff; filter: drop-shadow(0 0 5px rgba(201, 166, 255, 0.55)); }
.chip .ico-shard .inner { fill: #0d1b30; opacity: 0.55; }
.chip b { font-size: 13px; font-weight: 600; color: #f2f7ff; }
.chip span { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: #8395b6; }
.phase-chip { gap: 8px; padding: 0 12px; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #aebdda; }
.phase-icon {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fff9d8, #ffd15c 55%, #e8952e);
  box-shadow: 0 0 8px rgba(255, 209, 92, 0.65);
  transition: background 0.6s, box-shadow 0.6s;
}
.phase-icon.night { background: radial-gradient(circle at 35% 35%, #eef5ff, #a9c3ff 50%, #5a72bd); box-shadow: 0 0 9px rgba(169, 195, 255, 0.6); }
.phase-icon.dusk { background: radial-gradient(circle at 38% 35%, #ffe0c8, #ff9d78 55%, #d45c71); box-shadow: 0 0 9px rgba(255, 157, 120, 0.6); }

.objective {
  position: absolute; left: 24px; top: 104px;
  width: 258px; padding: 13px 15px 13px 17px;
  background: linear-gradient(100deg, rgba(11, 18, 38, 0.72), rgba(11, 18, 38, 0.34));
  border-left: 1px solid rgba(255, 209, 92, 0.55);
  backdrop-filter: blur(9px);
  border-radius: 0 9px 9px 0;
  box-shadow: 0 10px 40px rgba(0,0,0,0.22);
}
.objective-top { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; font-size: 8.5px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold-soft); opacity: 0.75; }
.objective-top i { width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold); box-shadow: 0 0 8px rgba(255,209,92,0.7); animation: pulse 2.4s ease-in-out infinite; }
.objective h3 { margin: 0 0 4px; font-family: var(--display); font-size: 14.5px; letter-spacing: 0.03em; font-weight: 500; color: #f2f7ff; }
.objective p { margin: 0 0 9px; font-size: 10.5px; line-height: 1.5; color: #97a9c9; font-weight: 300; }
.objective-progress { display: flex; align-items: center; gap: 9px; }
.objective-progress b { font-size: 9px; font-weight: 600; letter-spacing: 0.1em; color: var(--gold-soft); }
.objective-bar { flex: 1; height: 3px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.objective-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--cyan)); transition: width 0.5s ease; box-shadow: 0 0 8px rgba(127,244,255,0.4); }

.reticle {
  position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px;
  border-radius: 50%; background: rgba(255,255,255,0.55);
  box-shadow: 0 0 7px rgba(255,255,255,0.4);
  opacity: 0.28;
}
.reticle span { position: absolute; inset: -5px; border: 1px solid rgba(255,255,255,0.18); border-radius: 50%; }

.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 30px max(24px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; justify-content: space-between; }
.joystick {
  position: relative; width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(30, 50, 90, 0.3), rgba(6, 11, 26, 0.4));
  border: 1px solid rgba(172, 204, 255, 0.16);
  backdrop-filter: blur(8px);
  display: none;
  touch-action: none;
}
.joy-ring { position: absolute; inset: 17px; border-radius: 50%; border: 1px dashed rgba(172,204,255,0.14); }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(255,255,255,0.35), rgba(80, 130, 200, 0.18) 55%, rgba(10,18,38,0.5));
  border: 1px solid rgba(172, 224, 255, 0.4);
  box-shadow: 0 4px 18px rgba(0,0,0,0.4), inset 0 1px 3px rgba(255,255,255,0.25), 0 0 22px rgba(127,244,255,0.08);
  transition: transform 0.06s linear;
}
.joy-knob span { position: absolute; inset: 16px; border-radius: 50%; border: 1px solid rgba(127,244,255,0.35); }
.joy-arrows { position: absolute; inset: 0; display: grid; place-items: center; font-size: 8px; color: rgba(172,204,255,0.3); letter-spacing: 0.6em; }

.action-cluster {
  position: relative; width: 208px; height: 196px; display: none;
}
.action-btn {
  position: absolute; width: 62px; height: 62px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(circle at 38% 28%, rgba(61, 91, 148, 0.55), rgba(8, 15, 34, 0.72));
  border: 1px solid rgba(172, 204, 255, 0.28);
  box-shadow: 0 8px 24px rgba(0,0,0,0.36), inset 0 1px 0 rgba(255,255,255,0.12);
  backdrop-filter: blur(9px);
  color: #dce9ff; pointer-events: auto;
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
  touch-action: none;
}
.action-btn svg { width: 23px; height: 23px; }
.action-btn span { font-size: 7px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(220,233,255,0.6); }
.action-btn:active, .action-btn.pressed { transform: scale(0.9); }
.btn-attack {
  width: 84px; height: 84px; right: 4px; bottom: 2px;
  background: radial-gradient(circle at 38% 28%, rgba(255, 209, 92, 0.32), rgba(34, 24, 16, 0.75));
  border-color: rgba(255, 209, 92, 0.5);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 34px rgba(255,209,92,0.1), inset 0 1px 0 rgba(255,255,255,0.18);
  color: #ffe9a8;
}
.btn-attack svg { width: 30px; height: 30px; }
.btn-cast { right: 82px; bottom: 74px; border-color: rgba(127, 244, 255, 0.45); color: #9ff7ff; box-shadow: 0 8px 24px rgba(0,0,0,0.36), 0 0 26px rgba(127,244,255,0.08), inset 0 1px 0 rgba(255,255,255,0.12); }
.btn-jump { right: 6px; bottom: 96px; }
.btn-dodge { right: 82px; bottom: 8px; color: #cfd9ef; }

.interact-prompt {
  position: absolute; left: 50%; bottom: 178px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px 9px 10px; border-radius: 30px;
  background: rgba(8, 15, 32, 0.72); border: 1px solid rgba(255, 209, 92, 0.38);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 24px rgba(255,209,92,0.08);
  backdrop-filter: blur(12px);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #eef5ff;
  animation: promptIn 0.3s ease, promptPulse 2.6s ease-in-out infinite;
  pointer-events: auto;
  white-space: nowrap;
}
.interact-prompt kbd { background: rgba(255,209,92,0.16); border-color: rgba(255,209,92,0.4); color: #ffe9a8; }
@keyframes promptIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes promptPulse { 0%,100% { border-color: rgba(255,209,92,0.32); } 50% { border-color: rgba(127,244,255,0.5); } }

.desktop-hints {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(160, 180, 210, 0.55);
  white-space: nowrap;
}
.desktop-hints span { display: inline-flex; align-items: center; gap: 5px; }
.desktop-hints kbd { font-size: 8px; padding: 2px 4px; opacity: 0.8; }
body.touch .desktop-hints { display: none; }
body.touch .joystick, body.touch .action-cluster { display: block; }
body.touch .interact-prompt { bottom: 206px; }

/* ---------- pause ---------- */
.pause-screen {
  z-index: 40; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(12, 20, 44, 0.78), rgba(3, 6, 14, 0.92));
  backdrop-filter: blur(14px);
}
.pause-card {
  width: min(460px, calc(100vw - 40px));
  padding: 36px 36px 28px;
  background: linear-gradient(160deg, rgba(20, 30, 58, 0.85), rgba(8, 13, 28, 0.82));
  border: 1px solid rgba(168, 198, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 40px 120px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  text-align: center;
  animation: panelIn 0.45s ease;
}
.pause-card .eyebrow { margin-bottom: 8px; }
.pause-card .screen-title { margin-bottom: 26px; }
.pause-actions { display: flex; flex-direction: column; gap: 10px; }
.pause-actions .btn { width: 100%; justify-content: center; }
.pause-stats { display: flex; justify-content: space-between; gap: 10px; margin: 28px 0 16px; padding-top: 20px; border-top: 1px solid rgba(168,198,255,0.12); }
.pause-stats div { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.pause-stats b { font-family: var(--display); font-size: 20px; color: var(--gold-soft); font-weight: 500; }
.pause-stats span { font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #8395b6; }
.pause-note { margin: 0; font-size: 9.5px; letter-spacing: 0.08em; color: #7284a4; }

/* ---------- feedback ---------- */
.toast {
  position: absolute; top: 96px; left: 50%; transform: translate(-50%, -8px);
  z-index: 50; padding: 10px 20px; border-radius: 30px;
  background: rgba(9, 16, 34, 0.82); border: 1px solid rgba(127, 244, 255, 0.32);
  box-shadow: 0 10px 36px rgba(0,0,0,0.45), 0 0 26px rgba(127,244,255,0.08);
  backdrop-filter: blur(12px);
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: #e7f3ff;
  opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.35s;
  white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fade { position: absolute; inset: 0; z-index: 55; background: #04060e; opacity: 0; pointer-events: none; transition: opacity 0.55s ease; }
.fade.active { opacity: 1; pointer-events: auto; }
.touch-hint {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 16; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(206, 222, 248, 0.7); padding: 8px 16px; border-radius: 20px;
  background: rgba(8,14,30,0.45); border: 1px solid rgba(172,204,255,0.14);
  backdrop-filter: blur(8px); animation: hintFade 5s ease forwards; pointer-events: none;
}
@keyframes hintFade { 0%,60% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .title-screen { align-items: flex-end; }
  .title-content { width: calc(100% - 44px); margin: 0 auto 12vh; }
  .title-aura { width: 120vw; height: 120vw; right: -35vw; top: 38%; opacity: 0.45; }
  .logo-call { font-size: clamp(44px, 12vw, 80px); }
  .logo-mana { font-size: clamp(54px, 15vw, 98px); }
  .title-sub { max-width: 340px; font-size: 13px; margin-bottom: 22px; }
  .title-meta { display: none; }
  .build-tag { display: none; }
  .studio-screen { background: linear-gradient(180deg, rgba(4,8,18,0.25) 0%, rgba(4,8,18,0.5) 34%, rgba(4,8,18,0.95) 60%); }
  .studio-wrap { align-items: flex-end; padding: 0; }
  .studio-copy {
    width: 100%; max-height: 62vh; border-radius: 20px 20px 0 0;
    padding: 24px 22px calc(20px + env(safe-area-inset-bottom));
    border-left: none; border-right: none; border-bottom: none;
  }
  .studio-copy .screen-title { font-size: clamp(28px, 8vw, 38px); margin-bottom: 10px; }
  .studio-sub { font-size: 12px; margin-bottom: 16px; }
  .studio-spacer { display: none; }
  .studio-wrap .studio-spacer { width: 0; }
  .name-field { margin-bottom: 16px; }
  .palette-root { gap: 10px; margin-bottom: 18px; }
  .swatch { width: 25px; height: 25px; }
  .hud-top-left { left: 12px; top: max(12px, env(safe-area-inset-top)); gap: 9px; }
  .portrait-wrap { width: 50px; height: 50px; }
  .portrait span { font-size: 19px; }
  .vitals { width: 152px; }
  .hud-name { font-size: 14px; }
  .hud-role { display: none; }
  .hud-top-right { right: 12px; top: max(12px, env(safe-area-inset-top)); gap: 7px; }
  .icon-btn { width: 34px; height: 34px; }
  .resource-chips { gap: 5px; }
  .chip { height: 32px; padding: 0 9px 0 8px; gap: 5px; }
  .chip svg { width: 15px; height: 15px; }
  .chip span { display: none; }
  .chip b { font-size: 11px; }
  .phase-chip { height: 32px; padding: 0 10px; font-size: 8px; }
  .objective { left: 12px; top: 78px; width: 214px; padding: 10px 12px 10px 13px; }
  .objective h3 { font-size: 12.5px; }
  .objective p { font-size: 9.5px; }
  .hud-bottom { padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
  .joystick { width: 112px; height: 112px; }
  .joy-knob { width: 42px; height: 42px; margin: -21px; }
  .action-cluster { width: 180px; height: 168px; }
  .action-btn { width: 54px; height: 54px; }
  .action-btn svg { width: 20px; height: 20px; }
  .btn-attack { width: 76px; height: 76px; }
  .btn-attack svg { width: 26px; height: 26px; }
  .btn-cast { right: 72px; bottom: 62px; }
  .btn-jump { right: 4px; bottom: 82px; }
  .btn-dodge { right: 72px; bottom: 4px; }
  .interact-prompt { bottom: 152px; font-size: 9px; padding: 8px 15px 8px 8px; }
  body.touch .interact-prompt { bottom: 178px; }
  .toast { top: 76px; font-size: 9px; }
}
@media (max-width: 520px) {
  .hud-top-right { flex-direction: column-reverse; align-items: flex-end; }
  .phase-chip { display: none; }
  .objective { width: 190px; top: 72px; }
  .objective p { display: none; }
  .title-actions { flex-direction: column; align-items: stretch; }
  .title-actions .btn { width: 100%; }
  .pause-stats b { font-size: 17px; }
}
@media (hover: hover) and (pointer: fine) {
  .joystick, .action-cluster { display: none; }
}
@media (hover: none), (pointer: coarse) {
  body.touch .joystick, body.touch .action-cluster { display: block; }
}
