:root {
  --panel-bg: rgba(8, 18, 26, 0.84);
  --panel-border: rgba(182, 216, 232, 0.34);
  --text-main: #f4f8ff;
  --text-soft: #b8cad8;
  --accent-p1: #4cc9f0;
  --accent-p2: #ff758f;
  --accent-boss: #ffcc33;
  --shadow: 0 18px 48px rgba(3, 8, 16, 0.48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(72, 118, 153, 0.36), transparent 42%),
    radial-gradient(circle at 85% 78%, rgba(153, 81, 79, 0.3), transparent 46%),
    #03080f;
  color: var(--text-main);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

#app {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(233, 244, 255, 0.24);
  background: #000;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.start-hint {
  position: absolute;
  left: 24px;
  top: 20px;
  max-width: min(620px, 70%);
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(8, 16, 24, 0.64);
  border: 1px solid rgba(238, 246, 255, 0.24);
  backdrop-filter: blur(5px);
  line-height: 1.45;
}

.start-hint h1 {
  margin: 0 0 8px;
  font-size: clamp(20px, 2.1vw, 30px);
}

.start-hint p {
  margin: 5px 0;
  color: var(--text-soft);
  font-size: clamp(12px, 1.05vw, 15px);
}

.start-menu-button {
  position: absolute;
  right: 20px;
  top: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(199, 224, 238, 0.34);
  background: rgba(7, 14, 22, 0.68);
  color: #f2f8ff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 7;
}

.start-menu-button:hover {
  filter: brightness(1.12);
}

.start-menu-panel {
  position: absolute;
  right: 20px;
  top: 66px;
  min-width: 146px;
  border-radius: 10px;
  border: 1px solid rgba(189, 220, 236, 0.3);
  background: rgba(6, 15, 24, 0.95);
  overflow: hidden;
  z-index: 8;
}

.start-menu-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(167, 198, 215, 0.16);
  background: transparent;
  color: #e4f2fb;
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}

.start-menu-item:last-child {
  border-bottom: none;
}

.start-menu-item:hover {
  background: rgba(57, 89, 109, 0.34);
}

.start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 7, 12, 0.54);
  display: grid;
  place-items: center;
  z-index: 9;
}

.start-overlay-card {
  width: min(520px, 86%);
  border-radius: 14px;
  border: 1px solid rgba(186, 219, 237, 0.34);
  background: linear-gradient(140deg, rgba(11, 22, 31, 0.94), rgba(8, 17, 24, 0.94));
  padding: 16px 18px;
}

.start-overlay-card h3 {
  margin: 0;
  font-size: 22px;
}

.start-overlay-text {
  margin-top: 10px;
  line-height: 1.6;
  color: #d6e7f1;
  font-size: 14px;
}

.start-overlay-image {
  margin-top: 10px;
  width: min(280px, 100%);
  border-radius: 10px;
  border: 1px solid rgba(209, 231, 243, 0.22);
  display: block;
}

.phase-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  min-width: 260px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(7, 14, 22, 0.6);
  border: 1px solid rgba(207, 228, 240, 0.28);
  color: #f5fbff;
  font-size: clamp(12px, 1.05vw, 15px);
  pointer-events: none;
  z-index: 5;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  pointer-events: none;
  z-index: 6;
}

.hp-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(6, 13, 20, 0.68);
  border: 1px solid rgba(225, 241, 255, 0.2);
}

.hp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.side-tag {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.side-tag.p1 {
  background: color-mix(in srgb, var(--accent-p1) 36%, transparent);
  color: #d9f8ff;
}

.side-tag.p2 {
  background: color-mix(in srgb, var(--accent-p2) 36%, transparent);
  color: #ffe0e7;
}

.hp-text {
  font-size: 13px;
  color: #e0edf7;
}

.hp-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(208, 223, 236, 0.2);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease;
}

