:root {
  color-scheme: dark;
  font-family: system-ui, "Microsoft JhengHei", sans-serif;
  color: #fbf5ff;
  background: #080713;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 45%, #23123b, #080713 65%);
}
.game {
  position: relative;
  isolation: isolate;
  width: min(100vw, 56.25dvh, 560px);
  height: 100dvh;
  overflow: hidden;
  border-inline: 1px solid #c691ff38;
  background: #0d0920 center / cover no-repeat url("assets/Backgrounds/BG01_Temple.jpg");
  box-shadow: 0 0 90px #8d39ff2b;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 44px;
  align-items: center;
  gap: 14px;
  padding: max(14px, env(safe-area-inset-top)) 14px 22px;
  background: linear-gradient(#090717ed, #090717aa 65%, transparent);
  pointer-events: none;
}
.hud strong { font-size: .9rem; }
.health span { display: flex; justify-content: space-between; gap: 5px; font-size: .875rem; }
progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 7px;
  border: 0;
  border-radius: 5px;
  overflow: hidden;
  background: #ffffff26;
  color: var(--meter);
}
progress::-webkit-progress-bar { background: #ffffff26; }
progress::-webkit-progress-value { background: var(--meter); }
progress::-moz-progress-bar { background: var(--meter); }
.route { --meter: #ce9aff; }
.health { --meter: #8df9e5; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid white; outline-offset: 4px; }
.pause {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #b494d174;
  border-radius: 10px;
  background: #120d29;
  pointer-events: auto;
}
.pause span { width: 12px; height: 14px; border-inline: 3px solid #f6e8ff; }
.score {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 53px);
  right: 14px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #0c0921dd;
  color: #ead6ff;
  font-size: .875rem;
  pointer-events: none;
}
.score strong, #hp { font-variant-numeric: tabular-nums; }
.evolution {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 53px);
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #0c0921dd;
  font-size: .875rem;
  pointer-events: none;
}
.energy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #a9f7ff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.energy img { object-fit: contain; }
.boss-hud {
  position: absolute;
  inset: calc(max(14px, env(safe-area-inset-top)) + 91px) 14px auto;
  color: #faf1ff;
  background: #0e0a22e6;
  border: 1px solid #aaa0e266;
  border-radius: 8px;
  padding: 6px 9px 8px;
  pointer-events: none;
}
.boss-status { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.boss-status strong { font-size: .875rem; }
.boss-status span { font-size: .8125rem; color: var(--meter); white-space: nowrap; }
.boss-hud progress { margin-top: 4px; }
.boss-warning {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  translate: -50%;
  padding: 4px 9px;
  border: 1px solid #ff95c88c;
  border-radius: 5px;
  background: #2b1033ed;
  color: #ffe2ee;
  font-size: .875rem;
  font-weight: 800;
  white-space: nowrap;
}
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 30px 18px max(42px, calc(env(safe-area-inset-bottom) + 26px));
  background: linear-gradient(180deg, #09071710 15%, #0907171a 32%, #0c081ceb 72%, #090717 100%);
}
.brand {
  margin: 0 0 12px;
  color: #e7beff;
  font-size: .875rem;
  font-weight: 750;
  letter-spacing: .23em;
}
.brand span { display: block; margin-top: 7px; letter-spacing: .35em; }
h1 {
  margin: 0;
  font-size: clamp(2.35rem, 11vw, 4.2rem);
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: .08em;
  text-shadow: 0 0 32px #ad69fc99;
}
#detail { margin: 17px 0 24px; color: #eee0fc; line-height: 1.55; }
.primary {
  min-height: 52px;
  min-width: min(100%, 245px);
  padding: 10px 28px;
  border: 1px solid #f6d6ff;
  border-radius: 10px;
  background: linear-gradient(150deg, #f1d5ff, #c399ff);
  color: #200c36;
  font-weight: 800;
  box-shadow: 0 5px 29px #762ec56b;
}
.primary:not(.crystal-button):hover { background: #f3ddff; }
.primary:disabled { opacity: .72; cursor: wait; }
.controls { margin: 15px 0 0; color: #d0badf; font-size: .875rem; }
.controls span { margin-inline: 6px; }
.crystal-button {
  border: 0;
  min-height: 54px;
  color: #fff8ed;
  background: url("assets/Interface/purple_button.png") center / 100% 100% no-repeat;
  box-shadow: none;
  text-shadow: 0 1px 4px #080419;
}
.crystal-button.crystal-blue { background-image: url("assets/Interface/blue_button.png"); }
.crystal-button:hover { background-color: transparent; filter: brightness(1.2); }
.secondary {
  min-height: 40px;
  padding: 4px 12px;
  border: 1px solid #75648a;
  border-radius: 7px;
  background: #201632ef;
  color: #f5eaff;
}
#change { margin-top: 10px; }
.sound {
  position: absolute;
  z-index: 4;
  right: 12px;
  top: max(12px, env(safe-area-inset-top));
  font-size: .875rem;
}
#hud:not([hidden]) ~ .sound { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
.game.is-hangar { width: min(100%, 910px); }
.is-hangar #field { visibility: hidden; }
.hangar {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: max(17px, env(safe-area-inset-top)) clamp(14px, 4vw, 38px) 0;
  background: linear-gradient(#100b20dc, #0d0919 78%), url("assets/Backgrounds/BG01_Temple.jpg") center 38% / cover;
}
.hangar-brand {
  margin: 0 0 4px;
  padding-right: 83px;
  color: #ead1a1;
  font-size: .875rem;
  font-weight: 750;
  letter-spacing: .12em;
}
.hangar h2 { margin: 0 0 13px; font-size: clamp(1.55rem, 5vw, 2.2rem); }
.fighter-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(2px, 1.3vw, 13px);
}
.fighter-card {
  position: relative;
  display: grid;
  justify-items: center;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 74px;
  aspect-ratio: .81;
  padding: 9% 7% 13%;
  border: 0;
  border-radius: 9px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--fighter-color) 19%, #181029), #0b0816 76%);
  color: #f4eafe;
  font-weight: 750;
  isolation: isolate;
}
.fighter-card::after {
  position: absolute;
  inset: 0;
  content: "";
  background: url("assets/Interface/card-front-frame.png") center / 100% 100% no-repeat;
  opacity: .65;
  pointer-events: none;
}
.fighter-card[aria-pressed="true"] {
  color: #fff5ce;
  outline: 1px solid var(--fighter-color);
  box-shadow: 0 0 14px color-mix(in srgb, var(--fighter-color) 38%, transparent);
}
.fighter-card[aria-pressed="true"]::after, .fighter-card:hover::after { opacity: 1; }
.fighter-card span {
  position: relative;
  z-index: 1;
  font-size: clamp(.75rem, 2vw, 1rem);
  line-height: 1.1;
  text-shadow: 0 1px 3px #080518, 0 0 5px #080518;
}
.fighter-card img {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--fighter-color) 42%, transparent));
}
.fighter-info { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; margin: 14px 0 10px; }
.fighter-info h3 { margin: 0; font-size: clamp(1.35rem, 4.8vw, 1.9rem); }
.fighter-info span { color: var(--active-fighter); font-weight: 700; font-size: .875rem; }
.fighter-info p { flex-basis: 100%; margin: 0; color: #e2d5ef; line-height: 1.5; font-size: .9375rem; }
.tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 9px;
}
.tiers button {
  min-height: 40px;
  border: 1px solid #66567b;
  border-radius: 7px;
  background: #171124;
  color: #eee2fb;
  font-size: .875rem;
}
.tiers button[aria-pressed="true"] {
  border-color: var(--active-fighter);
  background: color-mix(in srgb, var(--active-fighter) 21%, #1e152b);
  font-weight: 750;
}
.hangar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hangar-tile {
  display: flex;
  min-width: 0;
  flex-direction: column;
  margin: 0;
  padding: 10px 8px 8px;
  border: 1px solid #5e4b76;
  border-radius: 10px;
  background: #130e22;
}
.hangar-tile h4 { margin: 0 0 3px; font-size: .9375rem; }
.hangar-tile canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1.30;
  max-height: 255px;
  object-fit: contain;
  border-radius: 5px;
  touch-action: pan-y;
}
.hangar-tile p {
  min-height: 2.6em;
  margin: auto 0 0;
  padding-top: 5px;
  color: #e3d4f0;
  font-size: .875rem;
  line-height: 1.34;
}
.radar-legend { display: flex; flex-wrap: wrap; gap: 2px 8px; align-content: start; }
.radar-legend span:first-child { color: var(--active-fighter); }
.hangar-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #0e0a1c 21%);
}
.hangar-actions .primary { min-width: min(100%, 218px); }
@media (max-width: 600px) and (orientation: portrait) { .game { width: 100%; border-inline: 0; } }
@media (max-width: 600px) {
  .hangar-grid { grid-template-columns: 1fr; }
  .hangar-tile canvas { height: clamp(115px, 19dvh, 174px); }
  .hangar-tile p { min-height: auto; }
  .radar-legend { justify-content: center; }
}
@media (max-height: 540px) { .panel { padding-bottom: 20px; } }
@media (min-width: 700px) {
  .fighter-card { aspect-ratio: 1.13; }
  .fighter-info { margin-top: 12px; }
  .hangar-tile { padding-inline: 14px; }
}
