/* ============================================
   提瓦特向量冒险 - 原神主题样式
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input { font-family: inherit; }

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #0B0E14;
  --bg-secondary: #1A1D2E;
  --bg-panel: rgba(20, 24, 40, 0.9);
  --bg-panel-solid: #141828;
  --text-primary: #ECE5D8;
  --text-secondary: #A69882;
  --text-dim: #6B6157;
  --accent-gold: #E2AC53;
  --accent-gold-bright: #FFD700;
  --accent-gold-dark: #C8963E;
  --border-gold: rgba(226, 172, 83, 0.35);
  --border-light: rgba(236, 229, 216, 0.1);
  --correct-green: #6FCF97;
  --wrong-red: #EB5757;
  --shadow-glow: 0 0 20px rgba(226, 172, 83, 0.2);
  --shadow-panel: 0 8px 32px rgba(0,0,0,0.5);

  /* Element colors */
  --anemo: #74C2A8;
  --geo: #FFB13F;
  --electro: #B08FC2;
  --dendro: #A5C83B;
  --cryo: #9EE0F0;
  --pyro: #EF7938;
  --hydro: #4CC2F1;
  --celestia: #E8D5B7;

  /* Nation gradients */
  --grad-mondstadt: linear-gradient(180deg, #2a5a3a 0%, #152e22 100%);
  --grad-liyue: linear-gradient(180deg, #4a4528 0%, #2a2510 100%);
  --grad-inazuma: linear-gradient(180deg, #3e2255 0%, #251240 100%);
  --grad-sumeru: linear-gradient(180deg, #2a4a2a 0%, #152a15 100%);
  --grad-fontaine: linear-gradient(180deg, #1a3a5a 0%, #0f2040 100%);
  --grad-natlan: linear-gradient(180deg, #5a2a1a 0%, #3a1510 100%);
  --grad-nodelkale: linear-gradient(180deg, #3a2a4a 0%, #201530 100%);
  --grad-snezhnaya: linear-gradient(180deg, #2a4a6a 0%, #152a45 100%);

  /* Spacing */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-round: 50%;
}

/* --- App Container --- */
#app {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

/* --- Landscape Warning --- */
#landscape-warning {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: var(--bg-primary);
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.landscape-content { text-align: center; color: var(--text-primary); }
.rotate-icon { font-size: 48px; animation: rotateHint 2s infinite; margin-bottom: var(--sp-md); }
@keyframes rotateHint { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }
@media (orientation: landscape) and (max-height: 500px) {
  #landscape-warning { display: flex; }
}

/* --- Screen Base --- */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.screen-active { display: flex; }

/* Screen Transitions */
.screen.screen-enter-slide-left { animation: slideInRight .35s ease-out forwards; pointer-events: none; }
.screen.screen-exit-slide-left { animation: slideOutLeft .35s ease-in forwards; pointer-events: none; }
.screen.screen-enter-slide-right { animation: slideInLeft .35s ease-out forwards; pointer-events: none; }
.screen.screen-exit-slide-right { animation: slideOutRight .35s ease-in forwards; pointer-events: none; }
.screen.screen-enter-fade { animation: fadeIn .3s ease-out forwards; pointer-events: none; }
.screen.screen-exit-fade { animation: fadeOut .3s ease-in forwards; pointer-events: none; }

@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideOutLeft { from { transform: translateX(0); } to { transform: translateX(-30%); opacity: 0.5; } }
@keyframes slideInLeft { from { transform: translateX(-30%); opacity: 0.5; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Panel --- */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  box-shadow: var(--shadow-glow);
}

/* --- Buttons --- */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-dark) 100%);
  color: #1A1D2E;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  min-height: 48px;
  font-size: 16px;
  letter-spacing: 1px;
  box-shadow: 0 4px 15px rgba(226, 172, 83, 0.3);
  transition: transform .1s, box-shadow .1s;
  text-align: center;
}
.btn-primary:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(226, 172, 83, 0.2); }
.btn-primary:disabled { opacity: 0.4; pointer-events: none; }

.btn-secondary {
  background: transparent;
  color: var(--accent-gold);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s;
}
.btn-secondary:active { background: rgba(226, 172, 83, 0.1); }

.btn-text {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-danger {
  background: rgba(235, 87, 87, 0.15);
  color: var(--wrong-red);
  border: 1px solid rgba(235, 87, 87, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  min-height: 48px;
  font-size: 15px;
  width: 100%;
  margin-bottom: var(--sp-sm);
}

.btn-full { width: 100%; }
.btn-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border-radius: var(--radius-round);
  background: rgba(255,255,255,0.05);
}
.btn-icon:active { background: rgba(255,255,255,0.1); }

/* --- Splash Screen --- */
#screen-splash {
  background: var(--bg-primary);
  justify-content: center;
  align-items: center;
  position: relative;
}
.splash-particles {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  overflow: hidden; pointer-events: none;
}
.splash-particle {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--accent-gold);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 4s infinite;
}
@keyframes particleFloat {
  0% { opacity: 0; transform: translateY(0) scale(0); }
  20% { opacity: 0.8; transform: translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateY(-120px) scale(0.3); }
}
.splash-content {
  text-align: center;
  z-index: 1;
  animation: splashAppear 1.2s ease-out;
}
@keyframes splashAppear {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash-icon {
  font-size: 56px;
  color: var(--accent-gold-bright);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  animation: iconPulse 2s infinite;
  margin-bottom: var(--sp-md);
}
@keyframes iconPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}
.splash-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 4px;
  margin-bottom: var(--sp-xs);
}
.splash-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 3px;
  margin-bottom: var(--sp-2xl);
}
.splash-tap {
  font-size: 14px;
  color: var(--text-dim);
  animation: tapPulse 2s infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- Character Select --- */
#screen-character-select {
  background: var(--bg-primary);
  padding: var(--sp-lg);
  padding-top: calc(var(--safe-top) + var(--sp-lg));
  padding-bottom: calc(var(--safe-bottom) + var(--sp-lg));
}
.screen-header { text-align: center; margin-bottom: var(--sp-lg); }
.screen-title {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-xs);
}
.screen-desc { font-size: 13px; color: var(--text-secondary); }

