* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  color: #2c2340;
  background:
    radial-gradient(ellipse at 18% 12%, rgba(255, 214, 165, 0.14), transparent 55%),
    radial-gradient(ellipse at 85% 88%, rgba(165, 198, 255, 0.12), transparent 55%),
    linear-gradient(160deg, #2c3d72 0%, #1d2650 55%, #151a38 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
}

#stage {
  display: grid;
  grid-template-columns: auto 300px;
  grid-template-areas:
    "canvas side";
  gap: 14px;
  align-items: flex-start;
  justify-content: center;
  max-width: 980px;
}

/* ---------- canvas area ---------- */
#canvasWrap {
  position: relative;
  flex: 0 0 auto;
  grid-area: canvas;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  background: #fdf6e7;
}

canvas#game {
  display: block;
  height: min(86vh, 640px);
  width: auto;
  max-width: 100%;
  touch-action: none;
  cursor: crosshair;
}

canvas#game.aiming {
  cursor: pointer;
}

#hintBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 5px 10px;
  text-align: center;
  font-size: 12px;
  color: #6b5d80;
  background: linear-gradient(rgba(255, 246, 232, 0.95), rgba(255, 246, 232, 0));
  pointer-events: none;
  z-index: 3;
}

#toast {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(42, 33, 64, 0.88);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 12px;
  border-radius: 10px;
  white-space: normal;
  text-align: center;
  max-width: 88%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
  z-index: 6;
  max-width: 92%;
}

#toast.show {
  opacity: 1;
}

#banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}

#banner.hidden {
  display: none;
}

#banner .core {
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
  animation: bannerPop 0.35s ease-out;
}

#banner .big {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
}

#banner .sub {
  font-size: 14px;
  opacity: 0.95;
}

@keyframes bannerPop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#targetHint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(52, 44, 76, 0.92);
  color: #fff;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 6;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

#targetHint.hidden {
  display: none;
}

#targetHint .sub {
  opacity: 0.7;
  font-size: 11px;
}

/* ---------- overlay ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 20, 43, 0.55);
  backdrop-filter: blur(3px);
  z-index: 8;
  transition: opacity 0.3s;
}

#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#overlay .panel {
  width: min(78%, 330px);
  text-align: center;
  background: linear-gradient(180deg, #fffdf7, #fff3e0);
  border-radius: 20px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

#overlay .ovLogo {
  width: 76px;
  height: 76px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff 0%, #ffe3ec 35%, #f7a9c4 75%, #ef7ea6 100%);
  border: 4px solid #fff;
  box-shadow: 0 4px 14px rgba(239, 126, 166, 0.55);
}

#overlay h1 {
  font-size: 26px;
  letter-spacing: 3px;
  color: #5a3a4d;
  margin-bottom: 8px;
}

#overlay p {
  font-size: 13px;
  line-height: 1.65;
  color: #6e5c70;
  margin-bottom: 12px;
}

#ovStats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #7c6780;
}

#ovStats .big {
  font-size: 20px;
  font-weight: 800;
  color: #463158;
}

#startBtn {
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #ff9ebd, #ff7ba3);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 11px 36px;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(255, 123, 163, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#startBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(255, 123, 163, 0.55);
}

/* ---------- side panels ---------- */
.sidePanel {
  background: rgba(255, 253, 248, 0.96);
  border-radius: 16px;
  padding: 14px 12px 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  scrollbar-width: thin;
  overflow-y: auto;
}

#sideStack {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(86vh, 640px);
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.sidePanel::-webkit-scrollbar {
  width: 6px;
}

.sidePanel::-webkit-scrollbar-thumb {
  background: rgba(90, 70, 110, 0.25);
  border-radius: 3px;
}

.headRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 4px 8px;
}

.headRow h1 {
  font-size: 20px;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ff7ba3, #9a6bf0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.headRow .sub {
  font-size: 11px;
  color: #a295ac;
}

