:root {
  --bg: #02091a;
  --blue-1: #061a5d;
  --blue-2: #0b43b8;
  --blue-3: #4aa6ff;
  --ink: #f8fbff;
  --muted: #b9d8ff;
  --line: #eff8ff;
  --gold: #ffd86a;
  --green: #65ff9b;
  --red: #ff6370;
  --orange: #ffbd5f;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 12% 6%, rgba(79, 174, 255, .38), transparent 28%),
    radial-gradient(circle at 92% 4%, rgba(255, 216, 106, .18), transparent 26%),
    linear-gradient(135deg, #02091a 0%, #061647 52%, #082568 100%);
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.side-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(2, 16, 60, .98), rgba(2, 9, 30, .96));
  border-right: 3px solid rgba(244, 251, 255, .92);
  box-shadow: inset -8px 0 0 rgba(255, 255, 255, .05), 14px 0 32px rgba(0, 0, 0, .28);
}

.brand-card,
.party-panel,
.hero,
.tool-card,
.quest-card {
  border: 3px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 87, 215, .9), rgba(5, 28, 98, .96));
  box-shadow: inset 0 0 0 3px rgba(0, 23, 98, .55), 0 8px 0 rgba(0, 7, 35, .35);
}

.brand-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.brand-card span,
.hero span,
.party-panel header span,
.quest-card span {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 900;
  font-size: 12px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 25px; line-height: .96; text-shadow: 2px 2px 0 #001044; }
h2 { font-size: clamp(34px, 5vw, 64px); line-height: .9; text-shadow: 3px 3px 0 #001044; }
p { color: var(--muted); line-height: 1.35; }

.crystal {
  width: 74px;
  height: 74px;
  background: linear-gradient(135deg, #fff, #8ff4ff 24%, #166dff 25% 58%, #061a5d 59%);
  clip-path: polygon(50% 0, 93% 25%, 78% 88%, 50% 100%, 22% 88%, 7% 25%);
  box-shadow: 4px 5px 0 rgba(0, 8, 58, .8), 0 0 18px rgba(143, 244, 255, .55);
}

.party-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
}

.party-panel header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.party-panel header b { color: var(--green); font-size: 12px; }

.party-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}

.party-card {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 92px;
  padding: 8px;
  border-bottom: 2px solid rgba(244, 251, 255, .35);
}

.party-card.ready { background: linear-gradient(90deg, rgba(255, 216, 106, .12), transparent 72%); }
.party-card.manual { background: linear-gradient(90deg, rgba(255, 189, 95, .16), transparent 72%); }
.party-card.offline { opacity: .72; }

.battle-aura {
  animation: battleAura 2.5s ease-in-out infinite;
  background: linear-gradient(90deg, rgba(101, 255, 155, .2), rgba(19, 78, 88, .1) 70%, transparent);
}

@keyframes battleAura {
  0%, 100% { box-shadow: 0 0 0 1px rgba(157, 255, 186, .26), 0 0 12px rgba(101, 255, 155, .18); }
  50% { box-shadow: 0 0 0 2px rgba(157, 255, 186, .46), 0 0 26px rgba(101, 255, 155, .38); }
}

.battle-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, #f3fff7 0 24%, #70ff9b 25% 54%, #0e4e2f 55% 100%);
  border: 1px solid #f4fbff;
  box-shadow: 0 0 12px rgba(101, 255, 155, .6);
  animation: badgeFlash 1.7s ease-in-out infinite;
}

.battle-badge:before,
.battle-badge:after {
  content: "";
  position: absolute;
  left: 10px;
  top: 4px;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, #fff, #ffd86a 45%, #725118 46% 100%);
  box-shadow: 0 0 0 1px rgba(0, 13, 55, .25);
}

.battle-badge:before { transform: rotate(42deg); }
.battle-badge:after { transform: rotate(-42deg); }

