/* ============================================================
   小侠牌 (Little Hero Cards) - Stylesheet
   Theme: Chinese ink wash (水墨) + Modern minimalist
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
  --ink-black: #1a1a1a;
  --ink-dark: #2d2d2d;
  --ink-medium: #4a4a4a;
  --ink-light: #8a8a8a;
  --ink-faint: #c0c0c0;
  --paper: #f5f0e8;
  --paper-dark: #e8e0d0;
  --red-primary: #c0392b;
  --red-light: #e74c3c;
  --red-dark: #8e2318;
  --red-glow: rgba(192, 57, 43, 0.4);
  --black-card: #2c3e50;
  --black-glow: rgba(44, 62, 80, 0.4);
  --gold: #d4a935;
  --gold-light: #f0d060;
  --hp-red: #c0392b;
  --mp-blue: #2c3e50;
  --success-green: #27ae60;
  --font-title: 'Ma Shan Zheng', cursive;
  --font-body: 'Noto Sans SC', sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--ink-black);
  color: var(--paper);
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Screens ---- */
.screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ---- Main Menu ---- */
#mainMenu {
  background: linear-gradient(180deg, #0d0d0d 0%, #1a1511 50%, #0d0d0d 100%);
  position: relative; overflow: hidden;
}
#mainMenu .bg-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover; background-position: center;
  opacity: 0.3; filter: grayscale(30%);
}
#mainMenu .content { position: relative; z-index: 2; text-align: center; }
.game-title {
  font-family: var(--font-title);
  font-size: clamp(48px, 10vw, 96px);
  color: var(--paper);
  text-shadow: 0 0 40px rgba(192,57,43,0.5), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 12px;
  margin-bottom: 8px;
}
.game-subtitle {
  font-family: var(--font-body);
  font-size: clamp(12px, 2.5vw, 18px);
  color: var(--ink-light);
  letter-spacing: 4px;
  margin-bottom: 40px;
  font-weight: 300;
}
.menu-btn {
  display: block; margin: 12px auto;
  width: 220px; padding: 14px 0;
  background: transparent;
  border: 1px solid var(--ink-light);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.menu-btn::before {
  content: ''; position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(192,57,43,0.15), transparent);
  transition: left 0.5s ease;
}
.menu-btn:hover { border-color: var(--red-primary); color: var(--red-light); }
.menu-btn:hover::before { left: 100%; }
.menu-btn:active { transform: scale(0.97); }

/* ---- Character Select ---- */
#charSelect {
  background: linear-gradient(180deg, #0d0d0d, #1a1511);
}
.char-select-title {
  font-family: var(--font-title);
  font-size: 36px;
  margin-bottom: 30px;
  color: var(--paper);
  letter-spacing: 6px;
}
.char-grid {
  display: flex; gap: 20px;
  flex-wrap: wrap; justify-content: center;
  max-width: 800px;
}
.char-card {
  width: 200px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--ink-medium);
  border-radius: 8px; padding: 16px;
  cursor: pointer; transition: all 0.3s ease;
  text-align: center;
}
.char-card:hover { border-color: var(--gold); transform: translateY(-4px); }
.char-card.selected { border-color: var(--red-primary); box-shadow: 0 0 20px var(--red-glow); }
.char-portrait {
  width: 120px; height: 120px; border-radius: 50%;
  margin: 0 auto 12px; overflow: hidden;
  border: 2px solid var(--ink-medium);
  background: var(--ink-dark);
}
.char-portrait img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(20%);
}
.char-name {
  font-family: var(--font-title);
  font-size: 24px; margin-bottom: 6px;
}
.char-stats {
  font-size: 12px; color: var(--ink-light);
  line-height: 1.6;
}
.char-stats span.red { color: var(--red-primary); }
.char-stats span.dark { color: #7fb3d3; }

/* Difficulty selector */
.difficulty-row {
  display: flex; gap: 12px; margin: 20px 0;
  justify-content: center;
}
.diff-btn {
  padding: 8px 20px; background: transparent;
  border: 1px solid var(--ink-medium);
  color: var(--ink-light); font-family: var(--font-body);
  font-size: 13px; cursor: pointer;
  transition: all 0.3s ease; letter-spacing: 2px;
}
.diff-btn.selected { border-color: var(--gold); color: var(--gold); }
.diff-btn:hover { border-color: var(--ink-faint); }

.start-battle-btn {
  margin-top: 24px; padding: 14px 48px;
  background: var(--red-dark); border: 1px solid var(--red-primary);
  color: var(--paper); font-family: var(--font-title);
  font-size: 22px; letter-spacing: 4px;
  cursor: pointer; transition: all 0.3s ease;
}
.start-battle-btn:hover { background: var(--red-primary); }
.start-battle-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- Deck Config ---- */
#deckConfig {
  background: linear-gradient(180deg, #0d0d0d, #1a1511);
  padding: 20px;
}
.deck-section { margin: 16px 0; width: 100%; max-width: 600px; }
.deck-section h3 {
  font-family: var(--font-title); font-size: 22px;
  margin-bottom: 10px; color: var(--gold);
}
.deck-items { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Battle Screen ---- */
#battleScreen {
  background: var(--ink-black);
  flex-direction: column;
  position: relative;
}
.battle-bg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover; background-position: center;
  opacity: 0.2; filter: grayscale(40%);
}