.char-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}
.char-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  text-align: center;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.char-card:active { transform: scale(0.97); }
.char-card.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(226, 172, 83, 0.3), inset 0 0 20px rgba(226, 172, 83, 0.05);
}
.char-card-emoji { font-size: 42px; margin-bottom: var(--sp-sm); }
.char-card-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.char-card-element {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--sp-xs);
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
}

.char-detail-panel {
  margin-bottom: var(--sp-md);
  text-align: center;
  animation: fadeIn .3s ease;
}
.char-detail-name { font-size: 18px; font-weight: 700; color: var(--accent-gold); }
.char-detail-title { font-size: 12px; color: var(--text-secondary); margin-bottom: var(--sp-sm); }
.char-detail-skill {
  font-size: 14px; color: var(--correct-green);
  padding: 8px;
  background: rgba(111, 207, 151, 0.08);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-sm);
}
.char-detail-desc { font-size: 13px; color: var(--text-secondary); }

/* --- World Map --- */
#screen-world-map {
  background: var(--bg-primary);
  padding-top: calc(var(--safe-top));
}
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-primary) 70%, transparent);
}
.map-title { font-size: 18px; font-weight: 700; }
.map-primogems {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-gold-bright);
}
.primogem-icon { font-size: 18px; }

.map-path {
  padding: var(--sp-md) var(--sp-lg);
  padding-bottom: calc(var(--safe-bottom) + var(--sp-2xl));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.map-node {
  width: 100%;
  max-width: 320px;
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-md);
  border-radius: var(--radius-md);
  transition: transform .15s;
}
.map-node:active:not(.locked) { transform: scale(0.97); }
.map-node.locked { opacity: 0.4; pointer-events: none; }
.map-node-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  border: 2px solid var(--border-gold);
  background: var(--bg-secondary);
  position: relative;
}
.map-node.completed .map-node-icon { border-color: var(--correct-green); }
.map-node.current .map-node-icon {
  border-color: var(--accent-gold-bright);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  animation: currentPulse 2s infinite;
}
@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.4); }
  50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); }
}
.map-node-info { flex: 1; }
.map-node-nation { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.map-node-topic { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.map-node-stars { margin-top: 4px; font-size: 14px; letter-spacing: 2px; }
.map-node-stars .star-filled { color: var(--accent-gold-bright); }
.map-node-stars .star-empty { color: var(--text-dim); }
.map-node-lock { font-size: 18px; color: var(--text-dim); }
.map-connector {
  width: 2px; height: 32px;
  background: var(--border-gold);
  opacity: 0.3;
}
.map-connector.active { opacity: 0.8; background: var(--accent-gold); }

/* --- Level Intro / Dialogue --- */
#screen-level-intro {
  background: var(--bg-primary);
  justify-content: flex-end;
  position: relative;
}
.intro-bg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0.7;
}
.intro-title-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1;
  text-align: center;
  padding: 0 var(--sp-lg);
}
.intro-level-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  margin-bottom: var(--sp-sm);
}
.intro-level-topic {
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 2px;
}
.dialogue-box {
  background: rgba(15, 18, 30, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 2px solid var(--accent-gold);
  padding: var(--sp-lg);
  padding-bottom: calc(var(--safe-bottom) + var(--sp-lg));
  min-height: 180px;
  position: relative;
  z-index: 1;
}
.dialogue-speaker {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: var(--sp-sm);
}
.dialogue-text {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 60px;
}
.dialogue-tap {
  position: absolute;
  bottom: calc(var(--safe-bottom) + var(--sp-sm));
  right: var(--sp-lg);
  font-size: 12px;
  color: var(--text-dim);
  animation: tapPulse 2s infinite;
}

/* --- Level Play --- */
#screen-level-play {
  background: var(--bg-primary);
}
.play-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  padding-top: calc(var(--safe-top) + var(--sp-sm));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}
.btn-back { font-size: 18px; font-weight: 700; }
.play-progress {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.play-progress-bar {
  height: 100%;
  background: var(--accent-gold);
  border-radius: 3px;
  transition: width .4s ease;
  width: 0%;
}
.play-info {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.play-timer {
  height: 4px;
  background: rgba(255,255,255,0.05);
}
.timer-bar {
  height: 100%;
  background: var(--correct-green);
  transition: width .1s linear;
  width: 100%;
}
.timer-bar.warning { background: var(--accent-gold); }
.timer-bar.danger { background: var(--wrong-red); }

.play-content {
  flex: 1;
  padding: var(--sp-md);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.play-skill-bar {
  padding: var(--sp-sm) var(--sp-md);
  padding-bottom: calc(var(--safe-bottom) + var(--sp-sm));
  display: flex;
  justify-content: flex-end;
}
.btn-skill {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 8px 16px;
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  font-size: 14px;
  color: var(--accent-gold);
  border: 1px solid var(--border-gold);
}

/* Question styles */
.question-prompt {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: var(--sp-lg);
  padding: var(--sp-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-gold);
  word-break: break-word;
  overflow-wrap: break-word;
}
.question-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.question-option {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px var(--sp-md);
  font-size: 15px;
  color: var(--text-primary);
  text-align: left;
  transition: border-color .15s, background .15s;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.question-option:active { background: rgba(255,255,255,0.05); }
.question-option.selected { border-color: var(--accent-gold); background: rgba(226,172,83,0.08); }
.question-option.correct {
  border-color: var(--correct-green);
  background: rgba(111,207,151,0.1);
  color: var(--correct-green);
}
.question-option.wrong {
  border-color: var(--wrong-red);
  background: rgba(235,87,87,0.1);
  color: var(--wrong-red);
}
.option-label {
  width: 24px; height: 24px;
  border-radius: var(--radius-round);
  border: 1.5px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.question-option.selected .option-label { border-color: var(--accent-gold); color: var(--accent-gold); }
.question-option.correct .option-label { border-color: var(--correct-green); background: var(--correct-green); color: #fff; }
.question-option.wrong .option-label { border-color: var(--wrong-red); background: var(--wrong-red); color: #fff; }

.question-tf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}
.question-tf-btn {
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  transition: border-color .15s, background .15s;
  min-height: 56px;
}
.question-tf-btn.selected { border-color: var(--accent-gold); background: rgba(226,172,83,0.08); }
.question-tf-btn.correct { border-color: var(--correct-green); background: rgba(111,207,151,0.1); color: var(--correct-green); }
.question-tf-btn.wrong { border-color: var(--wrong-red); background: rgba(235,87,87,0.1); color: var(--wrong-red); }

.question-input-row {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
  align-items: center;
}
.question-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px var(--sp-md);
  color: var(--text-primary);
  font-size: 18px;
  text-align: center;
  outline: none;
  min-height: 48px;
}
.question-input:focus { border-color: var(--accent-gold); }
.question-input.correct { border-color: var(--correct-green); }
.question-input.wrong { border-color: var(--wrong-red); }

.question-submit {
  padding: 12px 20px;
  min-height: 48px;
}

.question-canvas-container {
  width: 100%;
  aspect-ratio: 1;
  max-height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
  margin-bottom: var(--sp-md);
  touch-action: none;
}
.question-canvas-hint {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: var(--sp-sm);
}

.question-explanation {
  background: rgba(111, 207, 151, 0.06);
  border: 1px solid rgba(111, 207, 151, 0.2);
  border-radius: var(--radius-sm);
  padding: var(--sp-md);
  margin-top: var(--sp-md);
  animation: fadeIn .3s ease;
}
.explanation-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--correct-green);
  margin-bottom: var(--sp-xs);
}
.explanation-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.question-explanation.wrong-explain {
  background: rgba(235, 87, 87, 0.06);
  border-color: rgba(235, 87, 87, 0.2);
}
.question-explanation.wrong-explain .explanation-title { color: var(--wrong-red); }

.question-next-btn {
  margin-top: var(--sp-md);
  width: 100%;
}

/* --- Level Results --- */
#screen-level-results {
  background: var(--bg-primary);
  justify-content: center;
  align-items: center;
  padding: var(--sp-lg);
  overflow-x: hidden;
}
.results-content {
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-sizing: border-box;
}
.results-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-lg);
}
.results-stars {
  font-size: 36px;
  letter-spacing: 4px;
  margin-bottom: var(--sp-lg);
}
.results-stars .star { display: inline-block; opacity: 0; transform: scale(0); }
.results-stars .star.show {
  animation: starPop .5s ease forwards;
}
@keyframes starPop {
  0% { opacity: 0; transform: scale(0) rotate(-30deg); }
  60% { opacity: 1; transform: scale(1.3) rotate(10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.results-score {
  margin-bottom: var(--sp-lg);
  text-align: left;
}
.results-row {
  display: flex;
  justify-content: space-between;
  padding: var(--sp-sm) 0;
  font-size: 15px;
}
.results-row + .results-row { border-top: 1px solid var(--border-light); }
.text-gold { color: var(--accent-gold-bright); font-weight: 700; }
.results-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  align-items: center;
}
.results-buttons .btn-primary,
.results-buttons .btn-secondary { width: 100%; }

/* --- Boss Battle --- */
#screen-boss-battle {
  background: var(--grad-snezhnaya);
}
.boss-header {
  padding: var(--sp-md);
  padding-top: calc(var(--safe-top) + var(--sp-md));
}
.boss-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-sm);
}
.boss-name { font-size: 16px; font-weight: 700; color: var(--wrong-red); }
.boss-phase { font-size: 12px; color: var(--text-secondary); }
.boss-hp-bar {
  height: 20px;
  background: rgba(0,0,0,0.5);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(235, 87, 87, 0.3);
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #EB5757, #FF8888);
  border-radius: 10px;
  transition: width .6s ease;
  width: 100%;
}
.boss-hp-fill.phase2 { background: linear-gradient(90deg, #E2AC53, #FFD700); }
.boss-hp-fill.phase3 { background: linear-gradient(90deg, #B08FC2, #D4B0E8); }
.boss-hp-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.boss-arena {
  flex: 0 0 auto;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.boss-sprite {
  font-size: 72px;
  filter: drop-shadow(0 0 20px rgba(235, 87, 87, 0.4));
  transition: transform .3s;
}
.boss-sprite.hit {
  animation: bossHit .4s ease;
}
@keyframes bossHit {
  0% { transform: scale(1); filter: drop-shadow(0 0 20px rgba(235,87,87,0.4)); }
  20% { transform: scale(0.9) translateX(-10px); filter: brightness(2) drop-shadow(0 0 30px #fff); }
  40% { transform: scale(0.9) translateX(10px); }
  100% { transform: scale(1); filter: drop-shadow(0 0 20px rgba(235,87,87,0.4)); }
}
.boss-sprite.heal {
  animation: bossHeal .5s ease;
}
@keyframes bossHeal {
  0% { filter: drop-shadow(0 0 20px rgba(235,87,87,0.4)); }
  50% { filter: drop-shadow(0 0 30px rgba(111,207,151,0.6)) brightness(1.3); }
  100% { filter: drop-shadow(0 0 20px rgba(235,87,87,0.4)); }
}
.boss-question-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-md);
  padding-bottom: calc(var(--safe-bottom) + var(--sp-md));
}

/* Screen shake */
.screen-shake { animation: shake .3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Damage number float */
.damage-number {
  position: absolute;
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-gold-bright);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
  animation: damageFloat 1.2s ease-out forwards;
  z-index: 5;
}
.damage-number.heal { color: var(--correct-green); }
@keyframes damageFloat {
  0% { opacity: 1; transform: translateY(0) scale(0.5); }
  20% { transform: translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.8); }
}

/* --- Overlays --- */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }

.feedback-content {
  text-align: center;
  animation: feedbackPop .4s ease;
}
@keyframes feedbackPop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.feedback-icon { font-size: 64px; margin-bottom: var(--sp-md); }
.feedback-text { font-size: 22px; font-weight: 700; }
.feedback-text.correct { color: var(--correct-green); }
.feedback-text.wrong { color: var(--wrong-red); }
.feedback-gems { font-size: 16px; color: var(--accent-gold-bright); margin-top: var(--sp-sm); }

.achievement-popup {
  width: 85%;
  max-width: 320px;
  text-align: center;
  padding: var(--sp-lg);
  animation: achievePop .5s ease;
}
@keyframes achievePop {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.05) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.achieve-icon { font-size: 48px; margin-bottom: var(--sp-sm); }
.achieve-title { font-size: 18px; font-weight: 700; color: var(--accent-gold); margin-bottom: var(--sp-xs); }
.achieve-desc { font-size: 14px; color: var(--text-secondary); }

/* Settings */
.settings-panel {
  width: 85%;
  max-width: 320px;
}
.settings-panel h3 { font-size: 18px; margin-bottom: var(--sp-md); text-align: center; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-sm) 0;
}
.settings-panel hr { border: none; border-top: 1px solid var(--border-light); margin: var(--sp-md) 0; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px; height: 28px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--text-dim);
  border-radius: 14px;
  transition: .3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* --- Toast --- */
#toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 60px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  pointer-events: none;
}
.toast {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
  animation: toastIn .3s ease, toastOut .3s ease 2s forwards;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* --- Hint bubble --- */
.hint-bubble {
  background: rgba(226, 172, 83, 0.1);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: var(--sp-md);
  margin-bottom: var(--sp-md);
  animation: fadeIn .3s ease;
}
.hint-bubble-title { font-size: 13px; font-weight: 700; color: var(--accent-gold); margin-bottom: var(--sp-xs); }
.hint-bubble-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* --- Utilities --- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mb-md { margin-bottom: var(--sp-md); }
