*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  color: #f4f7fb;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(32, 120, 150, 0.28), transparent 55%),
    radial-gradient(700px 380px at 100% 110%, rgba(160, 40, 70, 0.2), transparent 46%),
    #07090f;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #07090f;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

#view {
  width: 100%;
  height: 100%;
  display: block;
}

#menu,
#result {
  position: absolute;
  inset: 0;
}

#menu {
  z-index: 3;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 18px 14px;
  background: rgba(7, 9, 15, 0.9);
}

#menu[hidden],
#result[hidden],
#ougi[hidden] {
  display: none;
}

.hero {
  text-align: center;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.22em;
  font-size: 12px;
  color: #9eb0c4;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 4.6vw, 58px);
  line-height: 1;
  letter-spacing: 0.12em;
  text-shadow: 4px 4px 0 #0b8eab, -2px 0 0 #e23b73;
}

.tag,
#status,
.legend,
.hint {
  margin: 8px 0 0;
  color: #c5d0de;
  font-size: 13px;
  line-height: 1.5;
}

#status {
  color: #f4f7fb;
  font-weight: 700;
}

#match-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-bar,
.diff-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mode-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #93a0b3;
  margin-right: 4px;
}

.mode-btn,
.diff-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(18, 24, 38, 0.9);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
}

.mode-btn.on {
  background: #f4f7fb;
  color: #10151f;
  border-color: #f4f7fb;
}

.diff-btn.on {
  background: #ffe08a;
  color: #2a2008;
  border-color: #ffe08a;
}

.cpu-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: #d5deea;
}

#decks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.deck {
  min-width: 0;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px;
  backdrop-filter: blur(8px);
}

.deck-0 {
  box-shadow: inset 0 3px 0 #3ecbff;
}

.deck-1 {
  box-shadow: inset 0 3px 0 #ff4f8b;
}

.deck header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

.who {
  font-weight: 800;
  letter-spacing: 0.08em;
}

.deck-0 .who {
  color: #8be7ff;
}

.deck-1 .who {
  color: #ff9bb8;
}

.keys {
  color: #93a0b3;
  font-size: 12px;
}

.deck-label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #93a0b3;
}

.deck-label + .cards {
  margin-bottom: 10px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.card {
  min-width: 0;
  padding: 0 0 8px;
  border: 0;
  border-radius: 12px;
  background: #121826;
  text-align: center;
}

.card.on {
  transform: translateY(-3px);
}

.deck-0 .card.on {
  box-shadow: 0 0 0 2px #3ecbff, 0 10px 24px rgba(62, 203, 255, 0.22);
}

.deck-1 .card.on {
  box-shadow: 0 0 0 2px #ff4f8b, 0 10px 24px rgba(255, 79, 139, 0.22);
}

.thumb {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}

.nm,
.tr {
  display: block;
}

.nm {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
}

.abilities {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.ability {
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 8px 6px;
  background: #121826;
  text-align: center;
}

.ability.on {
  transform: translateY(-2px);
}

.deck-0 .ability.on {
  box-shadow: 0 0 0 2px #3ecbff, 0 8px 18px rgba(62, 203, 255, 0.18);
}

.deck-1 .ability.on {
  box-shadow: 0 0 0 2px #ff4f8b, 0 8px 18px rgba(255, 79, 139, 0.18);
}

.abi-nm,
.abi-tr {
  display: block;
}

.abi-nm {
  font-size: 13px;
  font-weight: 800;
}

.abi-tr {
  margin-top: 2px;
  color: #93a0b3;
  font-size: 10px;
  line-height: 1.3;
}

.ready {
  width: 100%;
  margin-top: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  padding: 8px 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.deck-0 .ready.on {
  background: #3ecbff;
  color: #062028;
  border-color: #3ecbff;
}

.deck-1 .ready.on {
  background: #ff4f8b;
  color: #2a0612;
  border-color: #ff4f8b;
}

.vs {
  align-self: center;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #f4f7fb;
}

.mech {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mech article {
  background: rgba(8, 12, 20, 0.78);
  border-radius: 12px;
  padding: 10px 12px;
}

.mech strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.mech p {
  margin: 0;
  color: #b7c3d4;
  font-size: 12px;
  line-height: 1.45;
}

.legend {
  text-align: center;
}

#result {
  z-index: 4;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(70% 80% at 38% 48%, rgba(0, 0, 0, 0.15), rgba(5, 7, 12, 0.82));
}

.victory {
  position: relative;
  width: min(1080px, calc(100% - 36px));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.9fr);
  gap: 28px;
  align-items: center;
}

.victory-rays {
  pointer-events: none;
  position: absolute;
  inset: -18%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.07) 0 8deg,
    transparent 8deg 18deg
  );
  opacity: 0.35;
  animation: victory-spin 18s linear infinite;
}

