/* ========== 全局重置与基础 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4a90d9;
  --primary-dark: #2c5f9e;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --gold: #ffd700;
  --bg-dark: #1a1a2e;
  --bg-medium: #16213e;
  --bg-light: #0f3460;
  --text: #e0e0e0;
  --text-bright: #ffffff;
  --text-dim: #888;
  --hp-green: #4caf50;
  --hp-yellow: #ff9800;
  --hp-red: #f44336;
  --border-radius: 8px;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
}

#game-container {
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-dark);
}

/* ========== 屏幕管理 ========== */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ========== 按钮 ========== */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  letter-spacing: 1px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 3px 10px rgba(74, 144, 217, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 5px 20px rgba(74, 144, 217, 0.6);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-info {
  background: rgba(23, 162, 184, 0.2);
  color: var(--info);
  border: 1px solid rgba(23, 162, 184, 0.3);
}

.btn-lg {
  padding: 16px 40px;
  font-size: 20px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ========== 模态框 ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-medium);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ========== 面板 ========== */
.panel-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  gap: 20px;
}

.panel-center h2 {
  font-size: 24px;
  color: var(--text-bright);
}

/* ========== Toast 提示 ========== */
#toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(30, 30, 60, 0.95);
  color: var(--text-bright);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ========== 内联图标（红钥匙等） ========== */
.inline-icon {
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  object-fit: contain;
}

/* ========== 切换开关 ========== */
.toggle-switch {
  width: 50px;
  height: 26px;
  background: #555;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-switch[data-on="true"] {
  background: var(--success);
}

.toggle-knob {
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.3s;
}

.toggle-switch[data-on="true"] .toggle-knob {
  left: 26px;
}

/* ========== 设置 ========== */
.settings-form {
  width: 100%;
  max-width: 300px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-row label {
  font-size: 16px;
}

.setting-row select {
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}

/* ========== 输入框 ========== */
input[type="number"] {
  background: var(--bg-dark);
  border: 2px solid var(--primary);
  color: var(--text-bright);
  padding: 10px 16px;
  font-size: 20px;
  border-radius: 8px;
  width: 120px;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

input[type="number"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* ========== 答题区通用 ========== */
.answer-input {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

.question-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  text-align: center;
  padding: 10px;
  letter-spacing: 2px;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

/* ========== 故事对话面板 ========== */
.story-panel {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.story-panel.active {
  opacity: 1;
}

.story-box {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(180deg, rgba(22, 33, 62, 0.97), rgba(15, 15, 40, 0.99));
  border-top: 2px solid rgba(255, 215, 0, 0.4);
  padding: 18px 22px 14px;
  min-height: 130px;
  animation: storySlideUp 0.35s ease;
}

@keyframes storySlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.story-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.story-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.story-speaker {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

.story-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-bright);
  min-height: 48px;
}

.story-hint {
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  animation: hintBlink 1.2s ease-in-out infinite;
}

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