@font-face {
  font-family: 'Canda Tawa Cute';
  src: url('assets/fonts/CandaTawaCute.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Candal';
  src: url('assets/fonts/Candal.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #24150c;
  --paper: #fdf6e3;
  --gold: #f5b942;
  --amber: #e67e22;
  --cream: #fffaf0;
  --font-hand: 'Canda Tawa Cute', 'Candal', 'Comic Sans MS', cursive, sans-serif;
  --font-bold: 'Candal', 'Canda Tawa Cute', system-ui, sans-serif;
  --font-ui: "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 35%, #231914 0%, #100b09 75%, #070504 100%);
  color: var(--cream);
  font-family: var(--font-ui);
  overflow: hidden;
}

.stage-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 1.4vw, 18px);
}

.cinema-frame {
  position: relative;
  width: min(100%, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100%;
  background: #140e0a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.78),
    0 0 0 2px rgba(245, 185, 66, 0.28),
    inset 0 0 36px rgba(0, 0, 0, 0.55);
}

.cinema-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

#intro-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #140e0a;
  cursor: pointer;
}

/* ==================== START / END OVERLAYS ==================== */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(28, 17, 10, 0.62) 0%, rgba(12, 7, 5, 0.88) 100%);
  backdrop-filter: blur(4px);
  z-index: 20;
  transition: opacity 0.45s ease;
}

.start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-card {
  text-align: center;
  max-width: 560px;
  padding: 28px 34px 24px;
  background: linear-gradient(155deg, rgba(255, 248, 229, 0.96) 0%, rgba(248, 232, 198, 0.94) 100%);
  color: var(--ink);
  border-radius: 22px;
  border: 4px solid var(--ink);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.55),
    6px 6px 0 var(--ink);
  position: relative;
}

.start-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: #24150c;
  color: #ffe38a;
  font-family: var(--font-bold);
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.start-logo {
  display: block;
  width: 116px;
  height: 116px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 10px;
  border: 4px solid var(--ink);
  box-shadow: 0 6px 18px rgba(36, 21, 12, 0.32);
}

.start-logo.small {
  width: 88px;
  height: 88px;
}

.start-title {
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(28px, 4.2vw, 46px);
  letter-spacing: 0.04em;
  color: #24150c;
  text-shadow: 2px 2px 0 #ffd86b;
  line-height: 1.08;
}

.start-title.small {
  font-size: clamp(22px, 3vw, 32px);
}

.start-sub {
  margin: 8px 0 18px;
  font-size: 13.5px;
  color: #5b3b24;
  font-weight: 600;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.btn-watch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 28px;
  font-family: var(--font-bold);
  font-size: 16px;
  color: #24150c;
  background: linear-gradient(180deg, #ffe27a 0%, #f5a623 100%);
  border: 3px solid #24150c;
  border-radius: 999px;
  box-shadow: 0 4px 0 #24150c;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-watch:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #24150c;
}

.btn-watch:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #24150c;
}

.btn-back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  font-family: var(--font-bold);
  font-size: 13px;
  color: #24150c;
  background: rgba(255, 255, 255, 0.78);
  border: 2.5px solid #24150c;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 3px 0 #24150c;
  transition: transform 0.12s ease;
}

.btn-back-home:hover {
  transform: translateY(-1px);
  background: #fff;
}

.load-status {
  margin-top: 12px;
  font-size: 12px;
  color: #7c563a;
  font-weight: 600;
}