.victory-art {
  position: relative;
  width: min(100%, 460px);
  justify-self: center;
  aspect-ratio: 1;
  border-radius: 28px;
  overflow: hidden;
  transform: rotate(-6deg) scale(1.04);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.victory-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center 18%;
  filter:
    contrast(1.28)
    saturate(1.45)
    brightness(1.06)
    drop-shadow(10px 0 0 rgba(255, 48, 110, 0.38))
    drop-shadow(-10px 0 0 rgba(48, 210, 255, 0.32));
}

.victory-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, 0.28) 48%, transparent 56%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%, rgba(0, 0, 0, 0.28));
  mix-blend-mode: screen;
  pointer-events: none;
}

.victory.p1 .victory-art {
  box-shadow: 0 0 0 4px #3ecbff, 0 24px 60px rgba(62, 203, 255, 0.28);
}

.victory.p2 .victory-art {
  box-shadow: 0 0 0 4px #ff4f8b, 0 24px 60px rgba(255, 79, 139, 0.28);
}

.victory.p1 .victory-art img {
  filter:
    contrast(1.28)
    saturate(1.4)
    brightness(1.08)
    hue-rotate(-8deg)
    drop-shadow(12px 0 0 rgba(255, 70, 120, 0.4))
    drop-shadow(-12px 0 0 rgba(62, 203, 255, 0.55));
}

.victory.p2 .victory-art img {
  filter:
    contrast(1.28)
    saturate(1.45)
    brightness(1.08)
    hue-rotate(8deg)
    drop-shadow(12px 0 0 rgba(255, 79, 139, 0.55))
    drop-shadow(-12px 0 0 rgba(80, 180, 255, 0.35));
}

.victory-art.play {
  animation: victory-slam 0.9s cubic-bezier(0.12, 1.4, 0.2, 1) both;
}

.victory-art.play::after {
  animation: victory-flash 0.7s ease-out both;
}

.victory-stamp {
  position: absolute;
  right: -6%;
  bottom: 8%;
  padding: 6px 14px;
  border: 4px solid #ff3b3b;
  color: #ff3b3b;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: 0.18em;
  transform: rotate(-12deg);
  background: rgba(20, 4, 6, 0.22);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  animation: victory-stamp 0.45s 0.18s cubic-bezier(0.2, 1.6, 0.3, 1) both;
}

.victory-copy {
  position: relative;
  z-index: 1;
  text-align: left;
}

.victory-copy .eyebrow {
  color: #ffe08a;
}

#result-title {
  margin: 0;
  font-size: clamp(36px, 5vw, 64px);
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#result-score {
  margin: 10px 0 0;
  font-size: 28px;
  letter-spacing: 0.16em;
}

.result-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 22px;
}

@keyframes victory-slam {
  0% {
    transform: rotate(-10deg) scale(1.55) translate(48px, -24px);
    filter: blur(8px) brightness(1.8);
  }
  14% {
    transform: rotate(-7deg) scale(1.12) translate(-14px, 10px);
    filter: blur(0) brightness(1.15);
  }
  22% { transform: rotate(-4deg) scale(1.08) translate(10px, -8px); }
  30% { transform: rotate(-7deg) scale(1.06) translate(-8px, 6px); }
  38% { transform: rotate(-5deg) scale(1.05) translate(6px, -4px); }
  48% { transform: rotate(-6deg) scale(1.04) translate(-3px, 2px); }
  100% { transform: rotate(-6deg) scale(1.04) translate(0, 0); }
}

@keyframes victory-flash {
  0% { opacity: 1; background: #fff; mix-blend-mode: overlay; }
  40% { opacity: 0.55; }
  100% { opacity: 1; }
}

@keyframes victory-stamp {
  0% { transform: rotate(-12deg) scale(1.8); opacity: 0; }
  100% { transform: rotate(-12deg) scale(1); opacity: 1; }
}

@keyframes victory-spin {
  to { transform: rotate(1turn); }
}

@media (max-width: 900px) {
  .victory {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .victory-copy,
  .result-actions {
    text-align: center;
    justify-content: center;
  }
}

.hint {
  margin: 10px 0 0;
}

.primary,
.ghost {
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 800;
}

.primary {
  background: #f4f7fb;
  color: #141820;
  border: 0;
}

.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

#ougi {
  position: absolute;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  background: #05060a;
  container-type: inline-size;
}

.ougi-stage {
  --zoom: 1.9;
  --focus: 50% 34%;
  --ougi-time: 2.9s;
  --grade: grayscale(0.9) contrast(1.7) brightness(0.92);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #05060a;
}

.ougi-photo-wrap {
  position: absolute;
  inset: -7%;
}

.ougi-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus);
  transform-origin: var(--focus);
  filter: var(--grade);
  will-change: transform, filter;
}

