:root {
  color-scheme: dark;
  --page-bg: #101827;
  --stage-bg: #0b1220;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --button-bg: rgba(255, 255, 255, 0.12);
  --button-bg-hover: rgba(255, 255, 255, 0.22);
  --button-border: rgba(255, 255, 255, 0.24);
  --toolbar-bg: rgba(7, 12, 22, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.classroom {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 18px 18px 82px;
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.16), transparent 34%),
    linear-gradient(180deg, #111c30 0%, var(--stage-bg) 100%);
}

.slide-stage {
  position: relative;
  display: flex;
  width: min(100%, calc((100vh - 112px) * 16 / 9));
  width: min(100%, calc((100dvh - 112px) * 16 / 9));
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  aspect-ratio: 16 / 9;
  align-items: center;
  justify-content: center;
}

.slide-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.42);
}

.slide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.slide-overlay button {
  pointer-events: auto;
}

.video-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.video-overlay.hidden {
  display: none !important;
}

.video-overlay video {
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.video-overlay.center-video {
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-overlay.center-video video {
  width: min(84%, calc((100vh - 180px) * 16 / 9));
  width: min(84%, calc((100dvh - 180px) * 16 / 9));
  max-width: 1280px;
  max-height: 72vh;
  max-height: 72dvh;
  border-radius: 14px;
}

.video-overlay.left-video {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4.5%;
  padding-right: 52%;
  box-sizing: border-box;
}

.video-overlay.left-video video {
  width: auto;
  height: 90%;
  max-height: 720px;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: 14px;
}

.student-info-overlay {
  position: absolute;
  top: 5.5%;
  left: 50%;
  z-index: 9;
  display: flex;
  width: min(72%, 760px);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
  padding: 10px 18px;
  border: 1px solid rgba(47, 93, 168, 0.25);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: #2f5da8;
  font-weight: 800;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
}

.student-info-overlay.hidden {
  display: none;
}

.student-info-overlay .hidden {
  display: none;
}

.student-start-button,
.student-login-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(47, 93, 168, 0.3);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.student-start-button {
  min-height: 40px;
  padding: 0 18px;
  border-color: rgba(29, 78, 216, 0.4);
  background: #2563eb;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.student-login-button {
  background: rgba(47, 93, 168, 0.9);
}

.student-start-button:hover,
.student-start-button:focus-visible,
.student-login-button:hover,
.student-login-button:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.student-login-button.hidden {
  display: none;
}

.contents-panel {
  position: absolute;
  right: 3%;
  bottom: 5%;
  display: grid;
  width: min(36%, 360px);
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(191, 219, 254, 0.24);
  border-radius: 8px;
  background: rgba(8, 20, 42, 0.72);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.contents-panel button,
.floating-action {
  border: 1px solid rgba(191, 219, 254, 0.28);
  border-radius: 8px;
  background: rgba(15, 43, 85, 0.78);
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, transform 160ms ease;
}

.contents-panel button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: clamp(12px, 1.15vw, 15px);
  line-height: 1.25;
}

.contents-panel button:hover,
.contents-panel button:focus-visible,
.floating-action:hover,
.floating-action:focus-visible {
  background: rgba(37, 99, 180, 0.9);
  outline: none;
  transform: translateY(-1px);
}

.floating-actions {
  position: absolute;
  right: 4%;
  bottom: 7%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.floating-action {
  min-width: 132px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.toolbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: var(--toolbar-bg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.menu-wrap {
  position: relative;
}

.toolbar.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
}

.toolbar.hidden {
  display: none;
}

.tool-button {
  min-width: 72px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
}

.tool-button:hover,
.tool-button:focus-visible {
  background: var(--button-bg-hover);
  outline: none;
}

.tool-button:disabled {
  color: rgba(248, 250, 252, 0.42);
  cursor: default;
  background: rgba(255, 255, 255, 0.06);
}

.page-indicator {
  min-width: 74px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.contents-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  display: grid;
  width: 210px;
  max-height: min(58vh, 360px);
  overflow-y: auto;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 12, 22, 0.9);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.contents-menu.hidden {
  display: none;
}

.contents-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.contents-menu button:hover,
.contents-menu button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.toast {
  position: fixed;
  right: 28px;
  top: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(191, 219, 254, 0.28);
  border-radius: 8px;
  background: rgba(8, 25, 52, 0.86);
  color: #fff;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  backdrop-filter: blur(10px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(-8px);
}

@media (max-width: 680px) {
  .classroom {
    padding: 10px 10px 78px;
  }

  .slide-stage {
    width: min(100%, calc((100dvh - 96px) * 16 / 9));
    max-height: calc(100dvh - 96px);
  }

  .toolbar {
    bottom: 10px;
    gap: 6px;
    padding: 8px;
  }

  .tool-button {
    min-width: auto;
    min-height: 38px;
    padding: 0 10px;
  }

  .contents-panel {
    right: 3%;
    bottom: 4%;
    width: min(58%, 300px);
    gap: 5px;
    padding: 8px;
  }

  .contents-panel button {
    min-height: 30px;
    padding: 5px 8px;
  }

  .floating-actions {
    right: 4%;
    bottom: 5%;
    gap: 7px;
  }

  .floating-action {
    min-width: 108px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .contents-menu {
    left: auto;
    right: 0;
    width: 184px;
    transform: none;
  }

  .video-overlay.center-video video {
    width: min(88%, calc((100dvh - 120px) * 16 / 9));
    max-height: 68dvh;
    border-radius: 10px;
  }

  .video-overlay.left-video {
    padding-left: 4.5%;
    padding-right: 52%;
  }

  .video-overlay.left-video video {
    height: 84%;
    max-height: 640px;
  }

  .student-info-overlay {
    top: 4%;
    left: 50%;
    width: 88%;
    gap: 10px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .toast {
    top: 14px;
    right: 14px;
    max-width: calc(100vw - 28px);
    padding: 10px 12px;
    font-size: 14px;
  }
}