/* ==================== RECORDING PILL ==================== */
.rec-pill {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(180, 26, 26, 0.9);
  color: #fff;
  font-family: var(--font-bold);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  z-index: 25;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.rec-pill.hidden {
  display: none;
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffecec;
  animation: rec-blink 0.9s infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ==================== CINEMA CONTROLS BAR ==================== */
.controls-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 16px 12px;
  background: linear-gradient(180deg, rgba(16, 10, 7, 0) 0%, rgba(16, 10, 7, 0.78) 42%, rgba(12, 7, 5, 0.94) 100%);
  z-index: 15;
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.cinema-frame.playing.idle .controls-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.timeline-wrap {
  position: relative;
  margin-bottom: 8px;
}

.chapter-markers {
  position: relative;
  height: 6px;
  pointer-events: none;
  margin-bottom: -4px;
}

.chapter-pip {
  position: absolute;
  top: 0;
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: rgba(255, 227, 138, 0.65);
  transform: translateX(-50%);
}

.scrubber {
  width: 100%;
  height: 6px;
  accent-color: #f7b944;
  cursor: pointer;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ctrl-left, .ctrl-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 232, 178, 0.32);
  background: rgba(34, 22, 14, 0.78);
  color: #fff3da;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.ctrl-btn:hover {
  background: rgba(66, 44, 28, 0.92);
  border-color: rgba(255, 220, 128, 0.72);
}

.ctrl-btn.primary {
  min-width: 38px;
  background: linear-gradient(180deg, #ffd86e 0%, #eb9b28 100%);
  color: #24150c;
  border-color: #24150c;
  font-size: 14px;
}

.ctrl-btn.active {
  background: rgba(245, 185, 66, 0.24);
  border-color: #f7c355;
  color: #ffe7a3;
}

.ctrl-btn.export-btn.recording {
  background: rgba(214, 48, 48, 0.86);
  border-color: #ffb8b8;
  color: #fff;
}

.time-readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #ffe8b8;
  font-weight: 700;
  min-width: 82px;
}

.chapter-label {
  font-family: var(--font-hand);
  font-size: 13px;
  color: #ffd57a;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 213, 122, 0.12);
  border: 1px solid rgba(255, 213, 122, 0.26);
}

@media (max-width: 720px) {
  .start-card {
    padding: 18px 18px 16px;
    max-width: 92%;
  }
  .start-logo {
    width: 74px;
    height: 74px;
  }
  .ctrl-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }
  .chapter-label {
    display: none;
  }
}

/* ================= PHONE LANDSCAPE (Pixel 10 Pro / Smartphones) ================= */
html.is-phone-landscape,
html.is-phone-landscape body {
  height: 100dvh;
}

html.is-phone-landscape .stage-shell {
  width: 100vw;
  height: 100dvh;
  padding: 0;
}

html.is-phone-landscape .cinema-frame {
  width: min(100vw, calc(100dvh * 16 / 9));
  max-height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

html.is-phone-landscape .start-overlay {
  padding: 8px;
}

html.is-phone-landscape .start-card {
  max-width: 520px;
  width: calc(100% - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  padding: 12px 18px 11px;
  border-radius: 16px;
  border-width: 3px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 4px 4px 0 var(--ink);
}

html.is-phone-landscape .start-badge {
  font-size: 9.5px;
  padding: 3px 10px;
  margin-bottom: 6px;
}

html.is-phone-landscape .start-logo {
  width: 56px;
  height: 56px;
  border-width: 3px;
  margin-bottom: 5px;
}

html.is-phone-landscape .start-logo.small {
  width: 50px;
  height: 50px;
}

html.is-phone-landscape .start-title {
  font-size: 24px;
}

html.is-phone-landscape .start-title.small {
  font-size: 20px;
}

html.is-phone-landscape .start-sub {
  font-size: 11.5px;
  margin: 4px 0 9px;
}

html.is-phone-landscape .start-actions {
  gap: 8px;
}

html.is-phone-landscape .btn-watch {
  padding: 8px 18px;
  font-size: 13.5px;
  border-width: 2.5px;
}

html.is-phone-landscape .btn-back-home {
  padding: 7px 13px;
  font-size: 11.5px;
  border-width: 2px;
}

html.is-phone-landscape .load-status {
  margin-top: 7px;
  font-size: 10.5px;
}

html.is-phone-landscape .controls-bar {
  padding: 14px max(10px, env(safe-area-inset-right, 0px)) max(7px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
}

html.is-phone-landscape .timeline-wrap {
  margin-bottom: 5px;
}

html.is-phone-landscape .ctrl-btn {
  height: 27px;
  padding: 0 8px;
  font-size: 11px;
}

html.is-phone-landscape .time-readout {
  font-size: 11px;
  min-width: 68px;
}

html.is-phone-landscape .chapter-label,
html.is-phone-landscape #btn-fps-badge,
html.is-phone-landscape #btn-export {
  display: none;
}