.tone-dark {
  --grade: grayscale(0.92) contrast(1.58) brightness(1.04) sepia(0.14);
}

.tone-harsh {
  --grade: grayscale(0.2) contrast(1.62) brightness(1.1) saturate(0.55);
}

.tone-abyss {
  --grade: grayscale(0.72) contrast(1.68) brightness(1.02) sepia(0.34);
}

.tone-storm {
  --grade: contrast(1.42) saturate(1.18) brightness(1.03);
}

.ougi-grade,
.ougi-grain,
.ougi-scan,
.ougi-speed,
.ougi-slash,
.ougi-vignette,
.ougi-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tone-dark .ougi-grade {
  background:
    linear-gradient(90deg, transparent 58%, rgba(0, 0, 0, 0.55)),
    linear-gradient(180deg, rgba(8, 8, 10, 0.16), transparent 30%, rgba(0, 0, 0, 0.34)),
    radial-gradient(ellipse at 36% 48%, transparent 48%, rgba(0, 0, 0, 0.34) 100%);
  mix-blend-mode: multiply;
}

.tone-harsh .ougi-grade {
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.55), rgba(0, 0, 0, 0.15) 58%);
  mix-blend-mode: soft-light;
}

.tone-abyss .ougi-grade {
  background:
    radial-gradient(ellipse at 50% 46%, rgba(120, 96, 70, 0.16), rgba(0, 0, 0, 0.34));
  mix-blend-mode: multiply;
}

.tone-storm .ougi-grade {
  background:
    linear-gradient(90deg, rgba(4, 14, 36, 0.62), transparent 16% 84%, rgba(4, 14, 36, 0.55)),
    linear-gradient(180deg, rgba(6, 18, 48, 0.4), transparent 20% 76%, rgba(4, 10, 28, 0.5));
  mix-blend-mode: multiply;
  opacity: 1;
}

.ougi-grain {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  opacity: 0.48;
  mix-blend-mode: overlay;
  animation: grain-move 0.12s steps(2) infinite;
}

.tone-abyss .ougi-grain {
  opacity: 0.7;
}

.tone-dark .ougi-grain {
  opacity: 0.58;
}

.tone-storm .ougi-grain {
  opacity: 0.22;
  mix-blend-mode: soft-light;
}

.ougi-scan {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgba(0, 0, 0, 0.28) 3px 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.16;
}

.ougi-speed {
  opacity: 0;
}

.tone-dark .ougi-speed,
.tone-harsh .ougi-speed,
.tone-abyss .ougi-speed {
  background: repeating-linear-gradient(
    97deg,
    transparent 0 11px,
    rgba(0, 0, 0, 0.55) 11px 13px
  );
}

