:root {
  color-scheme: light;
  --ink: #21212a;
  --muted: #7d7b87;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(33, 33, 42, 0.14);
  --shadow: 0 18px 48px rgba(73, 73, 110, 0.24);
  --accent: #17b5c8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow: hidden;
  background: #e8e0ee url("./assets/bg.png") center / cover no-repeat;
  color: var(--ink);
  font-family:
    "HarmonyOS Sans SC",
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.home {
  position: relative;
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  padding: clamp(16px, 2.4vh, 34px) clamp(18px, 2.5vw, 64px);
  place-items: center;
}

.menu-grid {
  --menu-gap: clamp(14px, 2.05vw, 52px);
  --menu-card-ratio: 0.518922;
  --menu-max-height-by-width: calc((100vw - (2 * clamp(18px, 2.5vw, 64px)) - (2 * var(--menu-gap))) / 3 / var(--menu-card-ratio));
  --menu-height: min(calc(100vh - (2 * clamp(16px, 2.4vh, 34px))), var(--menu-max-height-by-width));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--menu-gap);
  width: min(
    calc(100vw - (2 * clamp(18px, 2.5vw, 64px))),
    calc((var(--menu-height) * var(--menu-card-ratio) * 3) + (2 * var(--menu-gap)))
  );
  height: var(--menu-height);
  align-items: stretch;
  justify-content: center;
}

.menu-button {
  display: block;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 180ms ease,
    filter 180ms ease;
}

.menu-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.menu-button:active {
  transform: scale(0.985);
}

.menu-button.is-unavailable {
  cursor: not-allowed;
  filter: grayscale(1) opacity(0.48);
}

.menu-button.is-unavailable:active {
  transform: none;
}

.menu-button:focus-visible,
.close-button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.floating-button:focus-visible {
  outline: 4px solid rgba(23, 181, 200, 0.82);
  outline-offset: 5px;
}

.fullscreen-modal,
.miniapp-modal {
  max-width: 100vw;
  max-height: 100vh;
  border: 0;
  padding: 0;
  color: #fff;
}

.fullscreen-modal {
  width: 100vw;
  height: 100vh;
  background: #05070b;
}

.fullscreen-modal::backdrop,
.miniapp-modal::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.fullscreen-modal[open] {
  display: grid;
}

.video-modal[open] {
  grid-template-rows: minmax(0, 1fr);
}

.ppt-modal[open] {
  grid-template-rows: minmax(0, 1fr);
}

.ppt-modal {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(18px) saturate(1.1);
}

.close-button {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 5;
  display: grid;
  width: clamp(44px, 5vw, 64px);
  height: clamp(44px, 5vw, 64px);
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  color: #fff;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.close-button-dark {
  color: var(--ink);
  border-color: rgba(33, 33, 42, 0.12);
  background: rgba(255, 255, 255, 0.82);
}

.video-stage,
.slide-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
}

.video-stage {
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.slide-stage {
  overflow: hidden;
  padding: 0;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(18px) saturate(1.1);
}

.slide-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 56px);
  max-height: calc(100vh - 112px);
  object-fit: contain;
  background: #05070b;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  user-select: none;
}

.ppt-controls {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(14px);
}

.icon-button {
  display: grid;
  width: clamp(42px, 4.5vw, 58px);
  height: clamp(42px, 4.5vw, 58px);
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 0.8;
  cursor: pointer;
}

.slide-counter {
  min-width: 86px;
  color: #fff;
  font-size: clamp(16px, 1.45vw, 24px);
  font-weight: 800;
  text-align: center;
}

.floating-button,
.text-button {
  min-width: 132px;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent);
  color: #031114;
  font-weight: 800;
  cursor: pointer;
}

.replay-button {
  position: absolute;
  left: 50%;
  bottom: max(32px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
}

.empty-state {
  display: grid;
  width: min(86vw, 720px);
  place-items: center;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-align: center;
  font-size: clamp(18px, 1.6vw, 28px);
}

.empty-state p {
  margin: 0;
}

.miniapp-modal {
  width: min(88vw, 560px);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.miniapp-modal[open] {
  display: block;
}

.miniapp-body {
  display: grid;
  gap: 18px;
  place-items: center;
  padding: clamp(34px, 5vw, 56px);
  text-align: center;
}

.qr-image {
  width: min(62vw, 360px);
  aspect-ratio: 1;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  box-shadow: var(--shadow);
}

.miniapp-body p {
  max-width: 420px;
  margin: 0;
  font-size: clamp(18px, 1.9vw, 24px);
  line-height: 1.42;
}

.appid {
  color: var(--muted);
  font-size: 14px !important;
}

.miniapp-prompt-title {
  color: var(--ink);
  font-size: clamp(24px, 2.4vw, 34px) !important;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: clamp(18px, 4vh, 56px);
  z-index: 10;
  max-width: min(86vw, 760px);
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 13px 18px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: clamp(15px, 1.3vw, 20px);
  backdrop-filter: blur(14px);
}

.resource-overlay {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: block;
  height: 44px;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.resource-overlay[hidden] {
  display: none;
}

.resource-panel {
  position: absolute;
  inset: auto 0 0;
  width: 100%;
  padding: 0;
  background: transparent;
}

.resource-title {
  display: none;
}

.resource-detail {
  position: absolute;
  left: var(--progress-label-left, 8%);
  bottom: 13px;
  max-width: min(68vw, 620px);
  margin: 0;
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.68);
  color: rgba(33, 33, 42, 0.78);
  box-shadow: 0 8px 20px rgba(73, 73, 110, 0.14);
  font-size: clamp(12px, 1.05vw, 18px);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition: left 180ms ease;
}

.progress-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 0;
  background: rgba(33, 33, 42, 0.12);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #17b5c8, #6db9ff);
  transition: width 180ms ease;
}

.resource-percent {
  display: none;
}

@media (max-width: 900px), (orientation: portrait) {
  body {
    overflow: auto;
  }

  .home {
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    padding: 18px 18px 48px;
  }

  .menu-grid {
    --menu-gap: 18px;
    --menu-height: auto;
    grid-template-columns: 1fr;
    gap: 18px;
    width: min(100%, 560px);
    height: auto;
  }

  .menu-button {
    height: auto;
  }

  .menu-button img {
    height: auto;
  }

  .ppt-controls {
    gap: 10px;
    padding: 8px 10px;
  }
}
