:root {
  --primary: #4e7cff;
  --primary-dark: #3a63d9;
  --accent: #ffb02e;
  --bg: #f2f6ff;
  --card: #ffffff;
  --text: #2b3a55;
  --text-light: #7b8bab;
  --radius: 18px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 2px 8px rgba(74, 108, 220, 0.25);
}

#view {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

#tabbar {
  display: flex;
  background: var(--card);
  border-top: 1px solid #e6ecf7;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
}

.tab.active {
  color: var(--primary);
}

.placeholder {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 16px;
  background: var(--card);
  border-radius: var(--radius);
}

button {
  font-family: inherit;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(74, 108, 220, 0.3);
}

.story-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.story-scene {
  font-size: 56px;
  text-align: center;
  padding: 32px 0;
}

.story-dialog {
  margin-top: auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.08);
}

.story-speaker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.story-emoji {
  font-size: 24px;
}

.story-text {
  font-size: 20px;
  line-height: 1.6;
  min-height: 96px;
  margin-bottom: 16px;
}

.game-progress {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 16px;
}

.learn-card, .repeat-card, .q-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.08);
}

.learn-emoji { font-size: 72px; }
.learn-word { font-size: 34px; font-weight: 800; margin: 8px 0 4px; color: var(--primary-dark); }
.learn-phonetic { color: var(--text-light); font-size: 16px; }
.learn-zh { font-size: 18px; margin-top: 8px; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: #eaf0ff;
  color: var(--primary-dark);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { margin-top: 10px; }

.q-emoji { font-size: 72px; }
.q-hint { color: var(--text-light); margin: 8px 0 16px; }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.q-option {
  padding: 16px 8px;
  border: 2px solid #e6ecf7;
  border-radius: 14px;
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.q-option.wrong { border-color: #ff6b6b; color: #ff6b6b; }
.q-feedback { min-height: 28px; margin-top: 14px; font-size: 18px; font-weight: 700; }
.q-feedback.good { color: #22a06b; }
.q-feedback.try { color: #ff8c42; }

.view-title { text-align: center; margin-bottom: 16px; font-size: 22px; }

.island-list { display: flex; flex-direction: column; gap: 12px; }
.island-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.08);
}
.island-card.locked { opacity: 0.55; }
.island-icon { font-size: 36px; }
.island-info { flex: 1; }
.island-unit { font-weight: 700; font-size: 16px; }
.island-scene { color: var(--text-light); font-size: 14px; margin-top: 4px; }
.island-status { color: var(--primary); font-size: 14px; font-weight: 600; }

.result-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.08);
}
.result-title { font-size: 28px; font-weight: 800; margin-bottom: 16px; color: var(--accent); }
.result-gems { font-size: 20px; margin-bottom: 8px; }
.result-coins { font-size: 20px; margin-bottom: 16px; color: var(--primary-dark); font-weight: 700; }
.result-hint { color: var(--text-light); margin-bottom: 24px; font-size: 15px; line-height: 1.6; }

.coin-banner { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 16px; color: var(--accent); }
.gacha-area { background: var(--card); border-radius: var(--radius); padding: 20px; text-align: center; margin-bottom: 16px; }
.gacha-pity { color: var(--text-light); font-size: 13px; margin-top: 10px; }
.gacha-result { min-height: 24px; margin-top: 10px; font-weight: 700; }

.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shop-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(43, 58, 85, 0.08);
}
.shop-emoji { font-size: 44px; display: block; margin-bottom: 6px; }
.shop-name { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.shop-owned { color: #22a06b; font-size: 14px; font-weight: 700; }

.avatar-preview {
  font-size: 60px;
  text-align: center;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.wear-slot { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.wear-slot-label { font-weight: 700; margin-bottom: 12px; }
.wear-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wear-item {
  padding: 10px 4px;
  border: 2px solid #e6ecf7;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.wear-item.active { border-color: var(--primary); background: #eef3ff; }
.wear-emoji { font-size: 30px; display: block; }
.wear-name { font-size: 12px; }

.tab:active, .btn:active, .btn-primary:active, .q-option:active {
  transform: scale(0.96);
}
.tab, .btn, .btn-primary, .q-option {
  transition: transform 0.08s ease;
}

.story-text.enter {
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.learn-word.pop {
  animation: pop 0.35s ease;
}
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.q-option.correct-anim {
  background: #e8f8f0;
  border-color: #22a06b;
  animation: bounce 0.45s ease;
}
@keyframes bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.q-option.wrong {
  border-color: #ff6b6b;
  color: #ff6b6b;
  animation: shake 0.35s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.q-feedback.good {
  animation: pop 0.3s ease;
}

.result-title {
  animation: pop 0.5s ease;
}
.result-gems, .result-coins {
  animation: fadeUp 0.5s ease;
}