.tone-storm .ougi-speed {
  background:
    linear-gradient(104deg, transparent 0 3%, #f4fbff 5.4%, rgba(150, 205, 255, 0.35) 7.2%, transparent 10%),
    linear-gradient(104deg, transparent 0 89%, #e7f4ff 92%, transparent 96%),
    linear-gradient(76deg, transparent 0 12%, rgba(186, 224, 255, 0.9) 14.2%, transparent 17.5%);
  mix-blend-mode: screen;
}

.tone-storm .ougi-grain {
  opacity: 0.16;
}

.tone-storm .ougi-scan {
  opacity: 0.05;
}

.ougi-slash {
  top: 46%;
  bottom: auto;
  height: 7%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  mix-blend-mode: screen;
  opacity: 0;
}

.tone-storm .ougi-slash {
  background: linear-gradient(180deg, transparent, rgba(210, 236, 255, 0.9), transparent);
}

.ougi-vignette {
  background: radial-gradient(ellipse at center, transparent 46%, rgba(0, 0, 0, 0.28) 74%, rgba(0, 0, 0, 0.82) 100%);
}

.tone-harsh .ougi-vignette {
  background: radial-gradient(ellipse at 42% 48%, transparent 34%, rgba(0, 0, 0, 0.62) 100%);
}

.tone-storm .ougi-vignette {
  background: radial-gradient(ellipse at center, transparent 32%, rgba(3, 8, 24, 0.78) 100%);
}

.ougi-flash {
  background: #fff;
  opacity: 0;
}

.ougi-sub {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 2;
  width: max-content;
  max-width: 92%;
  transform: translateX(-50%);
  padding: 8px 26px 10px;
  background: rgba(0, 0, 0, 0.62);
  text-align: center;
}

.ougi-zh,
.ougi-jp {
  margin: 0;
  white-space: nowrap;
}

.ougi-zh {
  color: #f6f6f6;
  font-size: clamp(16px, 3.1cqi, 30px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7);
}

.ougi-jp {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(13px, 2.15cqi, 20px);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.tone-storm .ougi-sub {
  background: linear-gradient(180deg, rgba(8, 18, 40, 0.15), rgba(5, 12, 28, 0.78));
}

.tone-storm .ougi-zh {
  color: #e9f4ff;
  letter-spacing: 0.14em;
  -webkit-text-stroke: 0.6px #3c7bff;
  text-shadow:
    0 0 12px rgba(90, 170, 255, 0.9),
    0 2px 0 #071226;
}

.tone-storm .ougi-jp {
  color: #b7dcff;
}

.play .ougi-photo-wrap {
  animation: ougi-jitter var(--ougi-time) linear both;
}

.play .ougi-photo-wrap img {
  animation: ougi-zoom 0.48s cubic-bezier(0.12, 0.85, 0.2, 1) both;
}

.play .ougi-speed {
  animation: speed-out 0.7s ease-out both;
}

.play .tone-storm .ougi-speed {
  animation: storm-hold 1.8s ease-out both;
}

.play .ougi-slash {
  animation: ougi-slash 0.38s ease-out both;
}

.play .ougi-flash {
  animation: ougi-flash 0.32s ease-out both;
}

.ougi-sub {
  opacity: 0;
}

.play .ougi-sub {
  animation: ougi-line 0.28s 0.32s ease-out both;
}

.play .ougi-jp {
  animation: ougi-line 0.24s 0.46s ease-out both;
}

@keyframes ougi-jitter {
  0% { transform: translate3d(0, 0, 0); }
  4% { transform: translate3d(-18px, 11px, 0); }
  8% { transform: translate3d(16px, -13px, 0); }
  12% { transform: translate3d(-14px, -7px, 0); }
  17% { transform: translate3d(12px, 9px, 0); }
  22% { transform: translate3d(-8px, 5px, 0); }
  28% { transform: translate3d(7px, -5px, 0); }
  36% { transform: translate3d(-4px, 3px, 0); }
  46% { transform: translate3d(3px, -2px, 0); }
  58% { transform: translate3d(-3px, 2px, 0); }
  70% { transform: translate3d(2px, -2px, 0); }
  82% { transform: translate3d(-2px, 1px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@keyframes ougi-zoom {
  0% {
    transform: scale(calc(var(--zoom) * 1.42));
    filter: var(--grade) blur(8px) brightness(1.9);
  }
  22% {
    transform: scale(calc(var(--zoom) * 1.04));
    filter: var(--grade) blur(0px) brightness(1.08);
  }
  100% {
    transform: scale(var(--zoom));
    filter: var(--grade);
  }
}

@keyframes speed-out {
  0% { opacity: 0.95; transform: translateX(-3%); }
  100% { opacity: 0; transform: translateX(2%); }
}

@keyframes storm-hold {
  0% { opacity: 0; transform: translateX(-5%); }
  14% { opacity: 0.9; transform: none; }
  100% { opacity: 0.5; transform: translateX(1%); }
}

@keyframes ougi-slash {
  0% { opacity: 0; transform: rotate(-7deg) scaleX(0.35); }
  28% { opacity: 0.85; }
  100% { opacity: 0; transform: rotate(-7deg) scaleX(1); }
}

@keyframes ougi-flash {
  0% { opacity: 0.88; }
  100% { opacity: 0; }
}

@keyframes ougi-line {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes grain-move {
  from { background-position: 0 0; }
  to { background-position: -48px 28px; }
}

#mute {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 12, 20, 0.72);
  padding: 6px 12px;
  font-size: 12px;
}

@media (max-width: 900px) {
  #decks,
  .mech {
    grid-template-columns: 1fr;
  }

  .vs {
    text-align: center;
  }
}