.statsRow {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.stat {
  flex: 1;
  background: #f6efe4;
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}

.stat .k {
  display: block;
  font-size: 10px;
  color: #9a8aa5;
}

.stat .v {
  font-size: 17px;
  font-weight: 800;
  color: #4a365c;
}

.sec {
  background: #fbf6ec;
  border-radius: 12px;
  padding: 9px 10px;
  margin-bottom: 8px;
}

.secTitle {
  font-size: 12px;
  font-weight: 700;
  color: #685378;
  margin-bottom: 6px;
}

.secTitle span {
  color: #b07aa8;
  font-weight: 800;
}

/* 语音模式开关 */
.seg {
  display: flex;
  gap: 3px;
  background: #efe6d8;
  border-radius: 999px;
  padding: 3px;
}

.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #8b7b92;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 2px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.seg button.segOn {
  background: linear-gradient(135deg, #ff9ebd, #ff7ba3);
  color: #fff;
  box-shadow: 0 2px 7px rgba(255, 123, 163, 0.4);
}

.tiny {
  font-size: 10px;
  color: #a195ab;
  line-height: 1.5;
  margin-top: 5px;
}

.foot {
  padding: 0 4px 2px;
  text-align: center;
}

/* cats */
#catSlots {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0 2px;
}

.catSlot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #eadfc9;
  background: #eee4d3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.catSlot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.12;
  filter: grayscale(1);
  transition: opacity 0.2s;
}

.catSlot.filled img {
  opacity: 1;
  filter: none;
}

/* queue preview */
#nextSlots {
  display: flex;
  align-items: flex-end;
  min-height: 42px;
  gap: 4px;
  flex-wrap: wrap;
}

.qIcon {
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(80, 60, 40, 0.25);
  background: #e9dfd1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qIcon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qIconLock {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e7dbc9;
  color: #9b8b9d;
  font-size: 20px;
  font-weight: 800;
  border-color: #d8c8b2;
}

/* skill buttons */
#skillGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.skillBtn {
  position: relative;
  border: 0;
  background: #f1e8db;
  border-radius: 11px;
  padding: 6px 2px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: not-allowed;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.skillBtn .face {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.skillBtn .face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.skillBtn .lvl {
  position: absolute;
  right: -1px;
  bottom: -1px;
  min-width: 14px;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  background: #fff;
  color: #6f4d85;
  font-weight: 800;
  border-radius: 999px;
  border: 1px solid #d9c8dc;
}

.skillBtn .cnt {
  position: absolute;
  right: 2px;
  top: 2px;
  min-width: 16px;
  height: 15px;
  padding: 0 3px;
  font-size: 9px;
  line-height: 15px;
  text-align: center;
  background: linear-gradient(135deg, #ffe3a3, #ffc75f);
  color: #8a5c12;
  font-weight: 800;
  border-radius: 999px;
  border: 1px solid #fff;
  box-shadow: 0 1px 4px rgba(90, 60, 20, 0.35);
}

.skillBtn .cnt.zero {
  background: #e7dccb;
  color: #b6a693;
  box-shadow: none;
}

/* 技能悬停说明 */
.skillTip {
  position: fixed;
  z-index: 1000;
  max-width: 260px;
  background: rgba(45, 36, 66, 0.96);
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  line-height: 1.5;
}

.skillTip.hidden {
  display: none;
}

.skillTip .tipHead {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 3px;
  color: #ffd9a0;
}

.skillTip .tipLv {
  font-size: 10px;
  color: #cbb8ff;
  font-weight: 700;
}

.skillBtn .sname {
  font-size: 11px;
  color: #7a6b85;
  font-weight: 700;
}

.skillBtn .lockBadge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: rgba(70, 55, 85, 0.25);
  border-radius: 50%;
}

.skillBtn.locked .face img {
  filter: grayscale(0.9);
  opacity: 0.55;
}

.skillBtn.locked .sname {
  color: #b7a9c0;
}

.skillBtn.ready {
  cursor: pointer;
  background: #fff7e8;
  box-shadow: 0 0 0 2px rgba(255, 178, 107, 0.75), 0 4px 12px rgba(255, 178, 107, 0.3);
  animation: readyGlow 1.2s ease-in-out infinite;
}

@keyframes readyGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 178, 107, 0.7), 0 4px 10px rgba(255, 178, 107, 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(255, 140, 150, 0.95), 0 4px 16px rgba(255, 140, 150, 0.45); }
}