@keyframes badgeFlash {
  0%, 100% { opacity: .9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

.sprite {
  position: relative;
  width: 74px;
  height: 74px;
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(0, 10, 62, .68));
}

.sprite-image {
  display: block;
  background: transparent;
  justify-self: center;
  align-self: center;
}

.sprite:before { content: ""; position: absolute; left: 17px; top: 9px; width: 34px; height: 16px; background: var(--cloak); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sprite i { position: absolute; left: 21px; top: 22px; width: 26px; height: 20px; background: var(--skin); box-shadow: inset 0 -4px 0 rgba(0,0,0,.08); }
.sprite b { position: absolute; left: 16px; top: 43px; width: 36px; height: 20px; background: var(--cloak); clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); }
.sprite span { position: absolute; left: 27px; top: 29px; width: 4px; height: 4px; background: #101044; box-shadow: 12px 0 0 #101044, 5px 8px 0 #7c372d; }
.sprite-active { filter: drop-shadow(3px 3px 0 rgba(0, 10, 62, .68)) drop-shadow(0 0 10px rgba(101, 255, 155, .5)); }

.party-copy { min-width: 0; padding-right: 26px; }
.party-line { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.party-line strong { font-size: 15px; }
.party-line span { color: var(--gold); font-size: 11px; white-space: nowrap; }
.party-copy p { font-size: 12px; margin: 3px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.context-meter { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; gap: 6px; align-items: center; margin-top: 6px; }
.context-meter strong, .context-meter em, .context-meter small { font-style: normal; color: #fff; font-size: 10px; }
.context-meter i { display: block; height: 9px; border: 1px solid #fff; background: #041a57; }
.context-meter i span { display: block; height: 100%; background: linear-gradient(90deg, #39df73, #e9ff7a); box-shadow: 0 0 8px rgba(125, 255, 155, .45); }
.context-meter small { grid-column: 2 / -1; color: var(--muted); line-height: 1; }
.context-meter.warn i span { background: linear-gradient(90deg, #ffbd5f, #ffe36f); }
.context-meter.warn small { color: var(--orange); }
.context-meter.danger i span { background: linear-gradient(90deg, #ff6370, #ffbd5f); }
.context-meter.danger small { color: var(--red); }

.main-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; padding: 14px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 18px; }
.hero p { margin-top: 7px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(86px, 1fr)); gap: 10px; }
.hero-stats article { border: 2px solid rgba(255,255,255,.85); background: #041a57; padding: 10px; text-align: center; }
.hero-stats b { display: block; font-size: 25px; color: var(--gold); }
.hero-stats small { color: var(--muted); }

.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-content: start; }
.tool-card { min-height: 158px; color: #fff; text-decoration: none; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 14px; transition: transform .16s ease, filter .16s ease; }
.tool-card:hover { transform: translateY(-3px); filter: brightness(1.08); }
.tool-card strong { display: block; font-size: 20px; line-height: 1; text-shadow: 2px 2px 0 #001044; }
.tool-card small { color: var(--gold); text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
.tool-card p { margin-top: 8px; font-size: 13px; }
.tool-card em { justify-self: start; font-style: normal; border: 2px solid #fff; padding: 4px 8px; font-weight: 900; font-size: 11px; background: #041a57; }
.tool-card.active em { color: var(--green); }
.tool-card.manual em { color: var(--orange); }
.tool-card.offline em { color: var(--red); }
.tool-gem { width: 38px; height: 38px; background: linear-gradient(135deg, #fff, #8ff4ff 28%, #166dff 29% 70%, #061a5d 71%); clip-path: polygon(50% 0, 100% 32%, 78% 100%, 22% 100%, 0 32%); box-shadow: 3px 3px 0 rgba(0, 8, 58, .75); }

.quest-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.quest-card { padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.quest-card span { grid-column: 1 / -1; }
.quest-card strong { font-size: 18px; }
.quest-card i { display: block; height: 12px; border: 2px solid #fff; background: #041a57; }
.quest-card i b { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-3), var(--gold)); }
.quest-card em { font-style: normal; color: var(--gold); font-weight: 900; }

@media (max-width: 980px) {
  .dashboard { grid-template-columns: 1fr; }
  .side-panel { border-right: 0; border-bottom: 3px solid rgba(244, 251, 255, .92); }
  .hero { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .brand-card, .party-card { grid-template-columns: 64px minmax(0, 1fr); }
  .crystal { width: 58px; height: 58px; }
  .sprite { width: 64px; height: 64px; transform: scale(.86); transform-origin: center center; }
  .tool-grid, .quest-grid, .hero-stats { grid-template-columns: 1fr; }
  .main-panel, .side-panel { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation: none !important; transition: none !important; }
}
