:root {
  --text: #3d2838;
  --pink: #ff6b9d;
  --peach: #ff9a62;
  --mint: #3ed598;
  --violet: #9b6bff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 30% 20%, #ffe6f2 0%, #d8f5eb 48%, #c9d8ff 100%);
  touch-action: manipulation;
}

#viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  max-width: 450px;
  max-height: 920px;
  background: url('./assets/bg-BfWfiL10.jpg') center/cover no-repeat;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(82, 46, 110, 0.3), 0 0 0 4px rgba(255, 255, 255, 0.7);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.35s ease;
}

#game-shell.fever-on {
  box-shadow:
    0 0 0 4px #ffeb3b,
    0 0 36px rgba(255, 107, 157, 0.85),
    0 0 70px rgba(155, 107, 255, 0.65);
}

@media (max-width: 520px) {
  #game-shell {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Pastel dreamy overlay + animated Fever aurora */
#game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 240, 248, 0.35) 0%, rgba(255, 255, 255, 0.08) 45%, rgba(120, 90, 190, 0.16) 100%);
  pointer-events: none;
  z-index: 0;
  transition: background 0.35s ease;
}

#game-shell.fever-on::before {
  background:
    radial-gradient(circle at 20% 25%, rgba(255, 92, 168, 0.35), transparent 55%),
    radial-gradient(circle at 80% 75%, rgba(86, 204, 242, 0.35), transparent 55%),
    linear-gradient(135deg, rgba(255, 214, 102, 0.22), rgba(155, 107, 255, 0.28));
  animation: feverPulse 1.1s ease-in-out infinite alternate;
}

@keyframes feverPulse {
  from { opacity: 0.72; }
  to { opacity: 1; }
}

/* Top HUD */
.top-hud {
  position: relative;
  z-index: 10;
  padding: 10px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mode-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 3px 12px rgba(90, 50, 110, 0.14);
}

.mode-btn {
  border: none;
  background: transparent;
  color: #614a5b;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: linear-gradient(135deg, #ff7eb3, #ff758c);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 117, 140, 0.4);
}

.mode-btn.active.chaos-mode {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.45);
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(70, 45, 95, 0.14);
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.88);
}

.icon-btn.muted {
  opacity: 0.48;
  filter: grayscale(0.8);
}

.level-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 6px 11px;
  box-shadow: 0 4px 14px rgba(80, 50, 110, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
}

.level-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.level-title {
  font-size: 13.5px;
  font-weight: 900;
  color: #3f2438;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-sub {
  font-size: 10.5px;
  color: #7c6075;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.stat-pill {
  background: #fff0f6;
  border: 1px solid #ffc6dc;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #b8326a;
  white-space: nowrap;
}

.stat-pill.zen {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}

/* Fever 夯度条 */
.fever-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  box-shadow: 0 3px 10px rgba(80, 45, 110, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.fever-label {
  font-size: 11px;
  font-weight: 900;
  color: #b8326a;
  white-space: nowrap;
}

.fever-track {
  flex: 1;
  height: 10px;
  background: rgba(155, 107, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.fever-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7eb3, #ffb347, #6ee7b7, #60a5fa, #c084fc);
  background-size: 220% 100%;
  animation: rainbowFlow 2s linear infinite;
  transition: width 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 10px rgba(255, 126, 179, 0.7);
}

@keyframes rainbowFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 220% 50%; }
}

.fever-status {
  font-size: 10.5px;
  font-weight: 900;
  color: #7c3aed;
  min-width: 44px;
  text-align: right;
}

#game-shell.fever-on .fever-wrap {
  background: linear-gradient(90deg, rgba(255, 235, 59, 0.92), rgba(255, 126, 179, 0.92));
  border-color: #fff;
}

#game-shell.fever-on .fever-label,
#game-shell.fever-on .fever-status {
  color: #fff;
  text-shadow: 0 1px 4px rgba(120, 20, 60, 0.5);
}

/* Main Playfield Canvas Area */
.stage-wrap {
  position: relative;
  flex: 1;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

/* Mascot Cheer Bar */
.mascot-bar {
  position: absolute;
  top: 2px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 8;
}

.mascot-avatar {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.18));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mascot-avatar.bounce {
  transform: scale(1.26) rotate(-8deg);
}

.mascot-bubble {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px 12px 12px 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  color: #56324d;
  box-shadow: 0 3px 10px rgba(70, 40, 90, 0.12);
  max-width: 260px;
}

/* Bottom Props Bar */
.props-bar {
  position: relative;
  z-index: 10;
  padding: 4px 12px 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.prop-btn {
  position: relative;
  border: none;
  border-radius: 14px;
  padding: 7px 4px 6px;
  background: linear-gradient(180deg, #ffffff 0%, #f9e8f2 100%);
  box-shadow: 0 4px 0 #d59cb9, 0 6px 14px rgba(80, 40, 90, 0.16);
  color: #4f2a44;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease;
}

.prop-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d59cb9, 0 2px 6px rgba(80, 40, 90, 0.14);
}

.prop-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.prop-btn.magic {
  background: linear-gradient(180deg, #fff9e6 0%, #ffd580 100%);
  box-shadow: 0 4px 0 #d98c2b, 0 6px 14px rgba(180, 100, 10, 0.24);
  color: #6b3b08;
}

.prop-icon {
  font-size: 17px;
  line-height: 1.1;
}

.prop-name {
  font-size: 10.5px;
  font-weight: 800;
}

.prop-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff5e97, #ff7c5c);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  border: 1.5px solid #fff;
}

/* Modal Overlay */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(34, 20, 48, 0.56);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 312px;
  background: linear-gradient(180deg, #ffffff 0%, #fdf2f8 100%);
  border-radius: 26px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(255, 255, 255, 0.9);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-card {
  transform: scale(1);
}

.modal-mascot {
  width: 74px;
  height: 74px;
  object-fit: contain;
  margin-bottom: 6px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.16));
}

.modal-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 900;
  color: #3f2036;
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #74546b;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-stat-box {
  background: #fff;
  border-radius: 14px;
  padding: 8px 14px;
  border: 1.5px solid #f5d0e3;
}

.modal-stat-val {
  font-size: 18px;
  font-weight: 900;
  color: #e11d74;
}

.modal-stat-lbl {
  font-size: 11px;
  color: #8a6a80;
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ff6b9d, #ff8e53);
  box-shadow: 0 4px 0 #c9466e, 0 8px 18px rgba(255, 107, 157, 0.35);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.primary-btn:active {
  transform: translateY(2px);
}

.secondary-btn {
  border: 1.5px solid #f3c4dc;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 800;
  color: #7c385a;
  background: #fff5fa;
  cursor: pointer;
}