.skillBtn.active {
  background: #ffe9ef;
  box-shadow: 0 0 0 3px #ff8fb2;
  transform: scale(1.06);
}

.skillBtn.disable {
  filter: saturate(0.65);
}

/* responsive */
@media (max-width: 880px) {
  #app {
    overflow: hidden;
    height: 100dvh;
    padding: 8px;
    align-items: stretch;
  }

  #stage {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 560px;
    margin: 0 auto;
  }

  #sideStack {
    display: contents;
  }

  #panelTop {
    order: 0;
    width: min(96vw, 520px);
    max-height: 21vh;
    flex: 0 0 auto;
    padding: 8px 10px 6px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  #canvasWrap {
    order: 1;
    flex: 1 1 auto;
    min-height: 0;
    width: min(96vw, 520px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  canvas#game {
    height: 100%;
    width: auto;
    max-width: 100%;
  }

  #panelBottom {
    order: 2;
    width: min(96vw, 520px);
    max-height: 32vh;
    flex: 0 1 auto;
    padding: 6px 8px 8px;
    border-radius: 12px;
  }

  #panelBottom .sec {
    margin-bottom: 0;
  }

  /* 手机端：只保留常用状态，详细介绍折叠 */
  .headRow h1 {
    font-size: 16px;
  }

  .headRow .sub {
    display: none;
  }

  .sidePanel .tiny,
  .sidePanel .foot,
  #chargeSec,
  #voiceSec .tiny {
    display: none;
  }

  .statsRow {
    margin-bottom: 0;
  }

  #voiceSec,
  #catSec,
  #nextSec {
    margin-bottom: 0;
    padding: 5px 8px;
  }

  #voiceSec .seg {
    padding: 2px;
  }

  #voiceSec .seg button {
    font-size: 11px;
    padding: 4px 2px;
  }

  #catSlots {
    gap: 6px;
    margin: 0;
  }

  .catSlot {
    width: 28px;
    height: 28px;
  }

  #nextSlots {
    min-height: 34px;
  }

  .headRow {
    padding: 0 2px 0;
    justify-content: center;
    gap: 8px;
    display: none;
  }

  .secTitle {
    margin-bottom: 3px;
  }

  #skillGrid {
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
  }

  .skillBtn {
    padding: 4px 1px 3px;
    gap: 2px;
  }

  .skillBtn .sname {
    font-size: 10px;
  }

  .skillBtn .face {
    width: 38px;
    height: 38px;
  }

  #hintBar {
    font-size: 10px;
    padding: 3px 8px;
  }
}

@media (max-width: 520px) {
  .skillBtn .face {
    width: 36px;
    height: 36px;
  }

  .sidePanel .sec {
    margin-bottom: 6px;
    padding: 7px 8px;
  }

  #panelBottom .sec {
    margin-bottom: 0;
  }
}

/* 横屏手机 / 矮窗口：回到左右布局，避免画布过高 */
@media (max-height: 540px) and (min-width: 700px) {
  #app {
    align-items: center;
    padding: 4px;
  }

  #stage {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    height: auto;
    max-width: none;
  }

  canvas#game {
    height: min(88vh, 520px);
    width: auto;
    max-width: 56vw;
  }

  #canvasWrap {
    order: 0;
    width: auto;
    height: auto;
  }

  #sideStack {
    order: 1;
    display: flex;
    width: min(44vw, 360px);
    max-height: min(88vh, 520px);
    overflow-y: auto;
  }

  #panelTop,
  #panelBottom {
    max-height: none;
    flex: 0 0 auto;
    width: 100%;
  }

  .sidePanel .tiny,
  .sidePanel .foot {
    display: none;
  }
}
