:root {
  --blue-950: #0d2f67;
  --blue-800: #174991;
  --blue-650: #2672c9;
  --sky: #87d7ed;
  --gold: #f8b832;
  --gold-light: #ffd972;
  --cream: #fff9ec;
  --mint: #79cdb2;
  --coral: #ff8d72;
  --ink: #18324f;
  --muted: #63758a;
  --paper: rgba(255, 253, 247, 0.94);
  --line: rgba(18, 57, 105, 0.14);
  --shadow: 0 18px 50px rgba(12, 46, 84, 0.2);
  --soft-shadow: 0 10px 28px rgba(12, 46, 84, 0.16);
  font-family: "Avenir Next", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #bfeaf4; overflow: hidden; }
body.drawer-open { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 4px solid rgba(255, 192, 46, 0.65); outline-offset: 3px; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 999px; background: white; color: var(--blue-950); font-weight: 800; transition: top .2s ease; }
.skip-link:focus { top: 16px; }
.app-shell { min-height: 100vh; }

.topbar { position: fixed; inset: 18px 20px auto; z-index: 20; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; pointer-events: none; }
.brand, .top-actions { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; width: max-content; padding: 10px 16px 10px 12px; color: var(--blue-950); text-decoration: none; border: 2px solid rgba(255,255,255,.9); border-radius: 22px; background: var(--paper); box-shadow: var(--soft-shadow); backdrop-filter: blur(16px); }
.rotary-logo { display: block; width: 130px; height: auto; flex: none; overflow: visible; }
.brand-divider { width: 1px; height: 40px; flex: none; background: rgba(13, 47, 103, .18); }
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { font-size: clamp(1rem, 2.1vw, 1.35rem); letter-spacing: .01em; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-weight: 700; }

.top-actions { display: flex; gap: 8px; padding: 7px; border: 2px solid rgba(255,255,255,.9); border-radius: 22px; background: var(--paper); box-shadow: var(--soft-shadow); backdrop-filter: blur(16px); }
.icon-button { min-height: 44px; padding: 0 13px; border: 0; border-radius: 16px; color: var(--blue-950); background: transparent; font-weight: 800; cursor: pointer; transition: transform .2s ease, background .2s ease; }
.icon-button:hover { background: #edf7ff; transform: translateY(-2px); }
.icon-button[aria-pressed="true"] { color: white; background: var(--blue-800); }
.action-text { margin-left: 4px; }

.campus { position: relative; width: 100vw; height: 100vh; min-height: 650px; isolation: isolate; overflow: hidden; background: #88d9eb; }
.campus::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(23,73,145,.08), transparent 26%, transparent 72%, rgba(5,42,75,.2)); }
.map-stage { position: absolute; left: 50%; top: 50%; width: max(100vw, 177.78vh); height: max(100vh, 56.25vw); transform: translate(-50%, -50%); }
.campus-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.sea-glow { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(circle at 52% 52%, transparent 40%, rgba(7,64,102,.08) 78%); }
.floating-cloud { position: absolute; z-index: 2; width: 180px; height: 55px; border-radius: 999px; background: rgba(255,255,255,.75); filter: blur(1px); opacity: .66; animation: cloud-drift 24s linear infinite; pointer-events: none; }
.floating-cloud::before, .floating-cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.floating-cloud::before { width: 74px; height: 74px; left: 40px; bottom: 12px; }
.floating-cloud::after { width: 92px; height: 92px; right: 24px; bottom: 3px; }
.cloud-one { left: -170px; top: 18%; }
.cloud-two { left: 35%; top: 72%; transform: scale(.7); animation-delay: -12s; opacity: .42; }

.welcome-card { position: absolute; left: clamp(18px, 4vw, 60px); bottom: clamp(24px, 6vh, 70px); z-index: 8; width: min(420px, calc(100vw - 36px)); padding: 24px; border: 2px solid rgba(255,255,255,.92); border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); backdrop-filter: blur(18px); transition: opacity .35s ease, transform .35s ease; }
.welcome-card.is-hidden { opacity: 0; transform: translateY(22px) scale(.96); pointer-events: none; }
.welcome-close { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf4f8; color: var(--blue-950); font-size: 1.4rem; cursor: pointer; }
.eyebrow { margin: 0 0 8px; color: var(--coral); font-size: .72rem; font-weight: 900; letter-spacing: .13em; }
.welcome-card h1 { max-width: 330px; margin: 0; color: var(--blue-950); font-size: clamp(1.6rem, 3vw, 2.35rem); line-height: 1.18; letter-spacing: -.04em; }
.welcome-card p:not(.eyebrow) { margin: 14px 0 20px; color: #50667c; line-height: 1.7; font-weight: 650; }
.welcome-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 48px; padding: 0 20px; border: 0; border-radius: 16px; background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--blue-950); box-shadow: 0 8px 0 #d8991a, 0 14px 24px rgba(124,82,0,.18); font-weight: 900; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 10px 0 #d8991a, 0 16px 26px rgba(124,82,0,.2); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 3px 0 #d8991a; }
.text-button { border: 0; background: transparent; color: var(--blue-800); font-weight: 850; cursor: pointer; }