/* Top bar: enemy info */
.player-bar {
  width: 100%; padding: 8px 16px;
  display: flex; align-items: center; gap: 12px;
  position: relative; z-index: 10;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.player-bar.enemy { border-bottom: 1px solid rgba(255,255,255,0.06); }
.player-bar.self { border-top: 1px solid rgba(255,255,255,0.06); }

.bar-portrait {
  width: 48px; height: 48px; border-radius: 50%;
  overflow: hidden; border: 2px solid var(--ink-medium);
  flex-shrink: 0;
}
.bar-portrait img { width: 100%; height: 100%; object-fit: cover; }
.bar-portrait.active-turn { border-color: var(--gold); box-shadow: 0 0 12px rgba(212,169,53,0.5); }
.bar-info { flex: 1; }
.bar-name { font-family: var(--font-title); font-size: 18px; }
.bar-hp, .bar-mp { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.hp-bar-container, .mp-bar-container {
  flex: 1; height: 10px; background: rgba(255,255,255,0.08);
  border-radius: 5px; overflow: hidden; max-width: 200px;
}
.hp-bar-fill {
  height: 100%; background: linear-gradient(90deg, #8e2318, var(--red-primary));
  border-radius: 5px; transition: width 0.5s ease;
}
.mp-bar-fill {
  height: 100%; background: linear-gradient(90deg, #1a2530, #2c3e50);
  border-radius: 5px; transition: width 0.5s ease;
}
.bar-label { font-size: 11px; color: var(--ink-light); min-width: 30px; }
.bar-value { font-size: 11px; min-width: 40px; text-align: right; }

.bar-extras { display: flex; gap: 8px; align-items: center; }
.hand-count {
  font-size: 11px; color: var(--ink-light);
  background: rgba(255,255,255,0.05); padding: 2px 8px;
  border-radius: 3px;
}
.buff-icons { display: flex; gap: 4px; }
.buff-icon {
  font-size: 10px; padding: 2px 6px;
  background: rgba(192,57,43,0.2); border-radius: 3px;
  color: var(--red-light);
}

/* Middle: zones */
.battle-middle {
  flex: 1; width: 100%; position: relative; z-index: 5;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  overflow: hidden;
}

/* Enemy hand (face down) */
.enemy-hand {
  display: flex; justify-content: center; gap: -8px;
  padding: 4px;
}
.enemy-card-back {
  width: 36px; height: 50px;
  border-radius: 4px; border: 1px solid var(--ink-medium);
  background-size: cover; background-position: center;
  margin: 0 -4px;
}

/* Zones row */
.zones-row {
  display: flex; justify-content: space-between;
  align-items: stretch; gap: 6px;
  padding: 6px 4px;
}
.zone {
  flex: 1; min-height: 90px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 6px; padding: 8px 6px 6px;
  position: relative;
}
.zone-label {
  position: absolute; top: -10px; left: 8px;
  font-size: 10px; color: var(--ink-light);
  background: var(--ink-black); padding: 0 4px;
  letter-spacing: 1px;
}
.zone-cards {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 54px; padding-top: 2px;
}
.zone-card-mini {
  width: 38px; height: 52px;
  border-radius: 4px; font-size: 9px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 1px solid;
  line-height: 1.2; gap: 2px;
  cursor: default;
  transition: all 0.15s ease;
}
.zone-card-mini.red { border-color: var(--red-primary); color: var(--red-primary); background: rgba(192,57,43,0.1); }
.zone-card-mini.black { border-color: #5a7a9a; color: #7fb3d3; background: rgba(44,62,80,0.15); }
.zone-card-mini .mini-type { font-size: 12px; }
.zone-card-mini .mini-num { font-weight: 700; font-size: 12px; }
.zone-card-mini .mini-type-img { width: 16px; height: 16px; }

/* Selectable zone cards (for skill consumption / danuoyi) */
.zone-card-mini.selectable { cursor: pointer; }
.zone-card-mini.selectable:hover { transform: translateY(-3px); box-shadow: 0 3px 10px rgba(212,169,53,0.3); }
.zone-card-mini.zone-selected {
  border-color: var(--gold) !important;
  box-shadow: 0 0 12px rgba(212,169,53,0.5);
  transform: translateY(-4px);
}

.zone.public-zone { border-color: rgba(212,169,53,0.2); }

/* Action log */
.log-area {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 180px; max-height: 200px;
  overflow-y: auto; z-index: 20;
  background: rgba(0,0,0,0.7); border-radius: 6px;
  padding: 8px; border: 1px solid rgba(255,255,255,0.05);
}
.log-entry {
  font-size: 11px; color: var(--ink-light);
  padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.03);
  line-height: 1.4;
}
.log-entry:last-child { border-bottom: none; }
.log-entry.important { color: var(--red-light); }

/* Player hand */
.hand-area {
  position: relative; z-index: 15;
  display: flex; justify-content: center;
  gap: 4px; padding: 4px 8px;
  min-height: 110px; align-items: flex-end;
}
.game-card {
  width: 72px; height: 104px;
  border-radius: 6px; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 5px 4px;
  border: 2px solid;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--paper);
}
.game-card .card-art {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover; background-position: center;
  opacity: 0.2; pointer-events: none;
  transition: opacity 0.3s ease;
}
.game-card:hover .card-art { opacity: 0.35; }
.game-card.selected .card-art { opacity: 0.3; }
.game-card .card-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  width: 100%; height: 100%;
}
.game-card.red {
  border-color: var(--red-primary);
  color: var(--red-dark);
  background: linear-gradient(160deg, #fdf6f0 0%, #f5e6df 50%, #f0d8cf 100%);
}
.game-card.black {
  border-color: var(--black-card);
  color: var(--black-card);
  background: linear-gradient(160deg, #eef2f7 0%, #dce4ed 50%, #cdd8e5 100%);
}
.game-card:hover {
  transform: translateY(-14px) scale(1.05);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 20;
}
.game-card.selected {
  transform: translateY(-22px) scale(1.08);
  box-shadow: 0 0 24px var(--gold-light), 0 12px 30px rgba(0,0,0,0.4);
  border-color: var(--gold);
}
.game-card.highlight {
  animation: cardGlow 1s ease-in-out infinite;
}
@keyframes cardGlow {
  0%, 100% { box-shadow: 0 0 8px var(--gold-light); }
  50% { box-shadow: 0 0 24px var(--gold-light); }
}
.card-number-top {
  font-size: 16px; font-weight: 700;
  align-self: flex-start;
  text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}
/* Card type icon as image (SVG with black fill, colorized via CSS filter) */
.type-icon-img {
  width: 28px; height: 28px;
  object-fit: contain;
}
.game-card.red .type-icon-img {
  filter: invert(17%) sepia(74%) saturate(3284%) hue-rotate(347deg) brightness(83%) contrast(89%);
}
.game-card.black .type-icon-img {
  filter: invert(20%) sepia(15%) saturate(1486%) hue-rotate(169deg) brightness(96%) contrast(89%);
}

/* Mini zone card type icon */
.mini-type-img {
  width: 16px; height: 16px;
  object-fit: contain;
}
.zone-card-mini.red .mini-type-img {
  filter: invert(17%) sepia(74%) saturate(3284%) hue-rotate(347deg) brightness(83%) contrast(89%);
}
.zone-card-mini.black .mini-type-img {
  filter: invert(20%) sepia(15%) saturate(1486%) hue-rotate(169deg) brightness(96%) contrast(89%);
}

/* Combo glow on eligible cards */
.game-card.combo-glow {
  animation: comboGlow 0.8s ease-in-out infinite;
  border-color: var(--gold) !important;
}
@keyframes comboGlow {
  0%, 100% { box-shadow: 0 0 8px var(--gold-light), 0 0 16px rgba(212,169,53,0.3); }
  50% { box-shadow: 0 0 20px var(--gold-light), 0 0 40px rgba(212,169,53,0.5); }
}

/* Combo indicator text */
.combo-indicator {
  position: fixed; bottom: 200px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 24px; color: var(--gold);
  text-shadow: 0 0 20px rgba(212,169,53,0.6);
  z-index: 50; pointer-events: none;
  animation: comboFloat 1s ease-in-out infinite;
}
@keyframes comboFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

.card-type-icon {
  font-size: 28px; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}
.card-type-name {
  font-size: 10px; letter-spacing: 2px;
  font-family: var(--font-title);
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
}
.card-number-bottom {
  font-size: 16px; font-weight: 700;
  align-self: flex-end;
  transform: rotate(180deg);
  text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

/* --- Card Attack Impact Animations --- */
.game-card.card-fly-out {
  animation: cardFlyOut 0.5s cubic-bezier(0.55, 0, 0.1, 1) forwards;
}
@keyframes cardFlyOut {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  40% { transform: translateY(-60px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-200px) scale(0.3); opacity: 0; }
}

/* Screen shake */
.screen-shake {
  animation: screenShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-6px, -3px); }
  20% { transform: translate(5px, 4px); }
  30% { transform: translate(-4px, 2px); }
  40% { transform: translate(3px, -4px); }
  50% { transform: translate(-3px, 3px); }
  60% { transform: translate(4px, -2px); }
  70% { transform: translate(-2px, 3px); }
  80% { transform: translate(3px, -1px); }
  90% { transform: translate(-1px, 2px); }
}

/* Impact flash */
.impact-flash {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 180;
  opacity: 0;
}
.impact-flash.hp-flash {
  background: radial-gradient(circle at 50% 20%, rgba(192,57,43,0.5), transparent 70%);
  animation: impactFlash 0.4s ease-out forwards;
}
.impact-flash.mp-flash {
  background: radial-gradient(circle at 50% 20%, rgba(44,62,80,0.5), transparent 70%);
  animation: impactFlash 0.4s ease-out forwards;
}
.impact-flash.self-hp-flash {
  background: radial-gradient(circle at 50% 80%, rgba(192,57,43,0.5), transparent 70%);
  animation: impactFlash 0.4s ease-out forwards;
}
.impact-flash.self-mp-flash {
  background: radial-gradient(circle at 50% 80%, rgba(44,62,80,0.5), transparent 70%);
  animation: impactFlash 0.4s ease-out forwards;
}
@keyframes impactFlash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Ink burst particle effect */
.ink-burst {
  position: fixed; pointer-events: none; z-index: 170;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--paper);
}
.ink-burst.red { background: var(--red-primary); }
.ink-burst.dark { background: var(--black-card); }
.ink-burst.animate {
  animation: inkBurst 0.6s ease-out forwards;
}
@keyframes inkBurst {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* Action buttons */
.action-bar {
  display: flex; gap: 8px;
  justify-content: center; padding: 8px;
  position: relative; z-index: 15;
  flex-wrap: wrap;
}
.action-btn {
  padding: 8px 16px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--ink-medium); color: var(--paper);
  font-family: var(--font-body); font-size: 12px;
  letter-spacing: 1px; cursor: pointer;
  transition: all 0.2s ease; border-radius: 4px;
}
.action-btn:hover { border-color: var(--gold); color: var(--gold); }
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.action-btn.primary {
  background: var(--red-dark); border-color: var(--red-primary);
}
.action-btn.primary:hover { background: var(--red-primary); }

/* Response overlay */
.response-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.response-overlay.active { display: flex; }
.response-title {
  font-family: var(--font-title);
  font-size: 28px; margin-bottom: 20px;
  color: var(--gold);
}
.response-attack-card {
  width: 80px; height: 110px;
  margin-bottom: 20px;
}
.response-options {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; max-width: 500px;
}
.response-option {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  cursor: pointer; transition: all 0.2s ease;
  padding: 10px; border: 1px solid var(--ink-medium);
  border-radius: 6px;
}
.response-option:hover { border-color: var(--gold); transform: scale(1.05); }
.response-label {
  font-family: var(--font-title);
  font-size: 16px; color: var(--gold);
}
.response-skip {
  margin-top: 16px; padding: 10px 30px;
  background: transparent; border: 1px solid var(--ink-medium);
  color: var(--ink-light); cursor: pointer;
  font-family: var(--font-body); font-size: 13px;
}
.response-skip:hover { border-color: var(--red-primary); color: var(--red-light); }

.response-timer {
  font-size: 24px; color: var(--red-primary);
  font-family: var(--font-title); margin-top: 12px;
}

/* Skill/Item panels */
.side-panel {
  position: absolute; z-index: 30;
  background: rgba(0,0,0,0.9); border: 1px solid var(--ink-medium);
  border-radius: 8px; padding: 12px;
  display: none; min-width: 200px;
  backdrop-filter: blur(8px);
}
.side-panel.active { display: block; }
.side-panel h4 {
  font-family: var(--font-title); font-size: 18px;
  color: var(--gold); margin-bottom: 10px;
}
.panel-item {
  padding: 8px; margin: 4px 0;
  border: 1px solid var(--ink-medium);
  border-radius: 4px; cursor: pointer;
  transition: all 0.2s ease;
  display: flex; gap: 10px; align-items: center;
}
.panel-item:hover { border-color: var(--gold); background: rgba(212,169,53,0.06); }
.panel-item .p-icon {
  width: 40px; height: 40px; border-radius: 6px;
  overflow: hidden; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--ink-dark);
}
.panel-item .p-icon img {
  width: 100%; height: 100%; object-fit: cover;
}
.panel-item .p-info { flex: 1; }
.panel-item .p-name { font-weight: 500; font-size: 14px; }
.panel-item .p-cost { font-size: 11px; color: var(--red-light); margin-top: 2px; }
.panel-item .p-desc { font-size: 11px; color: var(--ink-light); margin-top: 4px; line-height: 1.4; }

/* Deck config item with icon */
.deck-item {
  padding: 10px 14px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--ink-medium); border-radius: 6px;
  font-size: 13px; cursor: pointer; transition: all 0.2s ease;
  display: flex; gap: 10px; align-items: center;
  max-width: 280px;
}
.deck-item:hover { border-color: var(--ink-faint); background: rgba(255,255,255,0.08); }
.deck-item.selected { border-color: var(--gold); color: var(--gold); background: rgba(212,169,53,0.08); }
.deck-item.disabled { opacity: 0.3; cursor: not-allowed; }
.deck-item .deck-icon {
  width: 36px; height: 36px; border-radius: 5px;
  overflow: hidden; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--ink-dark);
}
.deck-item .deck-icon img { width: 100%; height: 100%; object-fit: cover; }
.deck-item .deck-info { flex: 1; }
.deck-item .item-name { font-weight: 500; }
.deck-item .item-desc { font-size: 11px; color: var(--ink-light); margin-top: 4px; line-height: 1.3; }
.turn-announce {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-size: 48px; color: var(--gold);
  text-shadow: 0 0 40px rgba(212,169,53,0.5);
  z-index: 200; pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease;
}
.turn-announce.show {
  opacity: 1;
  animation: announceIn 1.5s ease forwards;
}
@keyframes announceIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Damage popup */
.damage-popup {
  position: fixed; z-index: 200;
  font-family: var(--font-title);
  font-size: 36px; pointer-events: none;
  animation: dmgFloat 1.2s ease forwards;
}
.damage-popup.hp { color: var(--red-primary); }
.damage-popup.mp { color: #3498db; }
.damage-popup.heal { color: var(--success-green); }
@keyframes dmgFloat {
  0% { opacity: 1; transform: translateY(0) scale(1.2); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* Game over overlay */
.game-over-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 300;
  backdrop-filter: blur(8px);
}
.game-over-overlay.active { display: flex; }
.game-over-text {
  font-family: var(--font-title);
  font-size: 64px; margin-bottom: 12px;
}
.game-over-text.win { color: var(--gold); }
.game-over-text.lose { color: var(--red-primary); }
.game-over-detail {
  font-size: 16px; color: var(--ink-light);
  margin-bottom: 30px;
}

/* Ink splash effect */
.ink-splash {
  position: fixed; pointer-events: none;
  z-index: 150; opacity: 0;
  font-family: var(--font-title);
  font-size: 72px; color: var(--paper);
  text-shadow: 0 0 30px rgba(245,240,232,0.5);
}
.ink-splash.show {
  animation: inkSplash 1s ease forwards;
}
@keyframes inkSplash {
  0% { opacity: 0; transform: scale(2) rotate(-10deg); }
  30% { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(0.8) translateY(-20px); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-medium); border-radius: 2px; }

/* Responsive */
@media (max-width: 600px) {
  .game-card { width: 58px; height: 84px; }
  .card-number-top, .card-number-bottom { font-size: 12px; }
  .card-type-icon { font-size: 22px; }
  .card-type-name { font-size: 8px; }
  .log-area { display: none; }
  .char-card { width: 160px; }
  .hand-area { gap: 2px; }
  .deck-item { max-width: 100%; }
  .zone-card-mini { width: 32px; height: 44px; }
  .zone-card-mini .mini-num { font-size: 10px; }
  .zone-card-mini .mini-type-img { width: 13px; height: 13px; }
}

/* ---- Skill Consume / Danuoyi / Value Picker Overlay ---- */
.modal-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.75);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 110;
  backdrop-filter: blur(4px);
}
.modal-overlay .modal-title {
  font-family: var(--font-title);
  font-size: 26px; color: var(--gold);
  margin-bottom: 8px; letter-spacing: 3px;
}
.modal-overlay .modal-subtitle {
  font-size: 13px; color: var(--ink-faint);
  margin-bottom: 16px; text-align: center;
  line-height: 1.6;
}
.modal-overlay .modal-cards {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; max-width: 400px;
  margin-bottom: 16px;
}
.modal-overlay .modal-card {
  width: 50px; height: 68px;
  border-radius: 5px; font-size: 10px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 2px solid; cursor: pointer;
  transition: all 0.15s ease; gap: 2px;
}
.modal-overlay .modal-card.red { border-color: var(--red-primary); color: var(--red-primary); background: rgba(192,57,43,0.12); }
.modal-overlay .modal-card.black { border-color: #5a7a9a; color: #7fb3d3; background: rgba(44,62,80,0.18); }
.modal-overlay .modal-card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(212,169,53,0.3); }
.modal-overlay .modal-card.modal-selected {
  border-color: var(--gold) !important;
  box-shadow: 0 0 16px rgba(212,169,53,0.5);
  transform: translateY(-6px);
}
.modal-overlay .modal-card .mc-type-img { width: 18px; height: 18px; object-fit: contain; }
.modal-overlay .modal-card.red .mc-type-img {
  filter: invert(17%) sepia(74%) saturate(3284%) hue-rotate(347deg) brightness(83%) contrast(89%);
}
.modal-overlay .modal-card.black .mc-type-img {
  filter: invert(20%) sepia(15%) saturate(1486%) hue-rotate(169deg) brightness(96%) contrast(89%);
}
.modal-overlay .modal-card .mc-num { font-weight: 700; font-size: 14px; }
.modal-overlay .modal-info {
  font-size: 13px; color: var(--gold-light);
  margin-bottom: 12px;
}
.modal-overlay .modal-btns {
  display: flex; gap: 12px;
}
.modal-overlay .modal-btn {
  padding: 10px 28px;
  font-family: var(--font-title);
  font-size: 18px; letter-spacing: 3px;
  cursor: pointer; transition: all 0.2s ease;
  border-radius: 4px;
}
.modal-overlay .modal-btn.confirm {
  background: var(--red-dark); border: 1px solid var(--red-primary);
  color: var(--paper);
}
.modal-overlay .modal-btn.confirm:hover { background: var(--red-primary); }
.modal-overlay .modal-btn.confirm:disabled { opacity: 0.3; cursor: not-allowed; }
.modal-overlay .modal-btn.cancel {
  background: transparent; border: 1px solid var(--ink-medium);
  color: var(--ink-light);
}
.modal-overlay .modal-btn.cancel:hover { border-color: var(--ink-faint); color: var(--paper); }

