/* ===== CSS Variables & Theme ===== */
:root {
  --c-bg: #f8f5f2;
  --c-accent: #ff9a8b;
  --c-aux: #a8d8ea;
  --c-success: #7bc043;
  --c-danger: #ff6b6b;
  --c-text: #4a4a4a;
  --c-text-light: #8a8a8a;
  --c-white: #ffffff;
  --c-card: #ffffff;
  --c-border: #e8e0d8;
  --c-shadow: rgba(74, 74, 74, 0.08);
  --c-overlay: rgba(74, 74, 74, 0.5);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font-main: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* body rules scoped to game via .game-active class */
body.game-active {
  overflow: hidden !important;
  height: 100% !important;
  background: var(--c-bg) !important;
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.app-body {
  width: 100%; height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ===== Screen System ===== */
.app-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.app-screen.active {
  display: flex;
  opacity: 1;
  z-index: 1;
}
.app-screen.slide-in-right {
  animation: slideInRight 0.45s ease forwards;
}
.app-screen.slide-out-left {
  animation: slideOutLeft 0.45s ease forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutLeft {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-100%); opacity: 0; }
}

/* ===== Loading Screen ===== */
.app-loading-screen {
  background: linear-gradient(135deg, #fff5f3 0%, #f0e8ff 50%, #e8f4fd 100%);
  align-items: center;
  justify-content: center;
}
.app-loading-content { text-align: center; }
.app-loading-icon {
  font-size: 64px;
  animation: heartbeat 1.2s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.app-loading-title {
  font-size: 36px; font-weight: 800;
  color: var(--c-accent);
  margin-top: 16px;
  letter-spacing: 2px;
}
.app-loading-subtitle {
  font-size: 16px; color: var(--c-text-light);
  margin-top: 8px; letter-spacing: 4px;
}
.app-loading-bar {
  width: 200px; height: 6px;
  background: var(--c-border);
  border-radius: 3px;
  margin: 24px auto 0;
  overflow: hidden;
}
.app-loading-bar-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--c-accent), #ffb3a7);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.app-loading-text {
  font-size: 13px; color: var(--c-text-light);
  margin-top: 12px;
}

/* ===== Menu Screen ===== */
.app-menu-screen {
  background: var(--c-bg);
  align-items: center;
  justify-content: center;
}
.app-menu-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 154, 139, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(168, 216, 234, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(123, 192, 67, 0.06) 0%, transparent 60%);
  pointer-events: none;
}
.app-menu-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 32px;
  padding: 24px;
  width: 100%; max-width: 400px;
}
.app-menu-logo { text-align: center; }
.app-menu-heart {
  font-size: 72px; display: block;
  animation: heartFloat 3s ease-in-out infinite;
}
@keyframes heartFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.app-menu-title {
  font-size: 40px; font-weight: 900;
  background: linear-gradient(135deg, var(--c-accent), #ff7eb3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 8px;
}
.app-menu-desc {
  font-size: 16px; color: var(--c-text-light);
  letter-spacing: 6px; margin-top: 4px;
}
.app-menu-buttons {
  display: flex; flex-direction: column;
  gap: 12px; width: 100%;
}
.app-menu-footer {
  display: flex; gap: 16px;
}

/* ===== Buttons ===== */
.app-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-size: 16px; font-weight: 700;
  border: 3px solid var(--c-text);
  cursor: pointer;
  transition: all var(--bounce);
  outline: none;
  position: relative;
  letter-spacing: 1px;
}
.app-btn:active { transform: scale(0.95); }

.app-btn-primary {
  background: var(--c-accent);
  color: var(--c-white);
  box-shadow: 4px 4px 0 var(--c-text);
}
.app-btn-primary:active {
  box-shadow: 2px 2px 0 var(--c-text);
  transform: translate(2px, 2px) scale(0.98);
}

.app-btn-secondary {
  background: var(--c-aux);
  color: var(--c-text);
  box-shadow: 4px 4px 0 var(--c-text);
}
.app-btn-secondary:active {
  box-shadow: 2px 2px 0 var(--c-text);
  transform: translate(2px, 2px) scale(0.98);
}