.hotspots { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.hotspot { position: absolute; display: flex; align-items: center; gap: 9px; min-height: 52px; padding: 7px 14px 7px 8px; border: 3px solid white; border-radius: 18px; color: white; background: var(--blue-800); box-shadow: 0 8px 0 var(--blue-950), 0 16px 24px rgba(8,38,75,.28); font-weight: 900; cursor: pointer; pointer-events: auto; transform: translate(-50%, -50%); transition: transform .2s ease, background .2s ease, box-shadow .2s ease; animation: hotspot-bob 3.4s ease-in-out infinite; }
.hotspot:hover { background: #2265b5; transform: translate(-50%, -56%) scale(1.04); }
.hotspot:active { transform: translate(-50%, -43%); box-shadow: 0 3px 0 var(--blue-950); }
.hotspot::after { content: ""; position: absolute; left: 50%; bottom: -14px; width: 12px; height: 12px; border-right: 3px solid white; border-bottom: 3px solid white; background: var(--blue-800); transform: translateX(-50%) rotate(45deg); }
.hotspot-icon { display: grid; place-items: center; width: 35px; height: 35px; flex: none; border-radius: 13px; background: white; color: var(--blue-800); }
.hotspot span:last-child { display: grid; white-space: nowrap; }
.hotspot small { color: #bdeaff; font-size: .65rem; line-height: 1.1; }
.hotspot-principal { left: 20%; top: 26%; animation-delay: -.5s; }
.hotspot-classroom { left: 49%; top: 25%; animation-delay: -1.2s; }
.hotspot-library { left: 79%; top: 27%; animation-delay: -2.1s; }
.hotspot-plaza { left: 52%; top: 54%; animation-delay: -.8s; }
.hotspot-auditorium { left: 79%; top: 63%; animation-delay: -1.7s; }

.campus-status { position: absolute; z-index: 7; right: 24px; bottom: 24px; display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border: 2px solid white; border-radius: 22px; background: var(--paper); box-shadow: var(--soft-shadow); }
.status-face { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 15px; color: white; background: var(--mint); font-size: 1.4rem; font-weight: 900; }
.campus-status div:last-child { display: grid; }
.campus-status strong { color: var(--blue-950); }
.campus-status span { color: var(--muted); font-size: .78rem; font-weight: 700; }
.scene-hint { position: absolute; left: 50%; bottom: 26px; z-index: 5; margin: 0; padding: 9px 14px; border-radius: 999px; color: white; background: rgba(6,44,78,.64); backdrop-filter: blur(12px); font-size: .8rem; font-weight: 800; transform: translateX(-50%); }
.mobile-campus-nav { display: none; }

.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(5,27,54,.42); backdrop-filter: blur(5px); }
.drawer { position: fixed; z-index: 50; top: 12px; right: 12px; bottom: 12px; width: min(460px, calc(100vw - 24px)); padding: 28px; border: 2px solid rgba(255,255,255,.85); border-radius: 30px; background: #fffdf6; box-shadow: -24px 0 70px rgba(8,35,72,.28); overflow-y: auto; transform: translateX(calc(100% + 40px)); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.drawer.is-open { transform: translateX(0); }
.drawer-handle { display: none; }
.drawer-close { position: absolute; top: 16px; right: 16px; z-index: 2; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; color: var(--blue-950); background: #edf4f8; font-size: 1.55rem; cursor: pointer; }
.room-hero { position: relative; margin: -28px -28px 24px; min-height: 190px; padding: 30px 70px 26px 28px; border-radius: 28px 28px 38px 38px; color: white; background: linear-gradient(145deg, var(--blue-950), var(--blue-650)); overflow: hidden; }
.room-hero .room-emoji { display: block; margin-bottom: 20px; font-size: 2.4rem; }
.room-hero .eyebrow { color: var(--gold-light); }
.room-hero h2 { margin: 0; font-size: 2rem; letter-spacing: -.04em; }
.room-hero p { margin: 10px 0 0; color: #d9ebff; line-height: 1.6; }
.room-intro { color: #4d6279; line-height: 1.75; font-weight: 600; }
.card-list { display: grid; gap: 10px; margin: 20px 0; }
.room-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 18px; color: inherit; background: white; text-align: left; text-decoration: none; box-shadow: 0 5px 16px rgba(12,46,84,.07); transition: transform .2s ease, border-color .2s ease; }
.room-card:hover { border-color: #8fc5ff; transform: translateY(-2px); }
.room-card-button { cursor: pointer; }
.room-card-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: #eaf5ff; font-size: 1.25rem; }
.room-card div { display: grid; gap: 3px; }
.room-card strong { color: var(--blue-950); }
.room-card small { color: var(--muted); line-height: 1.45; }
.room-card-arrow { color: var(--blue-650); font-weight: 900; }
.room-cta { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 16px; color: var(--blue-950); background: var(--gold); text-decoration: none; font-weight: 900; cursor: pointer; }
.room-note { margin-top: 18px; padding: 14px; border-radius: 16px; color: #50677e; background: #eef7f4; font-size: .86rem; line-height: 1.6; }

.lesson-hero { min-height: 225px; padding-top: 70px; }
.lesson-back { position: absolute; top: 22px; left: 24px; min-height: 34px; padding: 0 12px; border: 1px solid rgba(255,255,255,.34); border-radius: 999px; color: white; background: rgba(255,255,255,.12); font-size: .78rem; font-weight: 850; cursor: pointer; }
.lesson-duration { display: inline-flex; margin-top: 14px; padding: 5px 9px; border-radius: 999px; color: var(--blue-950); background: var(--gold-light); font-size: .72rem; font-weight: 900; }
.lesson-lead { margin: 0 0 20px; color: #415c75; font-size: 1.02rem; font-weight: 700; line-height: 1.75; }
.lesson-section { margin: 14px 0; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 6px 18px rgba(12,46,84,.06); }
.lesson-section h3 { margin: 0; color: var(--blue-950); font-size: 1rem; line-height: 1.55; }
.lesson-points { display: grid; gap: 11px; margin: 14px 0 0; padding-left: 22px; color: #4c637a; line-height: 1.65; }
.lesson-points li::marker { color: var(--coral); font-weight: 900; }
.lesson-practice { border-color: rgba(121,205,178,.48); background: #eef9f5; }
.lesson-check { border-color: rgba(248,184,50,.5); background: #fff7de; }
.lesson-kicker { margin: 0 0 7px; color: var(--blue-650); font-size: .68rem; font-weight: 900; letter-spacing: .12em; }
.lesson-sources { display: grid; gap: 8px; margin-top: 12px; }
.lesson-sources a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border-radius: 13px; color: var(--blue-800); background: #edf5ff; text-decoration: none; font-size: .86rem; font-weight: 850; }
.lesson-sources a:hover { background: #dfefff; }

.search-dialog { width: min(680px, calc(100vw - 24px)); max-height: min(760px, calc(100vh - 24px)); padding: 26px; border: 2px solid white; border-radius: 30px; color: var(--ink); background: #fffdf7; box-shadow: var(--shadow); }
.search-dialog::backdrop { background: rgba(5,27,54,.48); backdrop-filter: blur(7px); }
.dialog-head { position: relative; display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; color: var(--blue-950); font-size: 1.8rem; }
.dialog-close { position: static; flex: none; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 16px; border: 2px solid #cfe2f4; border-radius: 18px; background: white; }
.search-field:focus-within { border-color: var(--blue-650); box-shadow: 0 0 0 4px rgba(38,114,201,.12); }
.search-field input { width: 100%; min-height: 52px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-results { display: grid; gap: 10px; margin-top: 16px; overflow-y: auto; }
.search-empty { padding: 28px; border-radius: 18px; text-align: center; color: var(--muted); background: #f1f6f8; }

@keyframes hotspot-bob { 0%,100% { margin-top: 0; } 50% { margin-top: -7px; } }
@keyframes cloud-drift { from { translate: -20vw 0; } to { translate: 130vw 0; } }
.motion-paused *, .motion-paused *::before, .motion-paused *::after { animation-play-state: paused !important; }

@media (max-width: 900px) {
  body { overflow: auto; background: #bfeaf4; }
  .campus { min-height: 780px; }
  .topbar { inset: 10px 10px auto; }
  .brand { padding-right: 12px; }
  .brand-copy small, .action-text { display: none; }
  .top-actions { border-radius: 18px; }
  .icon-button { width: 42px; padding: 0; }
  .hotspot { min-height: 44px; padding: 5px 10px 5px 6px; border-width: 2px; border-radius: 15px; font-size: .83rem; }
  .hotspot-icon { width: 31px; height: 31px; border-radius: 11px; }
  .hotspot small { display: none; }
  .hotspot-principal { left: 17%; top: 26%; }
  .hotspot-classroom { left: 49%; top: 25%; }
  .hotspot-library { left: 81%; top: 28%; }
  .hotspot-plaza { left: 51%; top: 52%; }
  .hotspot-auditorium { left: 80%; top: 62%; }
  .welcome-card { bottom: 22px; }
  .campus-status, .scene-hint { display: none; }
}

@media (max-width: 720px) {
  body { overflow: hidden; overscroll-behavior: none; }
  .app-shell, .campus { height: 100svh; min-height: 0; }
  .campus::after { background: linear-gradient(180deg, rgba(8,44,86,.04) 45%, rgba(5,35,67,.5) 100%); }
  .map-stage { left: 52%; width: max(100vw, 177.78svh); height: max(100svh, 56.25vw); }
  .floating-cloud { opacity: .3; }

  .topbar { inset: max(8px, env(safe-area-inset-top)) 8px auto; gap: 8px; }
  .brand { gap: 7px; padding: 7px 10px 7px 8px; border-radius: 18px; }
  .rotary-logo { width: 82px; }
  .brand-divider { height: 30px; }
  .brand-copy strong { font-size: .82rem; }
  .brand-copy small { display: none; }
  .top-actions { gap: 2px; padding: 4px; border-radius: 18px; }
  .icon-button { width: 44px; min-height: 44px; }
  #guideButton { display: none; }

  .hotspots { display: none; }
  .welcome-card { left: 10px; right: 10px; bottom: calc(88px + env(safe-area-inset-bottom)); width: auto; padding: 15px 48px 15px 16px; border-radius: 22px; }
  .welcome-close { top: 10px; right: 10px; width: 36px; height: 36px; }
  .welcome-card .eyebrow { display: none; }
  .welcome-card h1 { max-width: none; font-size: 1.2rem; letter-spacing: -.02em; }
  .welcome-card p:not(.eyebrow) { display: -webkit-box; margin: 7px 0 12px; overflow: hidden; font-size: .82rem; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .welcome-actions { gap: 10px; }
  .primary-button { min-height: 44px; padding: 0 15px; border-radius: 14px; box-shadow: 0 5px 0 #d8991a, 0 10px 18px rgba(124,82,0,.18); font-size: .86rem; }
  .text-button { min-height: 44px; font-size: .82rem; }

  .mobile-campus-nav { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 30; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; padding: 6px; border: 2px solid rgba(255,255,255,.92); border-radius: 23px; background: rgba(255,253,247,.96); box-shadow: 0 14px 34px rgba(6,35,68,.28); backdrop-filter: blur(18px); }
  .mobile-campus-button { display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; min-height: 62px; padding: 5px 2px; border: 0; border-radius: 16px; color: var(--blue-950); background: transparent; cursor: pointer; }
  .mobile-campus-button span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 11px; color: var(--blue-800); background: #eaf5ff; font-size: 1rem; font-weight: 900; }
  .mobile-campus-button strong { overflow: hidden; font-size: .66rem; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-campus-button.is-active { color: white; background: var(--blue-800); }
  .mobile-campus-button.is-active span { color: var(--blue-950); background: var(--gold-light); }

  .backdrop { z-index: 40; background: rgba(5,27,54,.28); backdrop-filter: none; }
  .drawer { inset: 0; width: 100%; height: 100dvh; max-height: none; padding: 18px 18px calc(30px + env(safe-area-inset-bottom)); border: 0; border-radius: 0; box-shadow: none; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; transform: translateY(100%); }
  .drawer.is-open { transform: translateY(0); }
  .drawer-handle { display: none; }
  .drawer-close { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; width: 48px; height: 48px; box-shadow: 0 5px 16px rgba(8,35,72,.18); }
  .room-hero { margin: -18px -18px 20px; min-height: 190px; padding: calc(72px + env(safe-area-inset-top)) 72px 24px 20px; border-radius: 0 0 30px 30px; }
  .room-hero .room-emoji { margin-bottom: 14px; font-size: 2rem; }
  .room-hero h2 { font-size: 1.75rem; }
  .room-hero p { font-size: .9rem; line-height: 1.55; }
  .room-intro { display: none; }
  .card-list { gap: 10px; margin: 14px 0; }
  .room-card { min-height: 70px; padding: 13px 12px; border-radius: 18px; }
  .room-card-icon { width: 44px; height: 44px; }
  .room-card strong { font-size: 1rem; }
  .room-card small { font-size: .78rem; }
  .room-cta { width: 100%; min-height: 52px; }
  .room-note { margin-bottom: 0; }
  .lesson-hero { min-height: 220px; padding-top: calc(86px + env(safe-area-inset-top)); }
  .lesson-back { top: max(18px, env(safe-area-inset-top)); left: 16px; min-height: 44px; padding: 0 14px; }
  .lesson-lead { font-size: 1rem; line-height: 1.7; }
  .lesson-section { padding: 16px; border-radius: 18px; }
  .lesson-points { gap: 12px; line-height: 1.6; }
  .lesson-sources a { min-height: 48px; }

  .search-dialog { inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); border: 0; border-radius: 0; overflow: hidden; }
  .dialog-head { margin-bottom: 14px; }
  .dialog-head h2 { font-size: 1.55rem; }
  .dialog-close { position: static; width: 48px; height: 48px; }
  .search-field { border-radius: 16px; }
  .search-field input { min-height: 54px; font-size: 16px; }
  .search-results { max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding-bottom: 16px; overscroll-behavior: contain; }
}

@media (max-width: 720px) and (max-height: 650px) {
  .welcome-card p:not(.eyebrow), .welcome-actions .text-button { display: none; }
  .welcome-card { padding-top: 14px; padding-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
