﻿html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

@media (max-width: 480px) {
  html, body {
    overflow: auto;
    height: auto;
  }
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  box-sizing: border-box;
  background: #e9e3f5;
}

.app {
  font-family: 'Noto Sans JP', sans-serif;
  max-width: 720px;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1.5px solid #e8e0f0;
  box-shadow: 0 8px 32px rgba(124,58,237,.18), 0 2px 8px rgba(0,0,0,.10);    
}

.top-page {
  background: #fdf8ff;
  transition: opacity .32s ease, transform .32s ease;
}

.top-page.out {
  opacity: 0;
  transform: scale(.97);
  pointer-events: none;
}

.top-hero {
  background: #7c3aed;
  padding: 36px 32px 28px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-deco {
  position: absolute;
  right: -24px;
  top: -24px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

.hero-deco2 {
  position: absolute;
  right: 60px;
  bottom: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}

.hero-img-wrap {
  flex-shrink: 0;
}

.hero-img {
  width: 110px;
  height: auto;
  display: block;
}

.top-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #ddd6fe;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
  letter-spacing: .5px;
}

.top-title {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  margin-bottom: 10px;
}

.top-desc {
  font-size: 13px;
  color: rgba(255,255,255,.75);
  line-height: 1.75;
  max-width: 400px;
}

.top-stats {
  display: flex;
  background: #fff;
  border-bottom: 1.5px solid #ede8f8;
}

.stat-item {
  flex: 1;
  padding: 16px 0;
  text-align: center;
  border-right: 1px solid #ede8f8;
}

.stat-item:last-child {
  border-right: none;
}

.stat-num {
  font-size: 17px;
  font-weight: 700;
  color: #7c3aed;
}

.stat-lbl {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

.top-list {
  background: #fff;
  padding: 20px 28px;
}

.list-heading {
  font-size: 11px;
  color: #9ca3af;
  letter-spacing: .8px;
  margin-bottom: 14px;
  font-weight: 500;
}

.qp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f0fa;
}

.qp-row:last-child {
  border-bottom: none;
}

.qp-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ede8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #7c3aed;
  flex-shrink: 0;
}

.qp-txt {
  font-size: 13px;
  color: #374151;
  flex: 1;
}

.top-footer {
  background: #f5f3ff;
  padding: 28px;
  border-top: 1.5px solid #ede8f8;
}

.start-area {
  background: #7c3aed;
  border-radius: 16px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.start-area-deco {
  position: absolute;
  right: -16px;
  top: -16px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}

.start-area-deco2 {
  position: absolute;
  right: 40px;
  bottom: -30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}

.start-text {
  flex: 1;
  position: relative;
  z-index: 1;
}

.start-text-main {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.start-text-sub {
  font-size: 12px;
  color: rgba(255,255,255,.65);
  line-height: 1.5;
}

.start-btn,
.start-btn:link,
.start-btn:visited,
.start-btn:hover,
.start-btn:active,
.start-btn:focus {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #ffffff !important;
  border: none !important;
  outline: none;
  border-radius: 100px;
  padding: 10px 22px 10px 10px;
  color: #7c3aed !important;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Noto Sans JP', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s;
  -webkit-appearance: none;
  appearance: none;
  opacity: 1 !important;
}

.start-btn:hover {
  transform: scale(1.04);
}

.start-btn:active {
  transform: scale(.97);
}

.start-btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.player-page {
  display: none;
  flex-direction: column;
  background: #fdf8ff;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity .32s ease, transform .32s ease;
}

.player-page.show {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.player-page.in {
  opacity: 1;
  transform: scale(1);
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1.5px solid #ede8f8;
}

.back-btn {
  background: none;
  border: 1px solid #e8e0f0;
  color: #7c3aed;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-family: 'Noto Sans JP', sans-serif;
  padding: 5px 12px;
  border-radius: 20px;
  transition: background .15s;
}

.back-btn:hover {
  background: #f5f3ff;
}

.topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.topbar-sp {
  flex: 1;
}

.score-pill {
  font-size: 12px;
  font-weight: 700;
  color: #7c3aed;
  background: #ede8f8;
  padding: 4px 12px;
  border-radius: 20px;
}

.video-area {
  position: relative;
  width: 100%;
  flex: 1;
  background: #1e1033;
  overflow: hidden;
}

.fake-video {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.fake-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.vid-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(0,0,0,.35);
  transition: opacity .2s;
}

.vid-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(124,58,237,.35);
  border: 2px solid rgba(196,181,253,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}

.fake-video:hover .vid-circle {
  background: rgba(124,58,237,.5);
}

.vid-lbl {
  font-size: 13px;
  color: rgba(255,255,255,.45);
}

.vid-tag {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 11px;
  background: rgba(124,58,237,.5);
  color: #ddd6fe;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid rgba(196,181,253,.2);
}

.prog-wrap {
  position: relative;
  height: 10px;
  background: #ddd6fe;
  cursor: pointer;
  border-radius: 5px;
  overflow: visible;
}

.prog-fill {
  height: 100%;
  background: #7c3aed;
  transition: width .3s linear;
  border-radius: 5px;
}

.qmarks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.qmark {
  position: absolute;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid #fdf8ff;
  z-index: 2;
}

.qmark:hover::after {
  content: attr(data-label);
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1033;
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  font-family: 'Noto Sans JP', sans-serif;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 14px;
  background: #fff;
  border-top: 1.5px solid #ede8f8;
}

.ctrl-btn {
  background: none;
  border: 1px solid #e8e0f0;
  color: #7c3aed;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background .15s;
}

.ctrl-btn:hover {
  background: #f5f3ff;
}

.time-txt {
  font-size: 12px;
  color: #9ca3af;
  min-width: 82px;
}

.ctrl-sp {
  flex: 1;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.bar {
  width: 3px;
  background: #7c3aed;
  border-radius: 2px;
  animation: ba .8s ease-in-out infinite alternate;
}

.bar:nth-child(2) {
  animation-delay: .15s;
}

.bar:nth-child(3) {
  animation-delay: .3s;
}

.bar:nth-child(4) {
  animation-delay: .1s;
}

@keyframes ba {
  from { height: 3px; }
  to { height: 14px; }
}

.bars.paused .bar {
  animation: none;
  height: 5px;
  opacity: .3;
}

.qov {
  position: absolute;
  inset: 0;
  background: rgba(30,16,51,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  padding: 20px 0;
  box-sizing: border-box;
}

.qov.on {
  opacity: 1;
  pointer-events: all;
}

.qwin {
  background: #fff;
  border-radius: 16px;
  padding: 26px;
  max-width: 460px;
  width: 90%;
  max-height: calc(100% - 40px); /* .qovのpadding 20px×2=40px分 */
  overflow-y: auto;
  scrollbar-width: none;
  transform: scale(.92) translateY(8px);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
  border: 1.5px solid #ede8f8;
  flex-shrink: 0;
}

.qwin::-webkit-scrollbar {
  display: none;
}

.qov.on .qwin {
  transform: scale(1) translateY(0);
}

.qhdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.qwin.result-mode .qhdr {
  margin-bottom: 0;
}

.q-badge {
  font-size: 11px;
  color: #7c3aed;
  background: #ede8f8;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
}

.q-paused {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #9ca3af;
}

.q-question {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 16px;
  color: #1f2937;
}

.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.opt {
  background: #f9f7ff;
  border: 1.5px solid #ede8f8;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  color: #374151;
  font-size: 13px;
  font-family: 'Noto Sans JP', sans-serif;
  transition: background .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.opt:hover:not(:disabled) {
  background: #ede8f8;
  border-color: #c4b5fd;
}

.opt.correct {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.opt.wrong {
  background: #fff1f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.opt:disabled {
  cursor: default;
}

.opt-l {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ede8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  color: #7c3aed;
}

.opt.correct .opt-l {
  background: #bbf7d0;
  color: #166534;
}

.opt.wrong .opt-l {
  background: #fecdd3;
  color: #991b1b;
}

.qfb {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 14px;
  min-height: 18px;
  line-height: 1.65;
}

.qfb.hidden-result,
.cont-btn.hidden-result {
  display: none;
  height: 0;
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.qfb.ok {
  color: #16a34a;
}

.qfb.ng {
  color: #dc2626;
}

.cont-btn {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  background: #7c3aed;
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Noto Sans JP', sans-serif;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, background .15s;
}

.cont-btn.vis {
  opacity: 1;
  pointer-events: all;
}

.cont-btn:hover {
  background: #6d28d9;
}

.result-wrap {
  text-align: center;
  position: relative;
}

.result-wrap .cont-btn {
  margin-top: 18px;
}

.q-close-btn {
  background: #7c3aed;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #ffffff;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(124,58,237,.35);
  transition: background .15s, transform .1s, box-shadow .15s;
}

.q-close-btn:hover {
  background: #6d28d9;
}

.r-pct {
  font-size: 52px;
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: 2px;
}

.r-lbl {
  font-size: 13px;
  color: #9ca3af;
  margin-bottom: 18px;
}

.r-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}

.r-card {
  background: #f5f3ff;
  border-radius: 10px;
  padding: 10px 20px;
  text-align: center;
}

.r-num {
  font-size: 22px;
  font-weight: 700;
}

.r-sub {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
}

/* 解説リスト */
.rv-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
  text-align: left;
  max-height: min(390px, 35vh); /* 画面高さに応じて上限を調整 */
  overflow-y: auto;
  scrollbar-width: none;
  padding-right: 2px;
}

.rv-list::-webkit-scrollbar {
  display: none;
}

.rv-item {
  background: #faf9ff;
  border: 1px solid #ede9fe;
  border-radius: 10px;
  padding: 12px 14px;
}

.rv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rv-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.rv-badge.ok {
  background: #dcfce7;
  color: #16a34a;
}

.rv-badge.ng {
  background: #fee2e2;
  color: #dc2626;
}

.rv-qnum {
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
}

.rv-question {
  font-size: 13px;
  font-weight: 600;
  color: #1e1b4b;
  margin-bottom: 8px;
  line-height: 1.45;
}

.rv-opts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.rv-opt {
  font-size: 12px;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f3f4f6;
}

.rv-opt.correct {
  background: #dcfce7;
  color: #15803d;
  font-weight: 600;
}

.rv-exp {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  border-top: 1px solid #ede9fe;
  padding-top: 8px;
}

.rv-details {
  margin-top: 8px;
}

.rv-toggle {
  font-size: 12px;
  font-weight: 600;
  color: #7c3aed;
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #ede8f8;
  border-radius: 20px;
  background: #f5f3ff;
  user-select: none;
  transition: background .15s;
}

.rv-toggle::-webkit-details-marker {
  display: none;
}

.rv-toggle::before {
  content: "▶";
  font-size: 9px;
  transition: transform .2s;
}

details[open] > .rv-toggle::before {
  transform: rotate(90deg);
}

.rv-toggle:hover {
  background: #ede8f8;
}

.rv-body {
  margin-top: 10px;
}

/* ============================================
   Responsive — Mobile (≤480px)
   ============================================ */
@media (max-width: 480px) {
  body {
    padding: 0;
    align-items: flex-start;
    min-height: unset;
    background: #fdf8ff;
  }

  .app {
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: visible; /* トップページのスクロールを許可 */
  }

  .top-page {
    overflow-y: auto;
  }

  .top-hero {
    padding: 24px 18px 20px;
    gap: 10px;
  }

  .top-title {
    font-size: 20px;
  }

  .top-desc {
    font-size: 12px;
  }

  .hero-img {
    width: 72px;
  }

  .stat-item {
    flex: 1 1 50%;
    border-bottom: 1px solid #ede8f8;
  }

  .top-list {
    padding: 14px 18px;
  }

  .top-footer {
    padding: 16px 18px;
  }

  .start-area {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px;
  }

  .start-btn {
    width: 100%;
    justify-content: center;
  }

  .player-topbar {
    padding: 8px 12px;
  }

  .topbar-title {
    font-size: 11px;
  }

  .qwin {
    width: 95%;
    padding: 16px 14px;
    max-height: 100%;
  }

  .q-question {
    font-size: 14px;
  }

  .opt {
    font-size: 13px;
    padding: 10px 12px;
  }

  .result-wrap .cont-btn {
    margin-top: 0;
  }

  .rv-list {
    max-height: 250px;
  }

  .controls {
    padding: 8px 12px;
  }

  /* 採点結果 */
  .r-pct {
    font-size: 38px;
  }

  .r-lbl {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .r-row {
    gap: 8px;
    margin-bottom: 12px;
  }

  .r-card {
    padding: 8px 12px;
    flex: 1;
  }

  .r-num {
    font-size: 18px;
  }

  .rv-item {
    padding: 10px 10px;
  }

  .rv-question {
    font-size: 12px;
  }

  .rv-toggle {
    font-size: 11px;
    padding: 3px 8px;
  }

  .rv-opt {
    font-size: 11px;
    padding: 3px 7px;
  }

  .rv-exp {
    font-size: 11px;
  }
}

/* ============================================
   Responsive — Landscape Mobile (横画面)
   ============================================ */
@media (orientation: landscape) and (max-width: 1024px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  body {
    padding: 0;
    align-items: flex-start;
    min-height: unset;
  }

  .app {
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  /* トップページ: 縦スクロール可能にする */
  .top-page {
    height: 100vh;
    overflow-y: auto;
  }

  .top-hero {
    padding: 14px 18px 12px;
    gap: 10px;
  }

  .top-title {
    font-size: 18px;
  }

  .top-desc {
    font-size: 11px;
    line-height: 1.5;
  }

  .hero-img {
    width: 56px;
  }

  /* 横画面は幅が広いので stat を1行に */
  .top-stats {
    flex-wrap: nowrap;
  }

  .top-list {
    padding: 12px 18px;
  }

  .top-footer {
    padding: 14px 18px;
  }

  .start-area {
    padding: 16px 20px;
    gap: 14px;
  }

  /* クイズウィンドウ: 高さを画面内に収める */
  .qov {
    padding: 10px 0;
    overflow: hidden;
    align-items: center;
  }

  .qwin {
    width: 65%;
    max-width: 480px;
    padding: 12px 16px;
    /* 100% = .qovの高さ(= 動画エリア高さ)。上下padding 10px×2=20px を引く */
    max-height: calc(100% - 20px);
    overflow-y: auto;
    scrollbar-width: none;
  }

  .qwin::-webkit-scrollbar {
    display: none;
  }

  .qhdr {
    margin-bottom: 8px;
  }

  .q-question {
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.45;
  }

  .opts {
    gap: 5px;
    margin-bottom: 10px;
  }

  .opt {
    padding: 7px 10px;
    font-size: 12px;
  }

  /* 採点結果 */
  .r-pct {
    font-size: 30px;
  }

  .r-lbl {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .r-row {
    margin-bottom: 6px;
    gap: 8px;
  }

  .r-card {
    padding: 6px 12px;
  }

  .r-num {
    font-size: 16px;
  }

  .rv-list {
    max-height: 22vh;
  }

  .result-wrap .cont-btn {
    margin-top: 8px;
  }

  /* プレイヤーのコントロール */
  .player-topbar {
    padding: 6px 12px;
  }

  .controls {
    padding: 6px 12px 8px;
  }
}
