/* Calabash Brothers: Chinese Paper-cut Shadow Magic Tower Style */

:root {
  --color-paper-bg: #1c1614;
  --color-paper-card: #271e1b;
  --color-cinnabar: #b83b3b;
  --color-cinnabar-dark: #822222;
  --color-gold: #d4af37;
  --color-gold-light: #f39c12;
  --color-border: #44322b;
  --color-text-main: #f5eedb;
  --color-text-sub: #bcaaa4;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background-color: var(--color-paper-bg);
  color: var(--color-text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif SC", sans-serif;
}

/* Background Paper Cutwork Decor */
body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-radial-gradient: circle at 50% 50%, rgba(184, 59, 59, 0.08) 0%, rgba(20, 15, 13, 0.95) 100%;
  pointer-events: none;
  z-index: 0;
}

#gameApp {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
}

/* --- Top Header & HUD --- */
.game-header {
  width: 100%;
  max-width: 600px;
  background: linear-gradient(180deg, #2f211c 0%, #201714 100%);
  border-bottom: 2px solid var(--color-gold);
  padding: 6px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.floor-badge {
  font-size: 14px;
  font-weight: bold;
  color: var(--color-gold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: #3e2d26;
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--color-cinnabar);
}

/* Stats Row */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  gap: 6px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-hp { color: #ff7675; font-weight: bold; }
.stat-sp { color: #00cec9; font-weight: bold; }
.stat-atk { color: #e17055; }
.stat-def { color: #74b9ff; }
.stat-gold { color: #f1c40f; }
.stat-exp { color: #a29bfe; }

.keys-container {
  display: flex;
  gap: 6px;
}
.key-badge {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
}
.key-y { color: #f1c40f; }
.key-b { color: #3498db; }
.key-r { color: #e74c3c; }

/* Active Leader Banner */
.active-leader-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #34241e;
  border: 1px dashed var(--color-gold);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 12px;
}

.leader-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

#leaderAvatar {
  font-size: 18px;
}

#leaderName {
  font-weight: bold;
  color: var(--color-gold-light);
}

.leader-skill-info {
  color: #dfe6e9;
  font-size: 11px;
}

/* --- Canvas Area --- */
.canvas-wrapper {
  flex: 1;
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 4px;
}

#gameCanvas {
  background-color: #1a1412;
  border: 3px solid var(--color-gold);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: block;
}

/* --- Mobile Controls & Bottom Switch Bar --- */
.game-controls {
  width: 100%;
  max-width: 600px;
  background: linear-gradient(180deg, #201714 0%, #150f0d 100%);
  border-top: 2px solid var(--color-gold);
  padding: 6px 10px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Brothers Quick Switch Bar */
.brothers-bar {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
}

.brother-tab {
  flex: 1;
  min-width: 0;
  background: #2c1f1a;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.brother-tab .bro-num {
  font-size: 10px;
  color: var(--color-text-sub);
}

.brother-tab .bro-icon {
  font-size: 15px;
  margin: 1px 0;
}

.brother-tab .bro-name {
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}

.brother-tab.locked {
  opacity: 0.35;
  filter: grayscale(80%);
}

.brother-tab.locked::after {
  content: "🔒";
  position: absolute;
  font-size: 10px;
  top: 2px;
  right: 2px;
}

.brother-tab.active {
  border: 2px solid var(--color-gold);
  background: #4a2f24;
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
}

.brother-tab:active {
  transform: scale(0.95);
}

/* Lower Controls: Virtual D-Pad + Skill Button */
.lower-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

/* Virtual D-Pad */
.dpad-container {
  position: relative;
  width: 120px;
  height: 120px;
}

.dpad-btn {
  position: absolute;
  width: 38px;
  height: 38px;
  background: #3c2a23;
  border: 2px solid var(--color-gold);
  color: var(--color-gold);
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
  transition: background 0.1s, transform 0.1s;
}

.dpad-btn:active {
  background: var(--color-cinnabar);
  color: #fff;
  transform: scale(0.92);
}

.dpad-up    { top: 0; left: 41px; }
.dpad-down  { bottom: 0; left: 41px; }
.dpad-left  { top: 41px; left: 0; }
.dpad-right { top: 41px; right: 0; }
.dpad-center {
  position: absolute;
  top: 41px;
  left: 41px;
  width: 38px;
  height: 38px;
  background: #251a15;
  border-radius: 6px;
}

/* Action Trigger Area */
.actions-container {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-big-skill {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #e74c3c 0%, #962d22 100%);
  border: 3px solid var(--color-gold);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.5);
  transition: all 0.12s;
}

.btn-big-skill .skill-ico {
  font-size: 26px;
}

.btn-big-skill span {
  font-size: 12px;
  font-weight: bold;
  margin-top: 2px;
}

.btn-big-skill:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

/* Modals & Overlays */
.overlay-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.overlay-modal.hidden {
  display: none !important;
}

.dialogue-card {
  width: 100%;
  max-width: 500px;
  background: #2c1e19;
  border: 2px solid var(--color-gold);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialogue-speaker {
  font-size: 16px;
  font-weight: bold;
  color: var(--color-gold);
  border-bottom: 1px dashed var(--color-border);
  padding-bottom: 4px;
}

.dialogue-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-main);
  min-height: 48px;
}

.dialogue-hint {
  align-self: flex-end;
  font-size: 11px;
  color: var(--color-gold-light);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* Altar / Upgrade Modal */
.altar-card {
  width: 100%;
  max-width: 420px;
  background: #251a16;
  border: 2px solid var(--color-gold);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.altar-title {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: var(--color-gold);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}

.altar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.altar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #33241e;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.altar-btn {
  background: var(--color-cinnabar);
  border: 1px solid var(--color-gold);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.altar-btn:active {
  transform: scale(0.95);
}

.close-btn {
  background: #3e2d26;
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
}

/* Victory Screen */
.victory-card {
  width: 100%;
  max-width: 450px;
  background: #2b1a15;
  border: 3px solid var(--color-gold);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.victory-title {
  font-size: 22px;
  font-weight: bold;
  color: var(--color-gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.victory-summary {
  font-size: 14px;
  line-height: 1.6;
  color: #dfe6e9;
}

.victory-stats {
  display: flex;
  justify-content: space-around;
  width: 100%;
  background: #3b2820;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
}

.btn-restart-game {
  background: linear-gradient(180deg, #d4af37 0%, #b7950b 100%);
  color: #1a1412;
  font-weight: bold;
  font-size: 15px;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