/* Value picker (1-9 grid) */
.modal-overlay .value-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.modal-overlay .value-btn {
  width: 56px; height: 56px;
  border-radius: 6px; font-family: var(--font-title);
  font-size: 28px; cursor: pointer;
  border: 2px solid var(--ink-medium);
  background: rgba(255,255,255,0.04);
  color: var(--paper);
  transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay .value-btn:hover { border-color: var(--gold); color: var(--gold); transform: scale(1.08); }
.modal-overlay .value-btn.value-selected {
  border-color: var(--gold); color: var(--gold);
  background: rgba(212,169,53,0.15);
  box-shadow: 0 0 16px rgba(212,169,53,0.4);
  transform: scale(1.1);
}

/* Danuoyi move direction buttons */
.modal-overlay .move-row {
  display: flex; gap: 12px; align-items: center;
  margin: 8px 0;
}
.modal-overlay .move-zone-label {
  font-size: 12px; color: var(--ink-faint);
  min-width: 80px; text-align: center;
}
.modal-overlay .move-arrow {
  font-size: 20px; cursor: pointer;
  color: var(--gold); padding: 6px 14px;
  border: 1px solid var(--ink-medium);
  border-radius: 4px; transition: all 0.15s ease;
  background: rgba(255,255,255,0.03);
}
.modal-overlay .move-arrow:hover { border-color: var(--gold); background: rgba(212,169,53,0.1); }
.modal-overlay .move-arrow:disabled { opacity: 0.2; cursor: not-allowed; }

/* ---- Rules Screen ---- */
#rulesScreen {
  background: linear-gradient(180deg, #0d0d0d, #1a1511);
}
.rules-content {
  max-width: 700px; width: 100%;
  padding: 0 16px;
}
.rules-section {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
}
.rules-section h3 {
  font-family: var(--font-title);
  font-size: 22px; color: var(--gold);
  margin-bottom: 10px; letter-spacing: 2px;
}
.rules-section p {
  font-size: 13px; color: var(--ink-faint);
  line-height: 1.8; margin: 6px 0;
}
.rules-section .r { color: var(--hp-red); font-weight: 500; }
.rules-section .b { color: #7fb3d3; font-weight: 500; }
.rules-table {
  margin: 10px 0; border: 1px solid var(--ink-medium);
  border-radius: 6px; overflow: hidden;
}
.rules-row {
  display: flex; gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.rules-row:last-child { border-bottom: none; }
.rules-row span {
  flex: 1; padding: 8px 12px;
  font-size: 12px; color: var(--ink-faint);
  border-right: 1px solid rgba(255,255,255,0.04);
}
.rules-row span:last-child { border-right: none; }
.rules-row.header {
  background: rgba(212,169,53,0.08);
}
.rules-row.header span {
  color: var(--gold); font-weight: 500; font-size: 13px;
}

/* ---- Tutorial Overlay ---- */
.tutorial-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.65);
  z-index: 500;
  pointer-events: auto;
  transition: clip-path 0.3s ease;
}
.tutorial-highlighted {
  position: relative;
  z-index: 510 !important;
  pointer-events: auto !important;
}

/* Tutorial tooltip */
.tutorial-tooltip {
  position: fixed; z-index: 520;
  background: linear-gradient(135deg, #1c1815 0%, #252018 100%);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 420px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 20px rgba(212,169,53,0.15);
  display: none;
}
.tutorial-tooltip.pos-center {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.tutorial-tooltip.pos-top {
  top: 12%; left: 50%;
  transform: translateX(-50%);
}
.tutorial-tooltip.pos-bottom {
  bottom: 12%; left: 50%;
  transform: translateX(-50%);
}
.tutorial-title {
  font-family: var(--font-title);
  font-size: 26px; color: var(--gold);
  margin-bottom: 12px; letter-spacing: 3px;
}
.tutorial-text {
  font-size: 13px; color: var(--paper);
  line-height: 1.8; margin-bottom: 16px;
}
.tutorial-hint {
  font-size: 13px; color: var(--gold-light);
  font-style: italic;
  animation: hintPulse 1.5s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.tutorial-actions {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap;
}
.tutorial-next-btn {
  padding: 10px 28px;
  background: var(--red-dark); border: 1px solid var(--red-primary);
  color: var(--paper); font-family: var(--font-title);
  font-size: 18px; letter-spacing: 3px;
  cursor: pointer; transition: all 0.2s ease;
  border-radius: 4px;
}
.tutorial-next-btn:hover { background: var(--red-primary); }
.tutorial-skip-btn {
  padding: 8px 16px;
  background: transparent; border: 1px solid var(--ink-medium);
  color: var(--ink-light); font-family: var(--font-body);
  font-size: 12px; cursor: pointer;
  transition: all 0.2s ease; border-radius: 4px;
}
.tutorial-skip-btn:hover { border-color: var(--ink-faint); color: var(--paper); }
.tutorial-progress {
  margin-top: 10px;
  font-size: 11px; color: var(--ink-light);
  letter-spacing: 1px;
}
