/* 抉择，我的大学时光 - H5 Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sky: #87CEEB;
  --sakura: #FFB7C5;
  --campus-green: #90EE90;
  --navy: #1A237E;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.9);
  --btn-blue: #5eb9f0;
  --btn-blue-dark: #219EBC;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #000;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #111;
}

/* ===== Screens ===== */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  z-index: 10;
}

.screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.15) 100%);
  pointer-events: none;
}

/* ===== Home ===== */
#screen-home .bg-layer { background-image: url("../images/主页背景.png"); }

.home-title {
  position: absolute;
  top: calc(8% + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 78%;
  max-width: 320px;
  z-index: 2;
  animation: titleFloat 3s ease-in-out infinite;
}

.home-title img { width: 100%; height: auto; display: block; }

.home-hint {
  position: absolute;
  bottom: calc(12% + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  letter-spacing: 2px;
  animation: pulse 2s ease-in-out infinite;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 2;
}

/* ===== Loading ===== */
#screen-loading .bg-layer { background-image: url("../images/加载页背景.png"); }

.music-player {
  position: absolute;
  bottom: calc(18% + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 88%;
  z-index: 2;
}

.music-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #222;
  margin-bottom: 6px;
}

.progress-track {
  position: relative;
  height: 2px;
  background: rgba(0,0,0,0.25);
  border-radius: 2px;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #222;
  border-radius: 2px;
  transition: width 0.2s ease;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: #222;
  border-radius: 50%;
  transition: left 0.2s ease;
}

.progress-text {
  text-align: center;
  font-size: 12px;
  color: rgba(0,0,0,0.6);
  margin-top: 8px;
}

.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.music-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-btn.play-btn {
  width: 44px;
  height: 44px;
  border: 2px solid #222;
  border-radius: 50%;
}

.music-btn svg { width: 18px; height: 18px; fill: #222; }
.music-btn.play-btn svg { width: 16px; height: 16px; }

/* ===== Start Game ===== */
#screen-start .bg-layer { background-image: url("../images/加载页背景.png"); }

.start-btn-wrap {
  position: absolute;
  bottom: calc(22% + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.start-btn-wrap:active { transform: translateX(-50%) scale(0.95); }
.start-btn-wrap img { width: 160px; height: auto; display: block; }

/* ===== Enter Campus ===== */
#screen-enter .bg-layer { background-image: url("../images/进入页背景.png"); }

.enter-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 48px;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 30px;
  color: #fff;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 4px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s, transform 0.15s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.enter-btn:active { transform: translate(-50%, -50%) scale(0.96); background: rgba(255,255,255,0.6); }

/* ===== Score Panel ===== */
.score-panel {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  display: flex;
  gap: 8px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.score-panel.visible { opacity: 1; }

.score-item {
  flex: 1;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 6px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.score-item .label {
  font-size: 10px;
  color: #666;
  margin-bottom: 2px;
}

.score-item .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  transition: color 0.3s;
}

.score-item .bar {
  height: 3px;
  background: #e0e0e0;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.score-item .bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.score-item.study .bar-fill { background: #4CAF50; }
.score-item.social .bar-fill { background: #FF9800; }
.score-item.happy .bar-fill { background: #E91E63; }

/* ===== Story Screen ===== */
#screen-story .bg-layer { transition: background-image 0.8s ease; }

.narrative-box {
  position: absolute;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 18px 20px;
  z-index: 5;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  animation: slideUp 0.5s ease;
}

.narrative-box.hidden { display: none; }

.narrative-text {
  font-size: 15px;
  line-height: 1.8;
  color: #333;
  text-align: justify;
}

.narrative-continue {
  display: block;
  margin-top: 12px;
  text-align: right;
  font-size: 12px;
  color: #999;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===== Choice Dialog ===== */
.choice-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: calc(18% + var(--safe-top));
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.choice-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.choice-bubble {
  width: 88%;
  background: linear-gradient(135deg, rgba(200,230,255,0.92), rgba(180,220,250,0.88));
  border-radius: 16px;
  padding: 18px 20px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  position: relative;
  animation: slideDown 0.4s ease;
}

.choice-bubble::before,
.choice-bubble::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 6px;
  height: 6px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
}

.choice-bubble::before { left: 12px; }
.choice-bubble::after { right: 12px; }

.choice-question {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,80,150,0.3);
  line-height: 1.6;
}

.choice-bubble.white-style {
  background: rgba(255,255,255,0.92);
}

.choice-bubble.white-style .choice-question {
  color: #333;
  text-shadow: none;
}

.choice-buttons {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  justify-content: center;
  width: 88%;
}

.choice-btn {
  flex: 1;
  max-width: 140px;
  padding: 12px 0;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  color: #fff;
}

.choice-btn:active { transform: scale(0.95); }

.choice-btn.join {
  background: linear-gradient(180deg, #8ECAE6, #5eb9f0);
  box-shadow: 0 3px 10px rgba(94,185,240,0.4);
}

.choice-btn.leave {
  background: linear-gradient(180deg, #219EBC, #1a8aad);
  box-shadow: 0 3px 10px rgba(33,158,188,0.4);
}

.choice-btn.option {
  background: rgba(255,255,255,0.92);
  color: #555;
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}

.choice-btn img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.choice-btn-img {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex: 1;
  max-width: 130px;
  transition: transform 0.15s;
}

.choice-btn-img:active { transform: scale(0.95); }

/* ===== Score Float Animation ===== */
.score-float {
  position: absolute;
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 30;
  animation: floatUp 1.2s ease forwards;
}

.score-float.positive { color: #4CAF50; }
.score-float.negative { color: #f44336; }

/* ===== Ending Screen ===== */
#screen-ending .bg-layer { transition: background-image 0.8s ease; }

.ending-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(12px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  z-index: 5;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.55) 60%, rgba(0,0,0,0.75) 100%);
}

.ending-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  margin-bottom: 4px;
  text-align: center;
}

.ending-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  margin-bottom: 12px;
  text-align: center;
}

.ending-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.keyword-tag {
  padding: 4px 12px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  font-size: 12px;
  color: #fff;
  backdrop-filter: blur(4px);
}

.radar-wrap {
  width: 180px;
  height: 180px;
  margin-bottom: 12px;
}

.radar-wrap canvas { width: 100%; height: 100%; }

.ending-desc {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255,255,255,0.9);
  text-align: center;
  padding: 0 12px;
  margin-bottom: 16px;
  max-height: 80px;
  overflow-y: auto;
}

.ending-actions {
  display: flex;
  gap: 16px;
  margin-top: auto;
}

.ending-btn {
  padding: 10px 28px;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}

.ending-btn:active { transform: scale(0.95); }

.ending-btn.replay {
  background: rgba(255,255,255,0.9);
  color: var(--navy);
}

.ending-btn.share {
  background: linear-gradient(135deg, var(--sakura), #ff8fab);
  color: #fff;
  box-shadow: 0 3px 12px rgba(255,143,171,0.4);
}

/* ===== Gender Toggle ===== */
.gender-toggle {
  position: absolute;
  top: calc(8px + var(--safe-top));
  right: 12px;
  z-index: 25;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.75);
  border-radius: 20px;
  padding: 3px;
  backdrop-filter: blur(6px);
}

.gender-toggle.hidden { display: none; }

.gender-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: #666;
  transition: background 0.2s, color 0.2s;
}

.gender-btn.active {
  background: var(--navy);
  color: #fff;
}

/* ===== Animations ===== */
@keyframes titleFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-50px); }
}

@keyframes petalFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

.petal {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--sakura);
  border-radius: 50% 0 50% 50%;
  pointer-events: none;
  z-index: 3;
  animation: petalFall linear infinite;
}