.hp-fill.p1 {
  background: linear-gradient(90deg, #00b4d8, #6fffe9);
}

.hp-fill.p2 {
  background: linear-gradient(90deg, #ff4d6d, #ff99ac);
}

.skill-cd-row {
  margin-top: 6px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.skill-cd-text {
  font-size: 11px;
  color: #c9deec;
  white-space: nowrap;
}

.skill-cd-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(208, 223, 236, 0.18);
  overflow: hidden;
}

.skill-cd-fill {
  height: 100%;
  width: 100%;
  transition: width 0.12s linear;
}

.skill-cd-fill.weapon {
  background: linear-gradient(90deg, #5da9ff, #84dbff);
}

.skill-cd-fill.character {
  background: linear-gradient(90deg, #70e0a7, #96f2d7);
}

.status-row {
  margin-top: 8px;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(230, 240, 248, 0.6);
  background: rgba(15, 28, 39, 0.78);
  color: #e9f4fb;
  display: grid;
  place-items: center;
  position: relative;
  font-size: 12px;
  font-weight: 700;
}

.status-chip::after {
  content: attr(data-layers);
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #ff6b6b;
  color: #fff;
  border: 1px solid rgba(20, 24, 30, 0.8);
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  padding: 0 2px;
}

.battle-tip {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(230, 243, 252, 0.26);
  background: rgba(8, 17, 25, 0.65);
  color: #eff9ff;
  font-size: 13px;
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
}

.battle-info-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, 88%);
  border-radius: 14px;
  border: 1px solid rgba(194, 223, 239, 0.42);
  background:
    linear-gradient(135deg, rgba(11, 22, 33, 0.94), rgba(7, 17, 26, 0.94));
  box-shadow: var(--shadow);
  padding: 18px 20px 16px;
  z-index: 10;
}

.battle-info-header h2 {
  margin: 0;
  font-size: clamp(20px, 1.9vw, 28px);
}

.battle-info-header p {
  margin: 6px 0 0;
  color: #b9d0de;
  font-size: 13px;
}

.battle-info-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.battle-info-card {
  border: 1px solid rgba(190, 220, 236, 0.24);
  border-radius: 10px;
  background: rgba(6, 15, 23, 0.64);
  padding: 10px 12px;
}

.battle-info-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.battle-info-card p {
  margin: 4px 0;
  color: #d4e7f2;
  line-height: 1.45;
  font-size: 13px;
}

.battle-info-boss {
  margin: 10px 0 0;
  color: #ffe3ab;
  font-size: 13px;
}

.boss-hud {
  position: absolute;
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  width: min(420px, 70%);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(10, 16, 24, 0.72);
  border: 1px solid rgba(255, 232, 151, 0.46);
  z-index: 6;
}

.boss-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  text-align: center;
}

.boss-track {
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 230, 154, 0.21);
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease;
  background: linear-gradient(90deg, #fcbf49, #ffd166);
}

.boss-text {
  margin-top: 4px;
  text-align: center;
  font-size: 12px;
  color: #ffe9b4;
}

.selection-panel {
  position: absolute;
  inset: 8% 10%;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(145deg, rgba(14, 25, 35, 0.9), rgba(6, 16, 24, 0.9)),
    var(--panel-bg);
  backdrop-filter: blur(5px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  z-index: 8;
}

.selection-header h2 {
  margin: 0;
  font-size: clamp(20px, 2vw, 30px);
}

.selection-header p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.selection-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 18px;
}

.selection-wheel {
  height: 100%;
  border-radius: 12px;
  padding: 10px;
  background: rgba(3, 12, 20, 0.48);
  border: 1px solid rgba(201, 229, 248, 0.2);
  overflow: auto;
  user-select: none;
  touch-action: none;
}

.selection-list {
  min-height: 100%;
  display: grid;
  grid-auto-rows: minmax(64px, 1fr);
  gap: 8px;
}

.wheel-item {
  min-height: 64px;
  width: 100%;
  border-radius: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  border: 1px solid rgba(201, 228, 244, 0.28);
  background: rgba(32, 48, 60, 0.34);
  color: #a8bfd0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wheel-item:hover {
  background: rgba(56, 84, 104, 0.4);
  color: #d9effb;
}

.wheel-item.current {
  border: 1px solid rgba(130, 221, 255, 0.72);
  background: rgba(42, 106, 132, 0.42);
  font-size: clamp(15px, 1.2vw, 20px);
  color: #e7fbff;
  text-shadow: 0 0 12px rgba(122, 227, 255, 0.25);
}

.selection-detail {
  min-height: 0;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(203, 226, 240, 0.2);
  background: rgba(2, 10, 18, 0.42);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
}

.selection-detail h3 {
  margin: 0;
  font-size: clamp(20px, 2vw, 30px);
}

.selection-detail p {
  margin: 0;
  color: #d8eaf8;
  line-height: 1.55;
}

.detail-stats {
  margin: 0;
  padding-left: 18px;
  color: #b9d2e2;
  font-size: 14px;
  line-height: 1.5;
  overflow: auto;
}

.confirm-button {
  justify-self: start;
  border: 1px solid rgba(175, 228, 250, 0.74);
  background: linear-gradient(130deg, #19445f, #20617f);
  color: #e5f9ff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.confirm-button:hover {
  filter: brightness(1.1);
}

.selection-path {
  min-height: 26px;
  color: #a6bfd0;
  font-size: 13px;
  border-top: 1px dashed rgba(184, 219, 236, 0.26);
  padding-top: 8px;
}

.result-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(540px, 82%);
  border-radius: 14px;
  border: 1px solid rgba(202, 229, 245, 0.34);
  background:
    linear-gradient(130deg, rgba(10, 18, 28, 0.92), rgba(7, 16, 25, 0.92));
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
  z-index: 9;
}

.result-panel h2 {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 34px);
}

.result-panel p {
  margin: 10px 0 20px;
  color: #bfd3e2;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  #app {
    width: 100vw;
    border-radius: 0;
    border: none;
  }

  .start-hint {
    max-width: 88%;
    left: 12px;
    top: 12px;
    padding: 12px;
  }

  .start-menu-button {
    right: 12px;
    top: 12px;
  }

  .start-menu-panel {
    right: 12px;
    top: 58px;
  }

  .hud {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .battle-tip {
    bottom: 10px;
    max-width: 90%;
    text-align: center;
    white-space: normal;
  }

  .battle-info-grid {
    grid-template-columns: 1fr;
  }

  .boss-hud {
    top: 124px;
    width: 82%;
  }

  .selection-panel {
    inset: 4%;
    padding: 14px;
  }

  .selection-body {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .selection-wheel {
    min-height: 240px;
  }
}
