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

:root {
  --bg: #0f0e17;
  --surface: #16141f;
  --surface-2: #1e1b2e;
  --border: rgba(255,255,255,0.08);
  --accent: #c8b4e3;
  --accent-glow: rgba(200,180,227,0.18);
  --gold: #e8d5a3;
  --gold-glow: rgba(232,213,163,0.15);
  --text: #f0edf8;
  --text-muted: rgba(240,237,248,0.55);
  --radius: 20px;
  --radius-sm: 12px;
  --font: 'Noto Serif TC', 'Georgia', serif;
  --font-ui: 'Noto Sans TC', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Ambient Light Background ─── */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 80vw;
  background: radial-gradient(ellipse, rgba(138, 99, 210, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(ellipse, rgba(200, 180, 227, 0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── App Wrapper ─── */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Screen System ─── */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 0 env(safe-area-inset-bottom, 24px);
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: flex;
}

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

/* ─── Home Screen ─── */
#home-screen {
  padding-top: env(safe-area-inset-top, 0);
}

.home-header {
  padding: 56px 28px 32px;
  text-align: center;
}

.home-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  background: radial-gradient(ellipse at 40% 40%, rgba(200,180,227,0.35), rgba(138,99,210,0.1));
  border-radius: 50%;
  border: 1px solid rgba(200,180,227,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.home-subtitle {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 16px;
  opacity: 0.7;
}

.home-title {
  font-size: clamp(20px, 5.5vw, 26px);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  letter-spacing: 0.04em;
}

.home-title em {
  font-style: normal;
  color: var(--accent);
}

/* ─── Category Grid ─── */
.category-grid {
  flex: 1;
  padding: 8px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.category-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.category-btn:active {
  transform: scale(0.98);
  border-color: rgba(200,180,227,0.3);
}

.category-btn:active::before {
  opacity: 1;
}

.cat-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
}

.cat-label {
  flex: 1;
  font-size: 15px;
}

.cat-arrow {
  font-size: 12px;
  opacity: 0.3;
  font-style: normal;
  font-family: var(--font-ui);
}

/* ─── Player Screen ─── */
#player-screen {
  padding-top: env(safe-area-inset-top, 0);
}

.player-nav {
  display: flex;
  align-items: center;
  padding: 16px 20px 8px;
  gap: 12px;
}

.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  font-family: var(--font-ui);
  transition: all 0.2s;
  flex-shrink: 0;
}

.back-btn:active {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.player-category-name {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.12em;
  opacity: 0.8;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-counter {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Video Player ─── */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ─── Video Info ─── */
.video-info {
  padding: 24px 24px 0;
}

.video-title {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 16px;
}

.video-divider {
  width: 32px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin-bottom: 16px;
}

.video-state {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin-bottom: 14px;
  line-height: 1.7;
}

.video-guide {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.85;
  letter-spacing: 0.06em;
  font-style: italic;
  padding: 14px 16px;
  background: rgba(200,180,227,0.05);
  border-left: 2px solid rgba(200,180,227,0.2);
  border-radius: 0 8px 8px 0;
}

/* ─── Player Actions ─── */
.player-actions {
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.btn-next {
  width: 100%;
  padding: 17px 24px;
  background: linear-gradient(135deg, rgba(138,99,210,0.25) 0%, rgba(200,180,227,0.12) 100%);
  border: 1px solid rgba(200,180,227,0.3);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn-next::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(200,180,227,0.15), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
}

.btn-next:active {
  transform: scale(0.98);
  background: linear-gradient(135deg, rgba(138,99,210,0.35) 0%, rgba(200,180,227,0.2) 100%);
}

.btn-next:active::after {
  opacity: 1;
}

.btn-home {
  width: 100%;
  padding: 15px 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-home:active {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

/* ─── Light Orb Decoration ─── */
.orb {
  pointer-events: none;
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  z-index: 0;
}

.orb-1 {
  width: 200px;
  height: 200px;
  top: 10%;
  left: -60px;
  background: rgba(138, 99, 210, 0.08);
  animation: drift 12s ease-in-out infinite alternate;
}

.orb-2 {
  width: 160px;
  height: 160px;
  bottom: 20%;
  right: -40px;
  background: rgba(200, 180, 227, 0.07);
  animation: drift 16s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from { transform: translateY(0px) scale(1); }
  to   { transform: translateY(20px) scale(1.08); }
}

/* ─── Transitions between screens ─── */
.screen {
  animation: screenIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ─── Safe area support ─── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .player-actions {
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
  .category-grid {
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
}

/* ─── Scrollbar hide ─── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }
