﻿:root {
  --bg-deep: #12061a;
  --bg-panel: #241030;
  --bg-card: #331743;
  --border-gold: #e39ec0;
  --gold-bright: #ffd1e6;
  --gold-mid: #f472b6;
  --text-main: #fdf2f8;
  --text-muted: #c9aec0;
  --green: #4ade80;
  --red: #f87171;
  --cyan: #c4b5fd;
}

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

body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 12%, #4a1552 0%, #22093a 45%, #14061f 72%, #0a0410 100%);
  color: var(--text-main);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.app-shell {
  width: 100%;
  max-width: 1000px;
}

.arcade-frame {
  background: linear-gradient(180deg, #2e1236 0%, #190a22 100%);
  border: 3px solid #7c3a63;
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(255, 200, 232, 0.22);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* HUD */
.hud-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
}

.hud-group {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}

.hud-card {
  background: rgba(26, 8, 34, 0.8);
  border: 1px solid rgba(233, 160, 196, 0.35);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 96px;
}

.hud-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.hud-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.hud-value.money {
  color: var(--gold-bright);
}

.hud-value.target {
  color: #ffc2dd;
}

.hud-value.timer {
  color: #ffe6f4;
}

.timer-card.warning {
  border-color: var(--red);
  background: rgba(122, 18, 66, 0.55);
  animation: pulseWarn 0.7s infinite alternate;
}

.timer-card.warning .hud-value.timer {
  color: #fecaca;
}

@keyframes pulseWarn {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

.hud-progress-card {
  min-width: 170px;
}

.hud-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.hud-progress-head strong {
  color: var(--gold-bright);
}

.hud-percent {
  font-size: 11px;
  color: var(--gold-bright);
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a855f7, #f472b6 55%, #ffd1e6);
  transition: width 0.25s ease;
}

.progress-fill.goal-met {
  background: linear-gradient(90deg, #34d399, #a7f3d0);
}

.hud-btn {
  background: linear-gradient(180deg, #4d1c48 0%, #2d0f36 100%);
  color: var(--text-main);
  border: 1px solid rgba(233, 160, 196, 0.5);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}

.hud-btn:hover:not(:disabled) {
  border-color: var(--gold-bright);
  filter: brightness(1.12);
}

.hud-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.hud-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dynamite-btn.ready {
  border-color: #ef4444;
  background: linear-gradient(180deg, #8d1640 0%, #4a0722 100%);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.finish-btn {
  border-color: #22c55e;
  background: linear-gradient(180deg, #0f5f52 0%, #053129 100%);
  color: #bbf7d0;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
  animation: pulseWarn 0.9s infinite alternate;
}

.hud-btn.hidden {
  display: none;
}

.icon-btn {
  padding: 6px 11px;
  font-size: 16px;
}

.buffs-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.buff-tag {
  background: rgba(244, 114, 182, 0.16);
  border: 1px solid rgba(255, 170, 212, 0.45);
  color: #ffd6ea;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Stage */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 600;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #6b2c58;
  background: #180b22;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.6);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
}

/* Overlays */
.overlay-panel {
  position: absolute;
  inset: 0;
  background: rgba(16, 4, 22, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
}

.overlay-panel.hidden {
  display: none;
}

.panel-card {
  width: 100%;
  max-width: 680px;
  background: linear-gradient(180deg, #2e1236 0%, #190a22 100%);
  border: 2px solid var(--border-gold);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
  text-align: center;
}

.compact-card {
  max-width: 440px;
}

.badge-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(244, 114, 182, 0.18);
  border: 1px solid rgba(255, 170, 212, 0.45);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.badge-pill.success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(74, 222, 128, 0.5);
  color: var(--green);
}

.badge-pill.danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

.game-title {
  font-size: clamp(28px, 4vw, 40px);
  color: var(--gold-bright);
  text-shadow: 0 3px 12px rgba(240, 106, 168, 0.35);
  margin-bottom: 8px;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 18px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  text-align: left;
}

.legend-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(233, 160, 196, 0.22);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-item span {
  font-size: 24px;
}

.legend-item strong {
  display: block;
  font-size: 14px;
  color: var(--text-main);
}

.legend-item small {
  color: var(--text-muted);
  font-size: 12px;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: #ffd6ea;
  background: rgba(240, 106, 168, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 18px;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.best-score-chip {
  font-size: 14px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
}

.best-score-chip strong {
  color: var(--gold-bright);
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 26px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.primary-btn {
  background: linear-gradient(180deg, #ffd1e6 0%, #f06aa8 100%);
  color: #3a0d24;
  box-shadow: 0 6px 18px rgba(240, 106, 168, 0.4);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.primary-btn:hover,
.secondary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.97);
}

/* Shop */
.shop-card {
  text-align: left;
  max-width: 760px;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.shop-header h2 {
  font-size: 24px;
  color: var(--gold-bright);
}

.shop-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.shop-wallet {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 170, 212, 0.45);
  border-radius: 12px;
  padding: 8px 14px;
  text-align: right;
}

.shop-wallet span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.shop-wallet strong {
  font-size: 22px;
  color: var(--gold-bright);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.shop-item {
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(233, 160, 196, 0.32);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.shop-item:hover:not(.sold):not(.unaffordable) {
  transform: translateY(-2px);
  border-color: var(--gold-bright);
  background: rgba(240, 106, 168, 0.14);
}

.shop-item.sold {
  opacity: 0.55;
  border-color: var(--green);
  cursor: default;
}

.shop-item.unaffordable {
  opacity: 0.5;
  cursor: not-allowed;
}

.shop-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-item-icon {
  font-size: 26px;
}

.shop-item-name {
  font-weight: 800;
  font-size: 14px;
  color: var(--text-main);
}

.shop-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.shop-item-price {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold-bright);
}

.shop-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.shop-tip {
  font-size: 12px;
  color: var(--text-muted);
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 20px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(233, 160, 196, 0.25);
  border-radius: 10px;
  padding: 10px;
}

.stat-box span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 18px;
  color: var(--gold-bright);
}

.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

/* Footer */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 4px;
}

.controls-bar code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  color: #ffd6ea;
}

@media (max-width: 680px) {
  .arcade-frame {
    padding: 8px;
  }

  .hud-card {
    padding: 5px 8px;
    min-width: 78px;
  }

  .hud-value {
    font-size: 16px;
  }

  .legend-grid {
    grid-template-columns: 1fr;
  }

  .panel-card {
    padding: 16px;
  }

  .controls-bar {
    display: none;
  }
}

@media (max-width: 520px) {  body {
    padding: 6px;
  }

  .arcade-frame {
    padding: 6px;
    gap: 6px;
    border-radius: 14px;
  }

  .hud-card {
    min-width: 62px;
    padding: 4px 7px;
    flex: 1 1 auto;
  }

  .hud-value {
    font-size: 15px;
  }

  .hud-label {
    font-size: 10px;
  }

  .hud-progress-card {
    min-width: 0;
    flex: 1 1 100%;
  }

  .hud-btn {
    padding: 5px 9px;
    font-size: 13px;
  }

  .icon-btn {
    padding: 5px 9px;
  }

  .stage-wrap {
    border-radius: 10px;
    border-width: 1px;
  }

  .overlay-panel {
    padding: 8px;
  }

  .panel-card {
    padding: 12px;
    border-radius: 12px;
  }

  .legend-grid {
    gap: 6px;
  }

  .legend-item {
    padding: 7px 9px;
  }

  .controls-hint {
    font-size: 12px;
    gap: 8px;
    padding: 6px 8px;
  }

  .shop-grid {
    grid-template-columns: 1fr;
  }

  .shop-header h2 {
    font-size: 20px;
  }

  .stats-summary {
    gap: 6px;
  }

  .primary-btn {
    padding: 10px 20px;
    font-size: 15px;
  }

  /* 灏忓睆涓婂脊绐楀唴瀹规瘮 960:600 鐨勭敾甯冮珮锛岃瀹冧粠椤堕儴寮€濮嬪苟鍙互婊氬姩 */
  .overlay-panel {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .legend-grid,
  .controls-hint {
    display: none;
  }

  .game-title {
    font-size: 24px;
    margin-bottom: 4px;
  }

  .game-subtitle {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .badge-pill {
    margin-bottom: 6px;
    font-size: 11px;
  }

  .start-actions {
    gap: 8px;
  }

  .best-score-chip {
    padding: 8px 12px;
    font-size: 12px;
  }

  .shop-header {
    flex-direction: column;
    gap: 8px;
  }

  .shop-wallet {
    text-align: left;
    align-self: flex-start;
  }

  .shop-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-row {
    flex-direction: column;
  }

  .compact-card {
    max-width: none;
  }
}

/* 绔栧睆鎵嬫満鎻愮ず */
.rotate-hint {
  display: none;
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint {
    display: block;
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    z-index: 50;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(10, 6, 3, 0.82);
    border: 1px solid rgba(212, 155, 53, 0.55);
    color: #ffd6ea;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    animation: rotateHintFade 7s ease forwards;
  }
}

@keyframes rotateHintFade {
  0%, 65% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
