/* Section numbering follows the approved categories; rule order preserves the V3 cascade. */

/* 2. COLORS & TYPOGRAPHY */
:root {
  --ui-primary: #121314;
  --ui-secondary: #292C2E;
  --ui-accent: #FAEEC8;
  --ui-text: #FFFFFF;
  --ui-muted: #C6C5BF;
  --ui-hover: #E5D3A6;
  --ui-border: #FAEEC899;
  --accent: var(--ui-accent);
  --border: var(--ui-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
  color: var(--ui-text);
  background: var(--ui-primary);
}

/* 1. GLOBAL STYLES */
*{box-sizing:border-box}html,body{width:100%;height:100%;margin:0;overflow:hidden}button{font:inherit;cursor:pointer}button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled{cursor:wait;opacity:.5}[hidden]{display:none!important}
#renderCanvas{display:block;width:100%;height:100%;touch-action:none;outline:none}

/* 3. NAVIGATION MENU */
#panel{position:fixed;z-index:10;top:max(20px,env(safe-area-inset-top));left:max(20px,env(safe-area-inset-left));width:min(326px,calc(100vw - 40px));max-height:calc(100dvh - 40px);display:flex;flex-direction:column;border:1px solid var(--border);border-radius:18px;background:#112130ed;box-shadow:0 14px 45px #0004;overflow:hidden}
#panelHead{display:flex;align-items:center;gap:12px;padding:17px 15px 17px 19px;flex-shrink:0}.brand{min-width:0;flex:1}.brand strong{display:block;font-size:15px;font-weight:650;letter-spacing:.015em}
#togglePanel{width:44px;height:44px;flex-shrink:0;display:grid;place-items:center;border:1px solid var(--border);border-radius:12px;background:#ffffff08;color:var(--accent)}#togglePanel:hover{background:#ffffff14}#togglePanel svg{width:20px;height:20px}
#panelBody{padding:0 16px 16px;overflow:auto;overscroll-behavior:contain;border-top:1px solid var(--border)}#panel.collapsed #panelBody{display:none}
.destGroup{margin:19px 0 15px}.destTitle{font-size:10px;font-weight:650;letter-spacing:.14em;color:#9bb5c0;margin:0 7px 8px}.dest{width:100%;display:flex;align-items:center;gap:10px;min-height:44px;padding:10px 9px;border:0;border-radius:9px;background:transparent;color:#eaf2f6;text-align:left;font-size:12.5px;line-height:1.6;overflow-wrap:anywhere}.dest::before{content:"";width:5px;height:5px;flex-shrink:0;border:1px solid #8eb5bf;border-radius:50%}.dest:hover,.dest[aria-current="location"]{background:#ffffff0a;color:#b9f1eb}.dest[aria-current="location"]::before{background:var(--accent);border-color:var(--accent)}
#goEntrance{display:flex;align-items:center;justify-content:center;gap:9px;width:100%;min-height:44px;margin-top:16px;padding:10px;border:1px solid #a2ded82e;border-radius:10px;background:#a2ded80b;color:#bfe2e1;font-size:12px}#goEntrance:hover{background:#a2ded81a}

/* 5. MOBILE CONTROLS & JOYSTICK */
#touchUI{display:none;position:fixed;inset:0;z-index:12;pointer-events:none}#stick{position:absolute;left:max(20px,env(safe-area-inset-left));bottom:max(20px,env(safe-area-inset-bottom));width:120px;height:120px;border:1px solid #d2f3f373;border-radius:50%;background:#10293870;pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none}#stick::before{content:"";position:absolute;inset:17px;border:1px solid #ffffff17;border-radius:50%}#knob{position:absolute;left:38px;top:38px;width:42px;height:42px;border:1px solid #e9ffffa8;border-radius:50%;background:#b7e8e396;pointer-events:none;will-change:transform}

/* 4. LOADING SCREEN */
#screenFade{position:fixed;inset:0;background:#08131e;z-index:30;opacity:0;pointer-events:none;transition:opacity .42s ease-in-out}#screenFade.visible{opacity:1;pointer-events:auto}
#loadingScreen{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;text-align:center;padding:30px;background:radial-gradient(ellipse at 50% 30%,#203e4a 0,#101f2d 48%,#0b1520 100%)}.loadingContent{width:min(360px,100%)}.loadingMark{display:grid;place-items:center;width:66px;height:66px;margin:0 auto 26px;border:1px solid #a2ded850;border-radius:19px;color:var(--accent);font-size:23px;font-weight:650;letter-spacing:.06em;background:#a2ded806}.loadingContent h1{font-size:23px;font-weight:550;letter-spacing:.015em;margin:0 0 10px}.loadingContent p{font-size:13px;line-height:1.8;color:#b6cbd2;margin:0}.loadingTrack{width:114px;height:2px;margin:29px auto;background:#ffffff13;overflow:hidden;border-radius:2px}.loadingTrack::after{content:"";display:block;width:45%;height:100%;background:var(--accent);animation:loading 1.6s ease-in-out infinite}#loadingScreen.failed .loadingTrack{display:none}@keyframes loading{from{transform:translateX(-110%)}to{transform:translateX(330%)}}
.retry{min-height:44px;padding:10px 18px;margin-top:20px;border:1px solid #a2ded85c;border-radius:10px;background:#a2ded815;color:#e3fbf8}.retry:hover{background:#a2ded82b}
#feedback{position:fixed;z-index:40;left:50%;bottom:max(22px,env(safe-area-inset-bottom));transform:translateX(-50%);max-width:min(440px,calc(100vw - 40px));padding:12px 18px;background:#122c3af5;border:1px solid #a2ded845;border-radius:13px;color:#e6f4f5;font-size:12px;line-height:1.7;text-align:center;box-shadow:0 8px 28px #0004}#feedback .retry{display:block;margin:8px auto 0}#feedback.pending::before{content:"";display:inline-block;width:7px;height:7px;margin-right:9px;border-radius:50%;background:var(--accent)}

/* 6. MINIMAP */
/* No minimap rules exist in V3. */

/* 7. RESPONSIVE DESIGN */
@media(pointer:coarse){#touchUI{display:block}#panel{top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));left:auto;width:min(330px,calc(100vw - 24px));max-height:calc(100dvh - 180px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}#panelHead{padding:10px 11px 10px 15px}.brand strong{font-size:14px}#panel.collapsed{width:min(268px,calc(100vw - 24px))}#feedback{bottom:max(153px,calc(env(safe-area-inset-bottom) + 135px))}}
@media(max-height:480px) and (pointer:coarse){#panel{max-height:calc(100dvh - 165px - env(safe-area-inset-top))}#panelHead{padding:6px 10px}.destGroup{margin:12px 0}#stick{width:108px;height:108px}#knob{left:32px;top:32px}#feedback{bottom:15px;left:auto;right:16px;transform:none;max-width:calc(100vw - 160px)}}
@media(prefers-reduced-motion:reduce){#screenFade{transition-duration:.05s}.loadingTrack::after{animation:none;transform:translateX(60%)}}

@media (pointer:fine) {
  #renderCanvas { cursor: grab; }
  #renderCanvas.clickable { cursor: pointer; }
  #renderCanvas.dragging { cursor: grabbing; }
}
#crosshair {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 6px; height: 6px; background: var(--ui-accent); border-radius: 50%; z-index: 12; pointer-events: none;
}
#tutorial {
  position: fixed; inset: 0; z-index: 13; display: grid; place-items: center;
  pointer-events: none; color: var(--ui-accent); text-align: center; font-size: 16px;
  font-weight: 600; text-shadow: 0 1px 5px #000, 0 0 8px #000; transition: opacity 350ms;
}
#tutorial[data-stage="0"] { opacity: 0; }
#tutorial[data-mobile="true"] .desktopInstruction,
#tutorial[data-mobile="false"] .mobileInstruction { display: none; }
#tutorial p { margin: 10px 8px 6px; }
.tutorialMouse, .tutorialHand { animation: tutorial-swipe 2.4s ease-in-out infinite; }
.mouseButton { animation: tutorial-press 2.4s ease-in-out infinite; }
.keyGroups { display: flex; align-items: center; justify-content: center; gap: 18px; }
.keyGroup { display: grid; grid-template-columns: repeat(3,40px); gap: 4px; }
.keyGroup kbd:first-child { grid-column: 2; }
.keyGroup kbd:nth-child(2) { grid-column: 1; animation-delay: .8s; }
.keyGroup kbd:nth-child(3) { animation-delay: 1.6s; }
.keyGroup kbd:nth-child(4) { animation-delay: 2.4s; }
#tutorial kbd {
  display: inline-grid; place-items: center; min-height: 24px; padding: 2px 8px;
  background: #121314e0; border: 1px solid var(--ui-border); border-radius: 6px;
}
#tutorial .keyGroup kbd { height: 38px; animation: tutorial-key 3.2s linear infinite; }
.stickHand {
  position: absolute; left: calc(max(20px, env(safe-area-inset-left)) + 44px);
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 42px);
  animation: tutorial-stick 3.2s ease-in-out infinite;
}
@keyframes tutorial-swipe { 0%,100% {transform:translateX(-24px)} 50% {transform:translateX(24px)} }
@keyframes tutorial-press { 0%,100% {opacity:.55} 50% {opacity:1} }
@keyframes tutorial-key { 0%,24% {background:var(--ui-accent);color:var(--ui-primary);text-shadow:none} 25%,100% {background:#121314e0} }
@keyframes tutorial-stick {
  0%,100% {transform:translateY(-26px)} 25% {transform:translateX(26px)}
  50% {transform:translateY(26px)} 75% {transform:translateX(-26px)}
}
@media (prefers-reduced-motion:reduce) {
  #tutorial, #tutorial * { animation: none !important; transition:none; }
}

#landing.exterior #landingPanel, #landing.exterior #landingBrand { display: none; }
#tourDialog {
  width: min(570px,calc(100vw - 28px)); max-height: min(94dvh,880px);
  flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--ui-border);
  border-radius: 14px; color: var(--ui-text); background: var(--ui-primary);
  box-shadow: 0 14px 50px #0009; overflow: hidden;
}
#tourDialog[open] { display:flex; animation: panel-in 250ms ease-out; }
#tourDialog::backdrop { background: #0006; backdrop-filter: blur(.7px); }
#tourDialog[data-panel="guide"]::backdrop { background: #00000059; backdrop-filter: blur(4px); }
.dialogHeading { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.dialogHeading h2 { color:var(--ui-accent); margin:0; font-size:clamp(19px,3vw,25px); }
.dialogBody { overflow:auto; padding:1px 3px; overscroll-behavior:contain; }
.dialogBody p { line-height:1.5; }
.dialogFooter { display:flex; justify-content:flex-end; }
.secondary {
  min-width:44px; min-height:44px; border:1px solid var(--ui-border); border-radius:10px;
  padding:8px 12px; color:var(--ui-text); background:var(--ui-secondary);
  transition:background-color 180ms,color 180ms;
}
.secondary:hover { background:var(--ui-hover); color:var(--ui-primary); }
.professors { display:grid; gap:12px; }
.professor { border:1px solid #faeec830; padding:12px; border-radius:10px; background:var(--ui-secondary); }
.professor h3, .dailyLesson h3 { margin:0 0 8px; color:var(--ui-accent); font-size:17px; }
.professor p { margin:7px 0; }
.professor a { color:var(--ui-accent); overflow-wrap:anywhere; }
.emailRow { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.copyStatus { color:var(--ui-muted); font-size:.86em; }
#tourDialog[data-panel="schedule"] { width:min(1200px,96vw); }
.scheduleStatus { color:var(--ui-muted); font-size:13px; margin:0 0 10px; }
.scheduleWeek { display:grid; grid-template-columns:45px repeat(5,minmax(0,1fr)); min-height:270px; height:min(67dvh,650px); padding:0 0 10px; }
.timeAxis, .scheduleCells { position:relative; }
.timeAxis { margin-top:30px; }
.timeAxis span { position:absolute; right:7px; transform:translateY(-50%); font-size:11px; color:var(--ui-muted); }
.scheduleColumn { display:grid; grid-template-rows:30px 1fr; min-width:0; }
.scheduleColumn h3 { margin:0; text-align:center; color:var(--ui-accent); font-size:13px; }
.scheduleCells { border:1px solid #faeec83d; background:repeating-linear-gradient(to bottom,transparent 0 calc(100% / 11 - 1px),#ffffff20 calc(100% / 11 - 1px) calc(100% / 11)); }
.lesson {
  position:absolute; top:var(--start); height:var(--duration);
  width:calc(100% / var(--lanes)); left:calc(var(--lane) * 100% / var(--lanes));
  border:1px solid #faeec86f; border-radius:5px; background:var(--ui-secondary);
  padding:4px 6px; overflow:hidden; font-size:12px;
}
.lesson strong, .lesson small { display:block; }
.lesson:hover, .lesson:focus { z-index:2; height:auto; min-height:var(--duration); width:100%; left:0; overflow:visible; }
.lesson small { margin-top:3px; color:var(--ui-muted); font-size:10px; }
.scheduleDaily { display:none; }
.scheduleDaily select { width:100%; min-height:44px; margin-bottom:10px; background:var(--ui-secondary); color:var(--ui-text); border:1px solid var(--ui-border); border-radius:7px; padding:8px; font:inherit; }
.dailyLessons { display:grid; gap:8px; }
.dailyLesson { padding:10px 12px; background:var(--ui-secondary); border-radius:8px; }
.dailyLesson p { margin:0; font-size:14px; }
@media (max-width:740px),(pointer:coarse) {
  .scheduleWeek { display:none; }
  .scheduleDaily { display:block; }
}
@keyframes panel-in { from {opacity:0} to {opacity:1} }
@media (prefers-reduced-motion:reduce) { #tourDialog[open] { animation:none; } }


button, summary, .settings label {
  user-select:none;
  -webkit-user-select:none;
  caret-color:transparent;
}
.copyEmail { display:inline-grid; place-items:center; padding:0; }
.tutorialMouse, .tutorialHand, .stickHand { overflow:visible; }
.tutorialPulse {
  transform-box:fill-box; transform-origin:center; vector-effect:non-scaling-stroke;
  animation:tutorial-pulse 2.4s ease-out infinite;
}
.stickHand .tutorialPulse { animation-duration:3.2s; }
@keyframes tutorial-pulse {
  0%, 66%, 100% { opacity:0; transform:scale(1); }
  15% { opacity:1; transform:scale(1); }
  62% { opacity:0; transform:scale(4.75); }
}
@media(prefers-reduced-motion:reduce) { .tutorialPulse { opacity:.65; } }

.dialogHeading, .dialogFooter { flex:none; }
.dialogBody { min-height:0; }
.dialogActions:not(:empty) { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.dialogFooter { flex-wrap:wrap; align-items:center; gap:8px; }
.dialogFooter .dialogActions:not(:empty) { margin-inline-end:auto; }
.dialogFooter a.secondary { display:inline-flex; align-items:center; text-decoration:none; }

#tourDialog[data-panel="announcement"] {
  width:min(660px,calc(100vw - 24px)); opacity:0;
  background:linear-gradient(145deg,#292c2efc,#121314fc 55%);
  transition:opacity 180ms ease, display 180ms allow-discrete, overlay 180ms allow-discrete;
}
#tourDialog[data-panel="announcement"][open] { opacity:1; animation:none; }
#tourDialog[data-panel="announcement"]:not([open]) { pointer-events:none; }
#tourDialog[data-panel="announcement"]::backdrop {
  background:#0000; backdrop-filter:blur(0);
  transition:background 180ms ease, backdrop-filter 180ms ease, display 180ms allow-discrete, overlay 180ms allow-discrete;
}
#tourDialog[data-panel="announcement"][open]::backdrop { background:#0007; backdrop-filter:blur(4px); }
@starting-style {
  #tourDialog[data-panel="announcement"][open] { opacity:0; }
  #tourDialog[data-panel="announcement"][open]::backdrop { background:#0000; backdrop-filter:blur(0); }
}
#tourDialog[data-panel="announcement"] .dialogBody { touch-action:pan-y; }
.announcementList { display:grid; gap:12px; overflow-wrap:anywhere; }
.announcementCard { padding:clamp(12px,3vw,18px); border:1px solid #faeec836; border-radius:12px; background:#ffffff07; }
.announcementCard h3 { margin:.35em 0; color:var(--ui-accent); font-size:clamp(16px,3vw,20px); }
.announcementMeta { display:flex; flex-wrap:wrap; align-items:center; gap:5px 12px; font-size:12px; color:var(--ui-muted); }
.announcementPinned { color:var(--ui-accent); }
.announcementPreview, .announcementState { margin:8px 0; }
.announcementDetails { margin:8px 0; line-height:1.55; }
.announcementDetails summary { cursor:pointer; padding:6px 0; color:var(--ui-accent); }
.announcementDetails pre { white-space:pre-wrap; }
.announcementDetails table { max-width:100%; }
.announcementTags { display:flex; flex-wrap:wrap; gap:6px; list-style:none; margin:9px 0; padding:0; }
.announcementTags li { padding:3px 7px; border:1px solid #faeec836; border-radius:12px; color:var(--ui-muted); font-size:11px; }
.announcementAttachments { margin:8px 0; padding-inline-start:20px; }
.announcementCard a { color:var(--ui-accent); text-underline-offset:.18em; }
.announcementOfficial { display:inline-block; padding-block:6px; font-size:13px; }
.announcementList > button { justify-self:start; }
@media (prefers-reduced-motion:reduce) {
  #tourDialog[data-panel="announcement"], #tourDialog[data-panel="announcement"]::backdrop { transition:none; }
}

#tourDialog[data-panel="restricted"] {
  width:min(550px,calc(100vw - 24px));
  background:linear-gradient(145deg,#292c2e,#121314 66%);
}
#tourDialog[data-panel="restricted"]::backdrop { background:#0007; backdrop-filter:blur(4px); }
#tourDialog[data-panel="restricted"] .dialogBody p { margin:0 0 7px; }
.restrictedLogin { background:var(--ui-accent); color:var(--ui-primary); }
.restrictedLogin:hover { background:var(--ui-hover); }