.app-btn-outline {
  background: var(--c-white);
  color: var(--c-text);
  box-shadow: 3px 3px 0 var(--c-text);
}
.app-btn-outline:active {
  box-shadow: 1px 1px 0 var(--c-text);
  transform: translate(2px, 2px) scale(0.98);
}

.app-btn-danger {
  background: var(--c-danger);
  color: var(--c-white);
  border-color: #cc4444;
  box-shadow: 3px 3px 0 #cc4444;
}

.app-btn-icon {
  background: none; border: none;
  font-size: 14px; color: var(--c-text-light);
  cursor: pointer; padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.app-btn-icon:hover { background: rgba(0,0,0,0.05); }

/* ===== Header ===== */
.app-header {
  display: flex; align-items: center;
  padding: 12px 16px;
  background: var(--c-white);
  border-bottom: 3px solid var(--c-text);
  gap: 12px;
  flex-shrink: 0;
}
.app-header-title {
  font-size: 18px; font-weight: 800;
  flex: 1; text-align: center;
}
.app-header-spacer { width: 60px; }
.app-back-btn {
  background: none; border: none;
  font-size: 16px; font-weight: 700;
  color: var(--c-text); cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.app-back-btn:active { transform: scale(0.9); }

/* ===== Chapters ===== */
.app-chapters-screen { background: var(--c-bg); }
.app-chapters-list {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.app-chapter-card {
  background: var(--c-white);
  border: 3px solid var(--c-text);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 4px 4px 0 var(--c-text);
  cursor: pointer;
  transition: all var(--bounce);
  position: relative;
  overflow: hidden;
}
.app-chapter-card:active {
  box-shadow: 2px 2px 0 var(--c-text);
  transform: translate(2px, 2px);
}
.app-chapter-card.locked {
  opacity: 0.5; cursor: not-allowed;
  filter: grayscale(0.5);
}
.app-chapter-card.locked:active { transform: none; box-shadow: 4px 4px 0 var(--c-text); }
.app-chapter-num {
  font-size: 13px; font-weight: 800;
  color: var(--c-accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.app-chapter-name {
  font-size: 20px; font-weight: 800;
  margin-top: 4px;
}
.app-chapter-desc {
  font-size: 13px; color: var(--c-text-light);
  margin-top: 6px; line-height: 1.5;
}
.app-chapter-progress {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 12px; color: var(--c-text-light);
}
.app-chapter-progress-bar {
  flex: 1; height: 6px;
  background: var(--c-border);
  border-radius: 3px; overflow: hidden;
}
.app-chapter-progress-fill {
  height: 100%;
  background: var(--c-success);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.app-chapter-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--c-accent);
  color: var(--c-white);
  font-size: 11px; font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  border: 2px solid var(--c-text);
}
.app-chapter-lock-icon {
  position: absolute; top: 50%; right: 20px;
  transform: translateY(-50%);
  font-size: 28px; opacity: 0.4;
}

/* ===== Levels ===== */
.app-levels-screen { background: var(--c-bg); }
.app-levels-list {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.app-level-card {
  background: var(--c-white);
  border: 3px solid var(--c-text);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: 3px 3px 0 var(--c-text);
  cursor: pointer;
  transition: all var(--bounce);
}
.app-level-card:active {
  box-shadow: 1px 1px 0 var(--c-text);
  transform: translate(2px, 2px);
}
.app-level-card.locked {
  opacity: 0.4; cursor: not-allowed;
}
.app-level-card.locked:active { transform: none; box-shadow: 3px 3px 0 var(--c-text); }
.app-level-num {
  font-size: 28px; font-weight: 900;
  color: var(--c-accent);
}
.app-level-name {
  font-size: 12px; font-weight: 700;
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-level-stars {
  margin-top: 8px;
  font-size: 16px;
  letter-spacing: 2px;
}

/* ===== Game HUD ===== */
.app-game-screen { background: var(--c-bg); }
.app-game-hud {
  display: flex; align-items: center;
  padding: 8px 12px; gap: 10px;
  background: var(--c-white);
  border-bottom: 3px solid var(--c-text);
  flex-shrink: 0; z-index: 10;
}
.app-game-hud-left { display: flex; align-items: center; gap: 8px; }
.app-game-chapter-label { font-size: 12px; font-weight: 700; color: var(--c-text-light); white-space: nowrap; }
.app-game-hud-center { flex: 1; min-width: 0; }
.app-game-hud-right { display: flex; align-items: center; gap: 8px; }
.app-progress-bar {
  height: 10px; background: var(--c-border);
  border-radius: 5px; overflow: hidden;
  border: 2px solid var(--c-text);
}
.app-progress-fill {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--c-accent), #ffb3a7);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.app-hearts { display: flex; gap: 2px; font-size: 18px; }
.app-heart { transition: all 0.3s ease; display: inline-block; }
.app-heart.lost { opacity: 0.2; transform: scale(0.8); }
.app-heart.losing { animation: heartLose 0.5s ease; }
@keyframes heartLose {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); color: var(--c-danger); }
  100% { transform: scale(0.8); opacity: 0.2; }
}
.app-clue-toggle {
  background: var(--c-aux); border: 2px solid var(--c-text);
  border-radius: 20px; padding: 4px 10px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all var(--bounce);
}
.app-clue-toggle:active { transform: scale(0.9); }

/* ===== Scene ===== */
.app-scene {
  flex: 1; position: relative;
  overflow: hidden; min-height: 0;
  display: flex; align-items: flex-end;
  justify-content: center;
}
.app-scene-bg {
  position: absolute; inset: 0;
  transition: all 0.6s ease;
}
.app-scene-bg.scene-chat {
  background: linear-gradient(180deg, #e8f4fd 0%, #f0e8ff 100%);
}
.app-scene-bg.scene-cafe {
  background: linear-gradient(180deg, #fff5e6 0%, #ffe8d6 100%);
}
.app-scene-bg.scene-group {
  background: linear-gradient(180deg, #e8fde8 0%, #d6f0e8 100%);
}
.app-scene-bg.scene-date {
  background: linear-gradient(180deg, #ffe8ee 0%, #ffd6e0 100%);
}
.app-scene-bg.scene-phone {
  background: linear-gradient(180deg, #e8e8fd 0%, #d6d6f0 100%);
}
.app-characters {
  position: relative; z-index: 2;
  display: flex; align-items: flex-end;
  justify-content: center; gap: 20px;
  padding: 0 20px 10px; width: 100%;
  max-width: 400px;
}
.app-character {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: all 0.4s ease;
}
.app-character-body {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid var(--c-text);
  display: flex; align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 3px 3px 0 var(--c-text);
  transition: all 0.3s ease;
  position: relative;
}
.app-character-body.player { background: var(--c-bg); }
.app-character-body.npc-blue { background: var(--c-aux); }
.app-character-body.npc-pink { background: #ffd6e0; }
.app-character-body.npc-yellow { background: #fff3c4; }
.app-character-body.npc-purple { background: #e8d6ff; }
.app-character-name {
  font-size: 11px; font-weight: 700;
  color: var(--c-text);
  background: var(--c-white);
  padding: 2px 8px;
  border-radius: 10px;
  border: 2px solid var(--c-text);
}
.app-character.speaking .app-character-body {
  animation: characterBounce 0.6s ease infinite;
}
@keyframes characterBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.app-character-emotion {
  position: absolute; top: -12px; right: -8px;
  font-size: 16px;
  animation: emotionPop 0.4s var(--bounce);
}
@keyframes emotionPop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ===== Barrier ===== */
.app-barrier {
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 40px; z-index: 3;
  background: repeating-linear-gradient(90deg, transparent, transparent 10px, rgba(150,150,150,0.2) 10px, rgba(150,150,150,0.2) 12px);
  border-top: 2px dashed var(--c-text-light);
  border-bottom: 2px dashed var(--c-text-light);
  opacity: 0.6;
  transition: opacity 0.5s ease;
}

/* ===== Dialogue ===== */
.app-dialogue {
  background: var(--c-white);
  border-top: 3px solid var(--c-text);
  padding: 14px 18px 12px;
  min-height: 100px;
  position: relative; cursor: pointer;
  flex-shrink: 0;
}
.app-dialogue-speaker {
  font-size: 13px; font-weight: 800;
  color: var(--c-accent);
  margin-bottom: 6px;
}
.app-dialogue-text {
  font-size: 15px; line-height: 1.7;
  color: var(--c-text);
  min-height: 44px;
}
.app-dialogue-indicator {
  position: absolute; bottom: 8px; right: 14px;
  font-size: 12px; color: var(--c-text-light);
  animation: indicatorBlink 1s ease infinite;
}
@keyframes indicatorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Clue Collectible ===== */
.app-clue-highlight {
  display: inline;
  background: rgba(168, 216, 234, 0.3);
  border-bottom: 2px dashed var(--c-aux);
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  transition: all 0.2s ease;
}
.app-clue-highlight:hover, .app-clue-highlight:active {
  background: rgba(168, 216, 234, 0.6);
}
.app-clue-fly {
  position: fixed; z-index: 100;
  font-size: 20px;
  pointer-events: none;
  animation: clueFly 0.6s ease forwards;
}
@keyframes clueFly {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.5) translateY(-60px); opacity: 0; }
}

/* ===== Choices ===== */
.app-choices {
  padding: 10px 16px 16px;
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
  max-height: 50vh; overflow-y: auto;
}
.app-choice-btn {
  background: var(--c-white);
  border: 3px solid var(--c-text);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  text-align: left; cursor: pointer;
  box-shadow: 3px 3px 0 var(--c-text);
  transition: all var(--bounce);
  line-height: 1.5;
  color: var(--c-text);
}
.app-choice-btn:active {
  box-shadow: 1px 1px 0 var(--c-text);
  transform: translate(2px, 2px);
}
.app-choice-btn:hover {
  background: #fff5f3;
  transform: scale(1.02);
}
.app-choice-btn.correct {
  background: var(--c-accent) !important;
  color: var(--c-white) !important;
  animation: choiceCorrect 0.5s ease;
}
.app-choice-btn.wrong {
  background: var(--c-danger) !important;
  color: var(--c-white) !important;
  animation: choiceWrong 0.4s ease;
}
@keyframes choiceCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes choiceWrong {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.app-choice-icon {
  display: inline-block; margin-right: 6px;
  font-weight: 900;
}

/* ===== Clue Panel ===== */
.app-clue-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--c-white);
  border-top: 3px solid var(--c-text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px;
  max-height: 60vh; overflow-y: auto;
  z-index: 20;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.app-clue-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.app-clue-header h3 { font-size: 16px; font-weight: 800; }
.app-clue-close {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  padding: 4px 8px;
}
.app-clue-list { display: flex; flex-wrap: wrap; gap: 8px; }
.app-clue-item {
  background: var(--c-aux);
  border: 2px solid var(--c-text);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 700;
  box-shadow: 2px 2px 0 var(--c-text);
}
.app-clue-analysis {
  margin-top: 14px; padding-top: 14px;
  border-top: 2px dashed var(--c-border);
}
.app-clue-analysis h4 {
  font-size: 14px; font-weight: 800;
  color: var(--c-accent); margin-bottom: 8px;
}
#clue-analysis-text {
  font-size: 13px; line-height: 1.6;
  color: var(--c-text);
}

/* ===== Feedback Overlay ===== */
.app-feedback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 30; pointer-events: none;
}
.app-feedback.correct { background: rgba(123, 192, 67, 0.15); }
.app-feedback.wrong { background: rgba(255, 107, 107, 0.15); }
.app-feedback-icon {
  font-size: 64px;
  animation: feedbackPop 0.5s var(--bounce);
}
@keyframes feedbackPop {
  from { transform: scale(0) rotate(-20deg); }
  to { transform: scale(1) rotate(0); }
}
.app-feedback-text {
  font-size: 15px; font-weight: 700;
  color: var(--c-text);
  margin-top: 12px;
  text-align: center;
  max-width: 320px;
  background: var(--c-white);
  border: 2px solid var(--c-text);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  box-shadow: 3px 3px 0 var(--c-text);
}

/* ===== Complete Screen ===== */
.app-complete-screen {
  background: var(--c-bg);
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.app-complete-content {
  width: 100%; max-width: 420px;
  padding: 24px 16px 0;
  text-align: center;
}
.app-complete-celebration {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.app-particle {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  animation: particleFall 2s ease-out forwards;
}
@keyframes particleFall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0); opacity: 0; }
}
.app-complete-title {
  font-size: 28px; font-weight: 900;
  color: var(--c-accent);
  position: relative; z-index: 1;
}
.app-complete-ending {
  font-size: 14px; line-height: 1.7;
  color: var(--c-text);
  margin-top: 12px;
  background: var(--c-white);
  border: 2px solid var(--c-text);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 3px 3px 0 var(--c-text);
  position: relative; z-index: 1;
}
.app-complete-stars {
  font-size: 36px; margin-top: 16px;
  letter-spacing: 8px;
  position: relative; z-index: 1;
}
.app-star { display: inline-block; transition: all 0.3s ease; }
.app-star.earned { animation: starEarn 0.5s var(--bounce); }
@keyframes starEarn {
  from { transform: scale(0) rotate(-180deg); }
  to { transform: scale(1) rotate(0); }
}
.app-complete-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 16px;
  position: relative; z-index: 1;
}
.app-stat-card {
  background: var(--c-white);
  border: 2px solid var(--c-text);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  box-shadow: 2px 2px 0 var(--c-text);
}
.app-stat-value {
  font-size: 22px; font-weight: 900;
  color: var(--c-accent);
}
.app-stat-label {
  font-size: 11px; color: var(--c-text-light);
  margin-top: 2px;
}
.app-complete-skills {
  margin-top: 16px;
  text-align: left;
  position: relative; z-index: 1;
}
.app-complete-skills h4 {
  font-size: 14px; font-weight: 800;
  margin-bottom: 8px;
}
.app-skill-unlock {
  background: var(--c-white);
  border: 2px solid var(--c-success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  animation: skillUnlock 0.5s var(--bounce);
}
@keyframes skillUnlock {
  from { transform: translateX(-20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.app-skill-unlock-title {
  font-size: 13px; font-weight: 800;
  color: var(--c-success);
}
.app-skill-unlock-desc {
  font-size: 12px; color: var(--c-text-light);
  margin-top: 2px; line-height: 1.4;
}
.app-complete-actions {
  display: flex; flex-direction: column;
  gap: 8px; padding: 16px;
  width: 100%; max-width: 420px;
  position: relative; z-index: 1;
}

/* ===== Game Over ===== */
.app-gameover-screen {
  align-items: center; justify-content: center;
}
.app-gameover-overlay {
  position: absolute; inset: 0;
  background: rgba(74, 74, 74, 0.6);
  animation: darken 0.5s ease;
}
@keyframes darken {
  from { opacity: 0; }
  to { opacity: 1; }
}
.app-gameover-content {
  position: relative; z-index: 1;
  text-align: center;
  background: var(--c-white);
  border: 3px solid var(--c-text);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  margin: 16px;
  box-shadow: 6px 6px 0 var(--c-text);
  animation: gameoverSlide 0.5s var(--bounce);
}
@keyframes gameoverSlide {
  from { transform: translateY(40px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.app-gameover-icon { font-size: 56px; }
.app-gameover-title {
  font-size: 24px; font-weight: 900;
  color: var(--c-danger); margin-top: 8px;
}
.app-gameover-text {
  font-size: 14px; color: var(--c-text-light);
  margin-top: 8px; line-height: 1.6;
}
.app-gameover-actions {
  display: flex; flex-direction: column;
  gap: 8px; margin-top: 20px;
}

/* ===== Gallery ===== */
.app-gallery-screen { background: var(--c-bg); }
.app-gallery-tabs {
  display: flex; gap: 6px;
  padding: 10px 16px; overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.app-gallery-tab {
  background: var(--c-white); border: 2px solid var(--c-text);
  border-radius: 20px; padding: 6px 14px;
  font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.app-gallery-tab.active {
  background: var(--c-accent); color: var(--c-white);
}
.app-gallery-grid {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.app-gallery-card {
  background: var(--c-white);
  border: 2px solid var(--c-text);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  box-shadow: 2px 2px 0 var(--c-text);
  cursor: pointer;
  transition: all var(--bounce);
}
.app-gallery-card:active { transform: scale(0.96); }
.app-gallery-card.locked { opacity: 0.35; filter: grayscale(0.8); }
.app-gallery-card-icon { font-size: 28px; }
.app-gallery-card-title {
  font-size: 12px; font-weight: 700;
  margin-top: 6px; line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-gallery-card-cat {
  font-size: 10px; color: var(--c-text-light);
  margin-top: 4px;
}

/* ===== Modal ===== */
.app-modal {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.app-modal-backdrop {
  position: absolute; inset: 0;
  background: var(--c-overlay);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-modal-content {
  position: relative; z-index: 1;
  background: var(--c-white);
  border: 3px solid var(--c-text);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 400px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 6px 6px 0 var(--c-text);
  animation: modalPop 0.3s var(--bounce);
}
@keyframes modalPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.app-modal-content h3 {
  font-size: 20px; font-weight: 900;
  margin-bottom: 16px; text-align: center;
}
.app-skill-detail-icon { font-size: 40px; text-align: center; margin-bottom: 8px; }
.app-skill-detail-title {
  font-size: 18px; font-weight: 800;
  text-align: center; margin-bottom: 4px;
}
.app-skill-detail-cat {
  font-size: 12px; color: var(--c-text-light);
  text-align: center; margin-bottom: 12px;
}
.app-skill-detail-desc {
  font-size: 13px; line-height: 1.7;
  color: var(--c-text); margin-bottom: 12px;
}
.app-skill-detail-section h4 {
  font-size: 14px; font-weight: 800;
  color: var(--c-accent); margin-bottom: 6px;
}
.app-skill-detail-section p {
  font-size: 13px; line-height: 1.6;
  color: var(--c-text); margin-bottom: 10px;
}
.app-modal-close {
  display: block; width: 100%;
  margin-top: 16px;
}

/* ===== Settings ===== */
.app-settings-content { max-width: 360px; }
.app-setting-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}
.app-setting-row span { font-size: 14px; font-weight: 700; }
.app-input {
  border: 2px solid var(--c-text);
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 14px;
  width: 160px; outline: none;
  font-family: var(--font-main);
}
.app-input:focus { border-color: var(--c-accent); }
.app-select {
  border: 2px solid var(--c-text);
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 14px;
  outline: none; background: var(--c-white);
  font-family: var(--font-main);
}

/* ===== Leaderboard ===== */
.app-leaderboard-screen { background: var(--c-bg); }
.app-lb-content {
  flex: 1; overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.app-lb-row {
  display: flex; align-items: center;
  background: var(--c-white);
  border: 2px solid var(--c-text);
  border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 8px;
  box-shadow: 2px 2px 0 var(--c-text);
  gap: 12px;
}
.app-lb-rank {
  font-size: 18px; font-weight: 900;
  color: var(--c-accent); min-width: 32px;
  text-align: center;
}
.app-lb-rank.top1 { color: #ffd700; }
.app-lb-rank.top2 { color: #c0c0c0; }
.app-lb-rank.top3 { color: #cd7f32; }
.app-lb-name { flex: 1; font-size: 14px; font-weight: 700; }
.app-lb-score { font-size: 16px; font-weight: 900; color: var(--c-accent); }
.app-lb-empty {
  text-align: center; padding: 40px;
  color: var(--c-text-light); font-size: 14px;
}

/* ===== Toast ===== */
.app-toast {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: var(--c-white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px; font-weight: 700;
  z-index: 100;
  animation: toastIn 0.3s var(--bounce);
  pointer-events: none;
  white-space: nowrap;
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  .app-menu-title { font-size: 32px; }
  .app-menu-heart { font-size: 56px; }
  .app-btn { padding: 12px 20px; font-size: 14px; }
  .app-character-body { width: 52px; height: 52px; font-size: 18px; }
  .app-complete-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}
@media (min-width: 768px) {
  .app-menu-content { max-width: 480px; }
  .app-chapters-list { max-width: 600px; margin: 0 auto; }
  .app-levels-list { max-width: 600px; margin: 0 auto; }
  .app-game-screen .app-scene { max-height: 50vh; }
  .app-complete-content { max-width: 500px; }
  .app-lb-content { max-width: 600px; margin: 0 auto; }
}
