:root {
  color-scheme: dark;
  --bg: #070a12;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --line: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1000px 700px at 25% 10%, rgba(66, 92, 255, 0.20), transparent 60%),
    radial-gradient(900px 620px at 70% 20%, rgba(255, 92, 160, 0.16), transparent 60%),
    linear-gradient(180deg, #070a12 0%, #05060c 100%);
  color: var(--text);
  overflow: hidden;
}

.topbar {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbarInner {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 14px;
  align-items: center;
  max-width: 1080px;
  margin: 0 auto;
}

.topbarInner .brand {
  justify-self: start;
}

.brand {
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 22px;
  line-height: 1;
}

.brandSite {
  margin-left: 10px;
  font-weight: 1000;
  font-size: 14px;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, #60a5fa, #34d399, #fbbf24, #fb7185, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(120, 170, 255, 0.10);
}

.hud {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.hudItem {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  min-width: 96px;
}

.hudItem .label {
  font-size: 12px;
  color: var(--muted);
}

.hudItem .value {
  font-size: 18px;
  font-weight: 900;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-self: start;
}

.levelList {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 2px;
}

.levelBtn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 1000;
  font-size: 13px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.levelBtn:hover {
  background: rgba(255, 255, 255, 0.10);
}

#levelMap .levelBtn {
  pointer-events: none;
  cursor: default;
}

#levelMap .levelBtn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.levelBtn.active {
  background: rgba(66, 92, 255, 0.26);
  border-color: rgba(66, 92, 255, 0.50);
  color: rgba(255, 255, 255, 0.96);
}

.levelBtn.locked {
  opacity: 0.42;
  cursor: not-allowed;
}

.levelBtn.cleared {
  border-color: rgba(26, 196, 136, 0.55);
  background: rgba(26, 196, 136, 0.10);
}

.levelBtn:focus {
  outline: 2px solid rgba(66, 92, 255, 0.45);
  outline-offset: 2px;
}

.selectWrap {
  display: grid;
  gap: 4px;
}

.selectLabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.select {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}

.select option {
  background: #0b1020;
  color: rgba(255, 255, 255, 0.92);
}

.topbar .select {
  padding: 10px 10px;
  min-width: 160px;
}

.select:focus {
  outline: 2px solid rgba(66, 92, 255, 0.45);
  outline-offset: 2px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn.primary {
  background: rgba(66, 92, 255, 0.24);
  border-color: rgba(66, 92, 255, 0.40);
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 16px;
  padding: 16px;
  max-width: 1080px;
  margin: 0 auto;
  height: calc(100vh - 92px);
}

.left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow: auto;
}

.bigValue {
  font-size: 34px;
  font-weight: 1000;
  line-height: 1;
  letter-spacing: -0.6px;
}

.statRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.statRow:last-child {
  border-bottom: 0;
}

.statLabel {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.statValue {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 1000;
}

.stage {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-start;
}

#c {
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 820;
  max-height: 100%;
  max-width: 100%;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow: auto;
}

.panel {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
}

.panel.muted {
  background: rgba(255, 255, 255, 0.04);
}

.panelTitle {
  font-weight: 900;
  margin-bottom: 8px;
}

.panelText {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

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

.playerName {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(234, 240, 255, 0.90);
  font-size: 15px;
  font-weight: 900;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .playerName {
  align-self: end;
}

.aiRow {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: start;
}

.aiAvatarWrap {
  width: 56px;
  height: 56px;
  position: relative;
}

.aiAvatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  --mouth-center: 0%;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.5), transparent 45%),
    radial-gradient(circle at 50% 70%, rgba(0, 0, 0, 0.18), transparent 55%),
    linear-gradient(180deg, #ffd2a6, #f1b98d);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.14), inset 0 -10px 16px rgba(0, 0, 0, 0.22),
    0 14px 22px rgba(0, 0, 0, 0.3);
}

.aiAvatar.sad {
  --mouth-center: 100%;
}

.aiArrow {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.28);
  z-index: 5;
  color: #ffffff;
  font-size: 16px;
  font-weight: 1000;
  letter-spacing: -0.4px;
  opacity: 0;
  transform: translateY(2px) scale(0.98);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.aiAvatar.happy + .aiArrow,
.aiAvatar.sad + .aiArrow {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.aiAvatar::before {
  content: "";
  position: absolute;
  inset: -2px -2px 18px -2px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.1), transparent 60%),
    linear-gradient(180deg, #2a2a2a, #101010);
  clip-path: ellipse(65% 55% at 50% 25%);
  opacity: 0.95;
}

.aiAvatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 38% 52%, #ffffff 0 1px, transparent 1.25px),
    radial-gradient(circle at 62% 52%, #ffffff 0 1px, transparent 1.25px),
    radial-gradient(circle at 38% 52%, rgba(0, 0, 0, 0.85) 0 2.6px, transparent 3px),
    radial-gradient(circle at 62% 52%, rgba(0, 0, 0, 0.85) 0 2.6px, transparent 3px),
    radial-gradient(circle at 50% var(--mouth-center), transparent 0 10px, rgba(0, 0, 0, 0.62) 10px 12px, transparent 12.8px);
  background-repeat: no-repeat;
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 34px 18px;
  background-position: 0 0, 0 0, 0 0, 0 0, 50% 90%;
  opacity: 0.85;
}

.aiDialog {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.82);
  font-weight: 650;
  line-height: 1.5;
}

.ballRow {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
}

.ballLabel {
  color: var(--muted);
  font-weight: 800;
}

.ballHint {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
}

#ballNow,
#ballNext {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.overlay.hidden {
  display: none;
}

.menuOverlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 4;
}

.menuOverlay.hidden {
  display: none;
}

.menuCard {
  width: min(520px, 94%);
  max-height: 92%;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.menuTitle {
  font-size: 26px;
  font-weight: 1000;
  letter-spacing: 0.3px;
  margin: 6px 4px 10px;
}

.modeRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modeRow .btn.active {
  background: rgba(66, 92, 255, 0.24);
  border-color: rgba(66, 92, 255, 0.40);
}

.levelSelectRow {
  margin-top: 10px;
}

.overlayCard {
  width: min(420px, 92%);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  padding: 18px;
  text-align: center;
}

.overlayTitle {
  font-size: 34px;
  font-weight: 1000;
  letter-spacing: 0.4px;
}

.overlayText {
  margin-top: 8px;
  color: var(--muted);
}

@media (max-width: 940px) {
  .topbarInner {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  #c {
    width: 100%;
    height: auto;
    max-width: 820px;
  }

  body {
    overflow: auto;
  }
}
