:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #080d14;
  color: #edf7ff;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(20, 115, 172, 0.22), transparent 32rem),
    linear-gradient(145deg, #090f18 0%, #070b11 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 52px;
}

/* ── Hero ─────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #5fcaff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

h1 {
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(36px, 6vw, 66px);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.subtitle {
  margin: 14px 0 0;
  color: #9aabba;
  font-size: 17px;
}

/* ── Room Card ────────────────────────────────────── */

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border: 1px solid #223246;
  border-radius: 8px;
  background: rgba(15, 24, 36, 0.88);
}

.room-card span {
  color: #687d92;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.room-card strong {
  color: #81dcff;
  font-family: Consolas, monospace;
  font-size: 18px;
  letter-spacing: 0.08em;
}

/* ── Level Dropdown ───────────────────────────────── */

.level-dropdown {
  position: relative;
}

.level-badge-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #1f91cc;
  border-radius: 6px;
  color: #77d4ff;
  background: rgba(15, 105, 151, 0.12);
  font-family: Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease;
}

.level-badge-btn:hover {
  background: rgba(15, 105, 151, 0.28);
}

.dropdown-arrow {
  font-size: 11px;
  transition: transform 200ms ease;
}

.level-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid #1f91cc;
  border-radius: 8px;
  background: #0e1826;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  min-width: 140px;
  max-height: 340px;
  overflow-y: auto;
}

.level-dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-menu li {
  padding: 0;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  border: none;
  border-radius: 5px;
  color: #aac5dd;
  background: transparent;
  font-family: Consolas, monospace;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}

.dropdown-menu button:hover {
  color: #fff;
  background: rgba(31, 145, 204, 0.18);
}

.dropdown-menu button.active {
  color: #5fcaff;
  background: rgba(31, 145, 204, 0.22);
  pointer-events: none;
}

/* ── Game Layout ──────────────────────────────────── */

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 800px) minmax(250px, 1fr);
  gap: 16px;
}

.arena-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid #2b4158;
  border-radius: 10px;
  background: #101722;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.result-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(4, 9, 15, 0.68);
  font-family: Consolas, monospace;
  font-size: clamp(46px, 9vw, 90px);
  font-weight: 900;
  letter-spacing: -0.08em;
  text-shadow: 0 0 32px rgba(79, 190, 255, 0.7);
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(4, 9, 15, 0.75);
  font-family: Consolas, monospace;
  font-size: clamp(80px, 16vw, 160px);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-shadow: 0 0 48px rgba(79, 190, 255, 0.8), 0 0 96px rgba(79, 190, 255, 0.4);
  animation: countPulse 0.8s ease-out;
}

@keyframes countPulse {
  0% { transform: scale(1.4); opacity: 0.3; }
  50% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.hidden {
  display: none;
}

/* ── Side Panel ───────────────────────────────────── */

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-card,
.hp-card,
.bot-tip,
.lesson-card {
  border: 1px solid #213145;
  border-radius: 9px;
  background: rgba(14, 22, 33, 0.9);
}

.status-card,
.bot-tip {
  padding: 18px;
}

.status-card h2,
.bot-tip h2 {
  margin: 0 0 14px;
  color: #cfeeff;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

dt {
  color: #71869a;
}

dd {
  margin: 0;
  font-family: Consolas, monospace;
  font-weight: 800;
}

#botStatus.connected {
  color: #57dd98;
}

.hp-card {
  padding: 14px;
}

.hp-card > div:first-child {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
}

.hp-card.player span,
.hp-card.player strong {
  color: #6ac9ff;
}

.hp-card.enemy span,
.hp-card.enemy strong {
  color: #ff7d89;
}

.hp-track {
  overflow: hidden;
  height: 7px;
  border-radius: 10px;
  background: #27303a;
}

.hp-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease;
}

.player .hp-fill {
  background: #2f9cff;
}

.enemy .hp-fill {
  background: #f04f5f;
}

.bot-tip,
.lesson-card {
  flex: 1;
}

.bot-tip p,
.lesson-card p {
  color: #8ca0b3;
  font-size: 13px;
  line-height: 1.6;
}

.bot-tip code,
.lesson-card code {
  display: block;
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px solid #27445c;
  border-radius: 6px;
  color: #83ddff;
  background: #09131d;
  font-family: Consolas, monospace;
  line-height: 1.5;
}

.lesson-link {
  color: #83ddff;
  font-weight: 800;
  text-decoration: none;
}

.lesson-card {
  padding: 18px;
}

.lesson-card h2 {
  margin: 0 0 12px;
  color: #cfeeff;
  font-size: 16px;
}

.lesson-link:hover {
  text-decoration: underline;
}

.bot-tip .muted {
  color: #667a8d;
}

.message {
  min-height: 24px;
  margin: 14px 2px 0;
  color: #79d3ff;
}

.message.error {
  color: #ff7d89;
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero-right {
    flex-direction: column;
    align-items: flex-end;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 22px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-right {
    flex-direction: row;
    align-items: center;
    width: 100%;
  }

  .room-card strong {
    font-size: 15px;
  }
}
