

    @import  url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap");
    :root {
      --font-display: "Fredoka", "Baloo 2", "Nunito", "Comic Sans MS", Arial, sans-serif;
      --font-body: "Nunito", "Baloo 2", "Comic Sans MS", Arial, sans-serif;
      --ink: #1f2a3d;
      --ink-soft: #415173;
      --sky-1: #e9f6ff;
      --sky-2: #fff3d6;
      --blue-500: #4c8dff;
      --pink-500: #ff5fa2;
      --sun-500: #ffcc4d;
      --mint-500: #44d7a8;
      --orange-500: #ff9f68;
      --lime-500: #a7f36b;
      --card-shadow: 0 26px 50px rgba(40, 86, 140, 0.18);
      --card-shadow-strong: 0 34px 60px rgba(40, 86, 140, 0.22);
    }

    
    * {
      box-sizing: border-box;
    }

    body {
      font-family: "Nunito", "Baloo 2", "Comic Sans MS", Arial, sans-serif;
      background: linear-gradient(160deg, #b8e4f7 0%, #d6eefc 50%, #f5c6d8 100%);
      margin: 0;
      min-height: 100vh;
      color: #1f2a3d;
      position: relative;
    }

    body::before,
    body::after {
      content: "";
      position: fixed;
      width: 200px;
      height: 200px;
      border-radius: 48% 52% 46% 54%;
      z-index: -2;
      filter: blur(0);
      opacity: 0.25;
    }

    body::before {
      top: -60px;
      left: -40px;
      background: #f5c6d8;
    }

    body::after {
      bottom: -80px;
      right: -40px;
      background: #b8e4f7;
    }

    .kids-page {
      width: min(1280px, 94%);
      margin: 0 auto 64px;
      padding-top: 28px;
      position: relative;
      z-index: 1;
    }

    .kids-top-bar {
      display: flex;
      align-items: center;
      gap: 20px;
      padding: 18px 28px;
      background: #ffffff;
      border-radius: 36px;
      box-shadow: 0 22px 45px rgba(33, 91, 182, 0.2);
      position: sticky;
      top: 20px;
      flex-wrap: wrap;
      row-gap: 14px;
      margin-bottom: 36px;
    }

    body.watching-video .kids-top-bar {
      position: fixed;
      top: 0; left: 0; right: 0;
      z-index: 200;
      margin-bottom: 0;
      border-radius: 0;
      box-shadow: none;
      background: #0f0f0f;
      padding: 10px 20px;
    }
    body.watching-video .kids-top-bar * { color: white !important; }
    body.watching-video .kids-search { display: none !important; }
    body.watching-video #switch-companion-btn { display: none !important; }
    body.watching-video #library-title { display: none !important; }
    body.watching-video #back-button {
      background: transparent !important;
      color: white !important;
      border: none;
      font-size: 15px;
      font-weight: 600;
    }

    /* Cover mode — hide top bar, video fills full screen */
    body.cover-mode .kids-top-bar { display: none !important; }

    /* When watching a video, fill everything below the top bar */
    body.watching-video #player-container {
      position: fixed !important;
      top: 52px !important;
      left: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      z-index: 100 !important;
      margin: 0 !important;
      padding: 20px 40px !important;
      border-radius: 0 !important;
      background: #000 !important;
      display: flex !important;
      flex-direction: column !important;
      justify-content: center !important;
      align-items: stretch !important;
      gap: 0 !important;
      box-shadow: none !important;
    }
    body.watching-video #video-wrapper {
      width: 100% !important;
      height: 100% !important;
      padding: 0 !important;
      display: flex !important;
      justify-content: center !important;
      align-items: center !important;
    }
    body.watching-video #video-container {
      width: min(100%, calc((100vh - 52px) * 16 / 9)) !important;
      height: auto !important;
      max-width: calc(100% - 80px) !important;
      border-radius: 12px !important;
      display: block !important;
      outline: 4px solid rgba(255,255,255,0.15) !important;
      box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 40px rgba(0,0,0,0.6) !important;
    }
    body.watching-video #player {
      border-radius: 0 !important;
      box-shadow: none !important;
      width: 100% !important;
      height: auto !important;
      aspect-ratio: 16 / 9 !important;
    }
    body.watching-video #player iframe {
      width: 100% !important;
      height: 100% !important;
      border-radius: 0 !important;
    }
    /* Hide black overlay blockers in theatre mode — they're for fullscreen only */
    body.watching-video #yt-logo-blocker-bottom {
      display: none !important;
    }

    /* Cover mode overrides — must come AFTER watching-video rules to win */
    body.watching-video.cover-mode #player-container {
      top: 0 !important;
    }
    body.watching-video.cover-mode #video-wrapper {
      width: 100vw !important;
      height: 100vh !important;
      padding: 0 !important;
    }
    body.watching-video.cover-mode #video-container {
      width: 100vw !important;
      height: 100vh !important;
      max-width: 100vw !important;
    }
    body.watching-video.cover-mode #player {
      width: 100vw !important;
      height: 100vh !important;
      aspect-ratio: unset !important;
    }
    body.watching-video.cover-mode #player iframe {
      width: 100vw !important;
      height: 100vh !important;
    }

    .kids-top-left {
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .kids-top-bar>* {
      flex-shrink: 0;
    }

    .kids-avatar {
      width: 54px;
      height: 54px;
      border-radius: 50%;
      background: linear-gradient(135deg, #69d6ff, #5aa9ff);
      display: grid;
      place-items: center;
      color: #ffffff;
      font-size: 1.8rem;
      box-shadow: inset 0 5px 0 rgba(255, 255, 255, 0.55);
    }

    #back-button {
      display: none;
      border: none;
      border-radius: 999px;
      background: linear-gradient(135deg, #ff6d85, #ff378f);
      color: #ffffff;
      font-weight: 600;
      padding: 10px 20px;
      font-size: 0.95rem;
      cursor: pointer;
      box-shadow: 0 16px 32px rgba(255, 61, 124, 0.38);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    #back-button span {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    #back-button:hover {
      transform: translateY(-1px);
      box-shadow: 0 20px 36px rgba(255, 61, 124, 0.45);
    }

    .kids-search {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 12px;
      background: #f0f5ff;
      border-radius: 999px;
      padding: 10px 16px;
      box-shadow: inset 0 0 0 2px rgba(112, 163, 255, 0.12);
    }

    .kids-search input {
      flex: 1;
      border: none;
      background: transparent;
      font-size: 1rem;
      letter-spacing: 0.01em;
      color: #214375;
      outline: none;
    }

    .kids-search input::placeholder {
      color: rgba(33, 67, 117, 0.55);
      font-weight: 600;
    }

    .kids-search button {
      border: none;
      background: linear-gradient(135deg, #5e7bff, #3a4dfd);
      color: #ffffff;
      width: 46px;
      height: 46px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      font-size: 1.2rem;
      cursor: pointer;
      box-shadow: 0 12px 24px rgba(56, 95, 255, 0.32);
      transition: transform 0.2s ease;
    }

    .kids-search button:hover {
      transform: translateY(-1px);
    }

    /* Grid for video cards */
    #video-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 32px;
      width: 100%;
      transition: grid-template-columns 0.2s ease;
    }

    .video-card {
      background: #ffffff;
      border-radius: 32px;
      padding: 18px 18px 24px;
      box-shadow: 0 28px 46px rgba(60, 113, 255, 0.18);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      position: relative;
      overflow: visible;
      cursor: pointer;
    }

    .video-card::after {
      content: "";
      position: absolute;
      inset: -6px;
      border-radius: 34px;
      background: linear-gradient(160deg, rgba(255, 197, 197, 0.6), rgba(192, 229, 255, 0.6));
      opacity: 0;
      transition: opacity 0.2s ease;
      z-index: -1;
    }

    .video-card:hover {
      transform: translateY(-6px) scale(1.02);
      box-shadow: 0 32px 50px rgba(56, 95, 255, 0.22);
    }

    .video-card:hover::after {
      opacity: 1;
    }

    .thumb-wrapper {
      position: relative;
      width: 100%;
      padding-top: 62%;
      border-radius: 24px;
      overflow: hidden;
      background: #dfe9ff;
      margin-bottom: 18px;
    }

    .video-thumb {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .video-duration {
      position: absolute;
      bottom: 10px;
      right: 10px;
      background: rgba(0, 0, 0, 0.72);
      color: #ffffff;
      font-size: 0.8rem;
      font-weight: 700;
      padding: 4px 9px;
      border-radius: 999px;
      letter-spacing: 0.04em;
    }

    .video-info {
      padding: 0 10px;
      text-align: left;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .video-title {
      font-size: 1.05rem;
      font-weight: 800;
      margin: 0;
      color: #2a3767;
      line-height: 1.3;
    }

    .video-empty {
      grid-column: 1 / -1;
      text-align: center;
      padding: 60px 20px;
      background: rgba(255, 255, 255, 0.65);
      border-radius: 32px;
      box-shadow: 0 20px 36px rgba(87, 128, 255, 0.15);
      font-size: 1.05rem;
      font-weight: 600;
      color: #6271a4;
    }

    /* Quiz player wrapper */
    #player-container {
      display: none;
      margin-top: clamp(20px, 3vw,36px);
      width: 100%;
      flex-direction: column;
      gap: 24px;
      background: rgba(255, 255, 255, 0.92);
      border-radius: clamp(22px,4vw,36px);
      padding: clamp(18px,3vw,32px);  
      padding: 32px;
      box-shadow: 0 32px 60px rgba(41, 86, 160, 0.18);
    }

    /* Video layout */
    #video-wrapper {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 0;
      width: 100%;
    }
    /* Video container */
    #video-container {
      position: relative;
      display: inline-block;
      width: 960px;
      max-width: 100%;
      border-radius: 24px;
      overflow: hidden;
      background: transparent;
      transition: border-radius 0.2s ease;
    }

    #player {
      width: 100%;
      aspect-ratio: 16 / 9;
      display: block;
      margin: 0 auto;
      border-radius: 24px;
      overflow: hidden;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
      transition: border-radius 0.2s ease;
    }

    #player iframe {
      width: 100%;
      height: 100%;
      border: 0;
      display: block;
      position: relative;
      z-index: 1;
      pointer-events: none;
    }

    #yt-logo-blocker {
      position: absolute;
      top: 8px;
      right: 8px;
      width: 72px;
      height: 42px;
      z-index: 30;
      pointer-events: auto;
      background: transparent;
    }

    #yt-logo-blocker-left {
      position: absolute;
      top: 8px;
      left: 8px;
      width: 72px;
      height: 42px;
      z-index: 30;
      pointer-events: auto;
      background: transparent;
    }

    #yt-logo-blocker-bottom {
      position: absolute;
      bottom: 0;
      right: 0;
      width: 50%;
      height: 52px;
      z-index: 5;
      pointer-events: auto;
      background: #000;
    }

    #yt-end-blocker {
      position: absolute;
      inset: 0;
      z-index: 31;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(8, 16, 32, 0.55);
      color: #fff;
      font-weight: 700;
      font-size: 1.1rem;
      text-align: center;
      pointer-events: auto;
      cursor: pointer;
    }

    #yt-pause-blocker {
      position: absolute;
      inset: 0;
      z-index: 26;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(8, 16, 32, 0.45);
      color: #ffffff;
      font-weight: 700;
      font-size: 1.05rem;
      text-align: center;
      pointer-events: auto;
      cursor: pointer;
    }

    #local-player {
      width: 100%;
      height: 100%;
      display: block;
      background: #000;
    }

    .embed-fallback {
      position: absolute;
      top: 14px;
      left: 50%;
      transform: translateX(-50%);
      display: none;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.95);
      box-shadow: 0 12px 28px rgba(41, 86, 160, 0.18);
      z-index: 24;
      font-weight: 600;
      color: #394b7b;
    }

    .embed-fallback button {
      background: #1d4ed8;
      color: #fff;
      border: none;
      border-radius: 999px;
      padding: 6px 14px;
      font-weight: 600;
      cursor: pointer;
    }

    .embed-fallback button:hover {
      background: #1e40af;
    }

    /* Question box overlay */
    #question-box {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      display: none;
      z-index: 16;
      width: clamp(280px, 68%, 680px);
      max-width: calc(100% - 32px);
      background: none;
      align-items: flex-end;
      gap: 18px;
      pointer-events: none;
    }

    #question-box .question-character {
      width: clamp(120px, 24%, 190px);
      border-radius: 18px;
      background: rgba(255, 255, 255, 0.35);
      box-shadow: 0 18px 38px rgba(14, 55, 120, 0.22);
      overflow: hidden;
      pointer-events: none;
    }

    #question-box .question-character video {
      width: 100%;
      display: block;
    }

    @keyframes companion-speak {
      0%   { transform: translateY(0) rotate(0deg); }
      20%  { transform: translateY(-6px) rotate(-2deg); }
      40%  { transform: translateY(0) rotate(2deg); }
      60%  { transform: translateY(-4px) rotate(-1deg); }
      80%  { transform: translateY(0) rotate(1deg); }
      100% { transform: translateY(0) rotate(0deg); }
    }

    .companion-speaking {
      width: 100%;
      display: block;
      animation: companion-speak 0.6s ease-in-out infinite;
    }

    #question-box .question-bubble {
      position: relative;
      flex: 1;
      padding: 28px 32px;
      border-radius: 28px;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 32px 60px rgba(41, 86, 160, 0.18);
      pointer-events: auto;
    }

    #question-box .question-bubble::after {
      content: "";
      position: absolute;
      bottom: 22px;
      left: -22px;
      width: 32px;
      height: 32px;
      background: rgba(255, 255, 255, 0.96);
      transform: rotate(45deg);
      border-radius: 10px;
      box-shadow: -10px 12px 24px rgba(41, 86, 160, 0.16);
    }

    #question-box h3 {
      margin: 0;
      font-size: 1.6rem;
      font-weight: 700;
      color: #1f2a3d;
      text-align: left;
    }

    .question-actions {
      display: none;
      margin-top: 16px;
      gap: 12px;
      flex-wrap: wrap;
    }

    .question-actions button {
      border: none;
      border-radius: 999px;
      padding: 10px 18px;
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .question-actions button.retry-btn {
      background: linear-gradient(135deg, #5aa9ff, #69d6ff);
      color: #ffffff;
      box-shadow: 0 8px 18px rgba(90, 169, 255, 0.35);
    }

    .question-actions button.skip-btn {
      background: #ffffff;
      color: #1f2a3d;
      box-shadow: 0 6px 14px rgba(31, 42, 61, 0.15);
    }

    .question-actions button:focus-visible {
      outline: 3px solid rgba(90, 169, 255, 0.45);
      outline-offset: 2px;
    }

    .question-actions button:hover {
      transform: translateY(-1px);
    }

    .question-actions button:active {
      transform: translateY(0);
      box-shadow: none;
    }

    #feedback {
      margin-top: 14px;
      font-weight: 600;
      font-size: 1.1rem;
      color: #356ae6;
      text-align: left;
    }

    #timestamp {
      margin-top: 10px;
      font-size: 1rem;
      color: #52607b;
      font-style: italic;
      text-align: left;
    }

    /* Transparent blocker */
    #blocker {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0);
      z-index: 15;
      display: none;
      pointer-events: auto;
    }

    /* Floating controls */
    .video-floating-controls {
      position: absolute;
      top: 12px;
      right: 12px;
      display: flex;
      gap: 10px;
      z-index: 20;
    }

    .video-floating-controls button {
      background: rgba(0, 119, 204, 0.9);
      color: white;
      border: none;
      border-radius: 50%;
      width: 40px;
      height: 40px;
      font-size: 18px;
      cursor: pointer;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
      transition: background 0.2s ease;
    }

    .video-floating-controls button:hover,
    .video-floating-controls button:focus-visible {
      background: rgba(0, 95, 163, 0.95);
      outline: none;
    }

    #fullscreen-toggle[aria-pressed="true"] {
      background: rgba(0, 95, 163, 0.95);
    }

    #video-container:fullscreen,
    #video-container:-webkit-full-screen {
      width: 100vw !important;
      height: 100vh !important;
      max-width: 100vw !important;
      border-radius: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      background: #000 !important;
    }

    #video-container:fullscreen #player,
    #video-container:-webkit-full-screen #player {
      border-radius: 0 !important;
      width: 100% !important;
      height: 100% !important;
      max-width: 100% !important;
      aspect-ratio: auto !important;
      position: relative !important;
      overflow: hidden !important;
      background: #000 !important;
      box-shadow: none !important;
    }

    /* Fill fullscreen on 16:10/other displays by cropping edges instead of letterboxing. */
    #video-container:fullscreen #player iframe,
    #video-container:-webkit-full-screen #player iframe {
      position: absolute !important;
      top: 50% !important;
      left: 50% !important;
      width: 100vw !important;
      height: 56.25vw !important;
      min-width: 177.78vh !important;
      min-height: 100vh !important;
      transform: translate(-50%, -50%) !important;
      border-radius: 0 !important;
    }

    #video-container:fullscreen #local-player,
    #video-container:-webkit-full-screen #local-player {
      width: 100% !important;
      height: 100% !important;
      object-fit: cover !important;
    }

    #video-container:fullscreen #question-box,
    #video-container:-webkit-full-screen #question-box {
      width: clamp(280px, 60vw, 720px);
      max-width: 80vw;
    }

    #video-container:fullscreen #yt-logo-blocker-bottom,
    #video-container:-webkit-full-screen #yt-logo-blocker-bottom {
      width: 200px;
      height: 120px;
      bottom: 10px;
      right: 10px;
    }

    #video-container:fullscreen .video-fullscreen-hitbox,
    #video-container:-webkit-full-screen .video-fullscreen-hitbox {
      width: 220px;
      height: 120px;
      bottom: 10px;
      right: 10px;
    }

    #video-container:fullscreen .video-floating-controls,
    #video-container:-webkit-full-screen .video-floating-controls {
      top: 20px;
      right: 20px;
    }

    #video-container:fullscreen #companion-corner,
    #video-container:-webkit-full-screen #companion-corner {
      max-width: 220px;
    }

    .video-fullscreen-hitbox {
      position: absolute;
      bottom: 12px;
      right: 12px;
      width: 160px;
      height: 80px;
      z-index: 25;
      pointer-events: auto;
      display: flex;
      align-items: flex-end;
      justify-content: flex-end;
    }

    #question-overlay {
      position: absolute;
      inset: 0;
      background: rgba(20, 32, 61, 0.55);
      backdrop-filter: blur(10px);
      display: none;
      opacity: 0;
      z-index: 12;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }

    .video-fullscreen-hitbox button {
      pointer-events: auto;
      width: 48px;
      height: 48px;
      margin: 8px;
      border: none;
      border-radius: 50%;
      background: rgba(0, 0, 0, 0.45);
      color: #fff;
      font-size: 20px;
      display: grid;
      place-items: center;
      transition: background 0.2s ease;
    }

    .video-fullscreen-hitbox button:hover,
    .video-fullscreen-hitbox button:focus-visible {
      background: rgba(0, 0, 0, 0.6);
      outline: none;
    }

    .video-fullscreen-hitbox button .icon-exit {
      display: none;
    }

    body.fullscreen-active .video-fullscreen-hitbox button {
      background: rgba(0, 0, 0, 0.55);
    }

    body.fullscreen-active .video-fullscreen-hitbox button .icon-enter {
      display: none;
    }

    body.fullscreen-active .video-fullscreen-hitbox button .icon-exit {
      display: inline;
    }

    /* Sidebar (dev/testing) */
    #sidebar {
      width: 30%;
      border-left: 2px solid #ddd;
      padding: 15px;
      background: #f9f9f9;
      overflow-y: auto;
      max-height: 600px;
    }

    #sidebar h3 {
      margin-top: 0;
    }

    #sidebar ul {
      list-style: none;
      padding: 0;
    }

    #sidebar li {
      margin-bottom: 12px;
      font-size: 0.9em;
    }

    #sidebar a {
      color: #0077cc;
      text-decoration: none;
      cursor: pointer;
    }

    #sidebar a:hover {
      text-decoration: underline;
    }

    .hidden {
      display: none !important;
    }

    /* Responsive tweaks */
    @media (max-width: 1024px) {
      .kids-top-bar {
        gap: 16px;
        padding: 16px 22px;
        margin-bottom: 26px;
      }

      #question-box {
        width: clamp(280px, 82%, 560px);
      }

      #question-box .question-character {
        width: clamp(110px, 28%, 170px);
      }

      #question-box h3 {
        font-size: 1.45rem;
      }
    }

    @media (max-width: 900px) {
      .kids-top-bar {
        flex-direction: column;
        align-items: stretch;
        position: static;
        gap: 12px;
        margin-bottom: 28px;
      }

      .kids-top-left {
        width: 100%;
        justify-content: flex-start;
      }

      .kids-search {
        width: 100%;
        order: 2;
      }

      #video-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 26px;
      }

      .video-card {
        padding: 16px 16px 22px;
        border-radius: 28px;
      }

      .thumb-wrapper {
        border-radius: 22px;
        margin-bottom: 16px;
      }

      #question-box {
        gap: 14px;
      }

      #question-box .question-bubble {
        padding: 24px 26px;
      }

      #question-box .question-bubble::after {
        bottom: 18px;
        left: -18px;
        width: 26px;
        height: 26px;
      }
    }

    @media (max-width: 700px) {
      .kids-page {
        width: 94%;
      }

      #video-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 16px;
      }

      #video-container {
        width: 100%;
      }

      #video-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 22px;
      }

      .video-card {
        padding: 14px 14px 20px;
        border-radius: 26px;
      }

      .thumb-wrapper {
        padding-top: 58%;
      }

      .kids-top-bar {
        padding: 14px 18px;
        border-radius: 28px;
        margin-bottom: 24px;
      }

      .kids-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
      }

      #question-box {
        flex-direction: column-reverse;
        align-items: center;
        gap: 12px;
        width: clamp(260px, 92%, 360px);
      }

      #question-box .question-character {
        width: clamp(120px, 42%, 160px);
      }

      #question-box .question-bubble {
        padding: 22px 20px;
        text-align: center;
      }

      #question-box .question-bubble::after {
        bottom: -16px;
        left: 50%;
        transform: translateX(-50%) rotate(45deg);
        width: 28px;
        height: 28px;
        box-shadow: 0 14px 24px rgba(41, 86, 160, 0.16);
      }

      #question-box h3,
      #timestamp,
      #feedback {
        text-align: center;
      }
    }
