@font-face {
  font-family: "Noto Sans CJK KR";
  src: url("../vendor/uos-slide-template/fonts/NotoSansCJKkr-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans CJK KR";
  src: url("../vendor/uos-slide-template/fonts/NotoSansCJKkr-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans CJK KR";
  src: url("../vendor/uos-slide-template/fonts/NotoSansCJKkr-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --flight-bg: #071522;
  --instrument: #0e2234;
  --uos-blue: #004094;
  --live-blue: #48a9ff;
  --stable: #45e3c6;
  --warning: #ffbf5b;
  --text: #f4f8fc;
  --muted: #91a4b7;
  --line: #294257;
  --ground: #725a3d;
  --dock-height: 104px;
  font-family: "Noto Sans CJK KR", system-ui, sans-serif;
  background: var(--flight-bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--flight-bg);
  overflow-x: hidden;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--flight-bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  clip-path: polygon(0 4px, 4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%);
}

button:focus-visible,
input:focus-visible,
.joystick:focus-visible {
  outline: 3px solid var(--warning);
  outline-offset: 3px;
}

button.primary {
  min-height: 56px;
  padding: 12px 16px;
  background: var(--uos-blue);
  color: #ffffff;
  font-weight: 700;
}

button.secondary {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #49657d;
  background: #102a40;
  color: var(--text);
  font-weight: 500;
}

[hidden] {
  display: none !important;
}

.safety-boundary {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 7px max(14px, env(safe-area-inset-right)) 7px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid #35516a;
  background: #0a1c2b;
  color: #bed0df;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.sim-label {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--warning);
  border-radius: 2px;
  color: var(--warning);
  font: 700 10px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.1em;
}

.student-shell,
.presenter-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 14px max(14px, env(safe-area-inset-right)) calc(var(--dock-height) + 34px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.instrument-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  margin-bottom: 10px;
}

.eyebrow,
.step-code,
.horizon-stamp,
.challenge-line span,
.result-score span,
.score-count span {
  margin: 0;
  color: var(--live-blue);
  font: 700 10px/1.25 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.12em;
}

.instrument-header h1 {
  margin: 3px 0 0;
  font-size: clamp(20px, 6vw, 30px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.connection-state {
  flex: 0 0 auto;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
}

.connection-state span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border: 1px solid var(--warning);
  border-radius: 50%;
  background: transparent;
}

.attitude-instrument {
  position: relative;
  overflow: hidden;
  border: 1px solid #3b5870;
  border-radius: 4px;
  background: var(--instrument);
  clip-path: polygon(0 6px, 6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
}

.horizon {
  --roll: 0deg;
  --pitch: 0px;
  position: relative;
  height: clamp(214px, 35svh, 296px);
  overflow: hidden;
  background: #174d79;
  contain: paint;
}

.horizon-plane {
  position: absolute;
  top: -55%;
  left: -50%;
  width: 200%;
  height: 210%;
  transform: translateY(var(--pitch)) rotate(calc(-1 * var(--roll)));
  transform-origin: center;
  will-change: transform;
}

.horizon-sky,
.horizon-ground {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
}

.horizon-sky {
  top: 0;
  background: #1768a0;
}

.horizon-ground {
  bottom: 0;
  background: var(--ground);
}

.horizon-line {
  position: absolute;
  top: calc(50% - 1px);
  left: 0;
  width: 100%;
  height: 2px;
  background: #f0d7a1;
}

.pitch-ladder {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pitch-mark {
  position: absolute;
  left: 50%;
  width: 42px;
  height: 1px;
  background: rgba(244, 248, 252, 0.75);
  transform: translateX(-50%);
}

.pitch-mark--upper { top: 34%; }
.pitch-mark--center { top: 50%; width: 84px; }
.pitch-mark--lower { top: 66%; }

.aircraft-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 142px;
  height: 34px;
  transform: translate(-50%, -50%);
}

.aircraft-reticle::before,
.aircraft-reticle::after,
.aircraft-reticle span::before,
.aircraft-reticle span::after {
  content: "";
  position: absolute;
  background: #ffffff;
}

.aircraft-reticle::before,
.aircraft-reticle::after {
  top: 16px;
  width: 54px;
  height: 3px;
}

.aircraft-reticle::before { left: 0; }
.aircraft-reticle::after { right: 0; }

.aircraft-reticle span::before {
  top: 10px;
  left: 64px;
  width: 14px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: transparent;
}

.aircraft-reticle span::after {
  top: 24px;
  left: 70px;
  width: 3px;
  height: 9px;
}

.horizon-stamp {
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 4px 6px;
  border: 1px solid rgba(244, 248, 252, 0.35);
  background: rgba(7, 21, 34, 0.72);
  color: #ffffff;
}

.attitude-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #3b5870;
  background: var(--instrument);
}

.attitude-values p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
}

.attitude-values p + p {
  border-left: 1px solid #3b5870;
}

.attitude-values span,
.telemetry-rail dt,
.stability-gauge span {
  color: var(--muted);
  font: 700 10px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.1em;
}

.attitude-values strong {
  color: #ffffff;
  font: 700 clamp(18px, 5vw, 25px)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.telemetry-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #2c465c;
  border-radius: 4px;
  background: #0a1c2b;
}

.telemetry-rail dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.telemetry-rail dl div {
  min-width: 0;
  padding: 0 8px;
  border-left: 1px solid #294257;
}

.telemetry-rail dl div:first-child {
  padding-left: 0;
  border-left: 0;
}

.telemetry-rail dd {
  margin: 5px 0 0;
  color: var(--live-blue);
  font: 700 14px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.stability-gauge {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.stability-gauge strong {
  color: var(--stable);
  font: 700 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.gauge-track {
  height: 4px;
  background: #294257;
}

.gauge-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--stable);
}

.joystick-panel {
  display: grid;
  grid-template-columns: 1fr 156px;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #2c465c;
  border-radius: 4px;
  background: var(--instrument);
}

.axis-labels {
  display: grid;
  gap: 12px;
  color: var(--muted);
  font: 700 11px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.07em;
}

.keyboard-instructions {
  margin: 2px 0 0;
  color: #b8c7d4;
  font: 500 11px/1.5 "Noto Sans CJK KR", system-ui, sans-serif;
  letter-spacing: -0.01em;
}

.joystick {
  position: relative;
  width: 156px;
  height: 156px;
  border: 1px solid #567289;
  border-radius: 50%;
  background: #0a1b29;
  touch-action: none;
  user-select: none;
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  background: #2c465c;
}

.joystick::before {
  top: 50%;
  left: 12px;
  right: 12px;
  height: 1px;
}

.joystick::after {
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 1px;
}

.joystick-ring {
  position: absolute;
  inset: 30px;
  border: 1px dashed #456177;
  border-radius: 50%;
}

.joystick-stick {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--uos-blue);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.screen-stack {
  margin-top: 12px;
}

.screen-panel {
  min-height: 132px;
}

.screen-panel h2,
.presenter-grid h2 {
  margin: 5px 0 0;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.screen-copy {
  margin: 8px 0 0;
  color: #b8c7d4;
  font-size: 13px;
  line-height: 1.55;
}

.nickname-field,
.url-field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.nickname-field small {
  color: var(--muted);
  font-weight: 400;
}

.nickname-field input,
.url-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #49657d;
  border-radius: 4px;
  background: #0a1c2b;
  color: var(--text);
}

.action-dock {
  position: fixed;
  z-index: 15;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 8px;
  width: 100%;
  min-height: var(--dock-height);
  padding: 12px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  border-top: 1px solid #35516a;
  background: #071522;
}

.action-dock > * {
  min-width: 0;
}

.action-dock > button:only-child {
  grid-column: 1 / -1;
}

.action-dock--status {
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-dock--status p {
  margin: 0;
  color: var(--stable);
  font: 700 11px/1.3 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.08em;
}

.status-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--stable);
}

.sensor-reason,
.submit-status,
.board-status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  background: #152a3a;
  color: #f5d9a3;
  font-size: 13px;
  line-height: 1.5;
}

.challenge-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 10px;
  background: #294257;
}

.challenge-line p {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  background: #0a1c2b;
}

.challenge-line strong {
  color: #ffffff;
  font: 700 20px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.challenge-line b {
  font-weight: inherit;
}

.result-panel {
  text-align: center;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 0;
}

.result-score strong {
  color: var(--stable);
  font: 700 clamp(50px, 18vw, 84px)/0.95 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums;
}

.result-score small {
  color: var(--muted);
  font: 700 13px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.result-stability,
.result-mode {
  margin: 8px 0 0;
  color: #b8c7d4;
  font-size: 13px;
}

.result-stability strong {
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.presenter-body {
  min-height: 100svh;
}

.presenter-shell {
  padding-bottom: 32px;
}

.presenter-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
}

.presenter-qr-panel,
.leaderboard-panel {
  border: 1px solid #35516a;
  border-radius: 4px;
  background: var(--instrument);
  clip-path: polygon(0 6px, 6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
}

.presenter-qr-panel {
  padding: 18px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: min(100%, 330px);
  aspect-ratio: 1;
  margin: 16px auto 0;
  padding: 12px;
  border: 4px solid var(--uos-blue);
  background: #ffffff;
}

.qr-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.presenter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.copy-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--stable);
  font-size: 12px;
}

.leaderboard-panel {
  padding: 18px;
}

.board-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #35516a;
}

.score-count {
  display: grid;
  justify-items: end;
  margin: 0;
}

.score-count strong {
  color: var(--stable);
  font: 700 38px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.score-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: score-rank;
}

.score-list li {
  counter-increment: score-rank;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  border-bottom: 1px solid #294257;
}

.score-list li::before {
  content: counter(score-rank, decimal-leading-zero);
  color: var(--live-blue);
  font: 700 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.score-list .score-empty {
  display: block;
  color: var(--muted);
  text-align: center;
}

.score-list .score-empty::before {
  content: none;
}

.score-name {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  color: var(--stable);
  font: 700 18px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .presenter-grid {
    grid-template-columns: 1fr;
  }

  .presenter-shell {
    padding-bottom: 24px;
  }
}

@media (max-width: 420px) {
  :root {
    --dock-height: 96px;
  }

  .student-shell,
  .presenter-shell {
    padding-top: 10px;
  }

  .instrument-header {
    min-height: 46px;
  }

  .connection-state {
    max-width: 88px;
    text-align: right;
  }

  .horizon {
    height: clamp(202px, 31svh, 252px);
  }

  .telemetry-rail {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stability-gauge {
    grid-template-columns: 72px 1fr 38px;
  }

  .joystick-panel {
    grid-template-columns: minmax(0, 1fr) 142px;
  }

  .joystick {
    width: 142px;
    height: 142px;
  }

  .action-dock {
    padding-top: 10px;
  }

  .action-dock button {
    padding-right: 9px;
    padding-left: 9px;
    font-size: 13px;
  }

  .presenter-qr-panel,
  .leaderboard-panel {
    padding: 14px;
  }
}

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