:root {
  --ink: #29304a;
  --cream: #fff1f7;
  --yellow: #ffd45c;
  --pink: #ff77aa;
  --blue: #79c8f5;
  --green: #85d9a5;
  --shadow: 0 12px 0 rgba(41, 48, 74, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #fff 0 6%, transparent 7%),
    radial-gradient(circle at 90% 13%, #ffd6e6 0 5%, transparent 6%),
    var(--cream);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4vw, 56px) 12px;
}

.brand, .parent-button, .back-button, .lock-button, .unlock-button {
  border: 0;
  font-weight: 900;
}

.brand { display: flex; gap: 10px; align-items: center; background: transparent; font-size: clamp(20px, 5vw, 30px); }
.brand-sun { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--pink); color: white; }
.parent-button, .back-button { padding: 13px 18px; border-radius: 999px; background: #fff; box-shadow: 0 5px 0 rgba(41,48,74,.12); }
.view { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 48px; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 190px;
  margin: 18px 0 28px;
  padding: clamp(24px, 5vw, 54px);
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 36px;
  background: linear-gradient(135deg, var(--pink), #ffb4cf);
  box-shadow: var(--shadow);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(34px, 7vw, 72px); line-height: .98; letter-spacing: -0.045em; }
h2 { font-size: 30px; }
.eyebrow { margin-bottom: 8px; color: #9b2858; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
.hero-art { font-size: clamp(90px, 18vw, 180px); transform: rotate(-10deg); }

.category-menu { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 34px; }
.category-button { min-height: 112px; padding: 12px 8px; border: 4px solid var(--ink); border-radius: 24px; background: white; box-shadow: 0 7px 0 rgba(41,48,74,.14); font-weight: 900; }
.category-button:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(41,48,74,.14); }
.category-button.active { background: var(--pink); color: white; transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.category-icon { display: block; margin-bottom: 5px; font-size: 38px; }
.category-name { display: block; font-size: 16px; }
.shelf-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 3px 18px; }
.shelf-heading h2 { margin-bottom: 0; font-size: clamp(30px, 5vw, 46px); }
.shelf-count { padding: 8px 12px; border-radius: 999px; background: #fff; font-weight: 900; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }
.video-card {
  position: relative;
  min-height: 260px;
  padding: 0;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
}
.video-card:active { transform: translateY(6px); box-shadow: 0 6px 0 rgba(41,48,74,.12); }
.thumbnail { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #ddd; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; }
.card-title { font-size: 22px; font-weight: 900; }
.play-dot { display: grid; flex: 0 0 46px; place-items: center; width: 46px; height: 46px; border: 3px solid var(--ink); border-radius: 50%; background: var(--pink); color: white; }
.video-card.berry .card-bottom { background: #ffe2eb; }
.video-card.sky .card-bottom { background: #e4f5ff; }
.video-card.mint .card-bottom { background: #e3f8eb; }
.video-card.sunny .card-bottom { background: #fff3c9; }
.catalog-message { grid-column: 1 / -1; padding: 32px; border: 4px dashed #b7af98; border-radius: 28px; background: white; text-align: center; }
.catalog-message h3 { margin-bottom: 0; font-size: clamp(20px, 4vw, 30px); }
.setup-button { width: auto; margin-top: 18px; }
.load-more { grid-column: 1 / -1; padding: 18px; border: 3px solid var(--ink); border-radius: 18px; background: var(--pink); color: white; font-weight: 900; }

.empty-state { padding: 60px 20px; border: 4px dashed #b7af98; border-radius: 30px; text-align: center; }
.empty-state span { font-size: 70px; color: var(--yellow); }

.player-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; margin: 28px 0 20px; }
.player-heading h1 { font-size: clamp(25px, 5vw, 48px); }
.lock-button { padding: 16px 20px; border: 3px solid var(--ink); border-radius: 18px; background: var(--pink); box-shadow: 0 6px 0 var(--ink); }
.player-shell { position: relative; overflow: hidden; border: 5px solid var(--ink); border-radius: 28px; background: #111; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.player-shell iframe { width: 100%; height: 100%; border: 0; }
.touch-shield { display: none; position: absolute; inset: 0; }
.player-shell.locked .touch-shield { display: block; }
.lock-tip { margin: 22px auto; max-width: 680px; color: #625f71; text-align: center; font-weight: 700; }

.locked-overlay { position: fixed; z-index: 20; inset: 0; pointer-events: auto; touch-action: none; }
.locked-badge { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%; display: flex; align-items: center; gap: 7px; padding: 9px 15px; transform: translateX(-50%); border-radius: 999px; background: rgba(20,22,30,.82); color: white; font-weight: 900; }
.lock-icon { color: var(--pink); animation: lockPulse 1.8s ease-in-out infinite; }
.unlock-button { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 150px; height: 48px; padding: 0; overflow: hidden; border: 2px solid rgba(255,255,255,.55); border-radius: 999px; background: rgba(20,22,30,.72); color: white; opacity: .55; }
.unlock-progress { position: absolute; inset: 0 100% 0 0; background: var(--pink); transition: right 1.25s linear; }
.unlock-button.holding .unlock-progress { right: 0; }
.unlock-button.armed { opacity: 1; border-color: white; }
.unlock-button.armed .unlock-progress { right: 0; }
.unlock-label { position: relative; z-index: 1; }
@keyframes lockPulse { 50% { opacity: .35; } }

.app-locked {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.app-locked * { touch-action: none; }
.app-locked #unlockButton { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.app-locked.unlock-prompt-open #pinDialog,
.app-locked.unlock-prompt-open #pinDialog * { touch-action: manipulation; user-select: auto; -webkit-user-select: auto; }
.app-locked.unlock-prompt-open #pinDialog { position: fixed; z-index: 1000; transform: none; }
.app-locked.unlock-prompt-open #pinCloseButton { position: absolute; z-index: 1001; pointer-events: auto; }
.app-locked .player-view {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: var(--locked-stage-width);
  height: var(--locked-stage-height);
  max-width: none;
  padding: 0;
  transform: translate(-50%, -50%) rotate(var(--locked-stage-rotation));
  transform-origin: center;
  background: #111;
}
.app-locked .topbar, .app-locked .player-heading, .app-locked .lock-tip { display: none; }
.app-locked .player-shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  box-shadow: none;
}

.parent-dialog { width: min(520px, calc(100% - 28px)); max-height: 90vh; padding: 28px; overflow-y: auto; border: 4px solid var(--ink); border-radius: 28px; box-shadow: 0 16px 0 rgba(41,48,74,.2); }
.parent-dialog::backdrop { background: rgba(41,48,74,.62); backdrop-filter: blur(4px); }
.parent-dialog form { position: relative; }
.dialog-close { position: absolute; top: -15px; right: -12px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: #eee; font-size: 28px; }
.helper { color: #65687a; line-height: 1.5; }
label { display: grid; gap: 7px; margin: 14px 0; font-weight: 900; }
input, select { width: 100%; padding: 14px; border: 3px solid #d6d3c8; border-radius: 14px; background: white; }
input:focus, select:focus { outline: 3px solid var(--blue); border-color: var(--ink); }
.primary-button, .secondary-button { padding: 14px 18px; border: 3px solid var(--ink); border-radius: 14px; font-weight: 900; }
.primary-button { width: 100%; background: var(--pink); color: white; }
.secondary-button { background: white; }
.error { min-height: 20px; color: #b42335; font-weight: 800; }
.parent-section, .change-pin-form { margin-top: 28px; padding-top: 24px; border-top: 3px dashed #ddd7c9; }
.parent-video { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; padding: 12px; border-radius: 14px; background: #f6f3eb; font-weight: 800; }
.delete-button { border: 0; background: transparent; color: #b42335; font-weight: 900; }
.guide { padding: 18px; border: 0; border-radius: 18px; background: #e4f5ff; line-height: 1.5; }

@media (max-width: 650px) {
  .hero { min-height: 150px; border-radius: 26px; }
  .hero-art { display: none; }
  .category-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 26px; }
  .category-button { min-height: 92px; border-width: 3px; border-radius: 18px; }
  .category-icon { font-size: 28px; }
  .category-name { font-size: 13px; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .video-card { min-height: 0; border-width: 3px; border-radius: 20px; box-shadow: 0 7px 0 rgba(41,48,74,.12); }
  .card-bottom { align-items: flex-start; padding: 12px; }
  .card-title { font-size: 16px; }
  .play-dot { width: 34px; height: 34px; flex-basis: 34px; border-width: 2px; }
  .player-heading { grid-template-columns: 1fr auto; }
  .player-heading > div { display: none; }
  .player-shell { width: calc(100% + 32px); margin-left: -16px; border-right: 0; border-left: 0; border-radius: 0; }
}

@media (orientation: landscape) and (max-height: 650px) {
  .topbar { display: none; }
  .player-view { width: 100%; padding: 0; }
  .player-heading { position: fixed; z-index: 8; top: 10px; right: 10px; left: 10px; margin: 0; pointer-events: none; }
  .player-heading button { pointer-events: auto; opacity: .72; }
  .player-heading > div { display: none; }
  .player-shell { width: 100vw; height: 100vh; margin: 0; border: 0; border-radius: 0; aspect-ratio: auto; box-shadow: none; }
  .lock-tip { display: none; }
}
