:root {
    --bg: #fbf6ec;
    --ink: #2d2a3e;
    --muted: #7a7590;
    --card: #ffffff;
    --accent: #7c6cf0;
    --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    -webkit-user-select: none;
    user-select: none;
}

/* Header */
.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 4px;
}
.top h1 { margin: 0; font-size: 30px; font-weight: 700; }
.right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 16px; white-space: nowrap; }
.icon {
    border: 0; background: #fff; border-radius: 50%;
    width: 44px; height: 44px; font-size: 20px;
    box-shadow: 0 1px 4px rgba(45, 42, 62, .18);
}

/* Category chips */
.cats {
    display: flex; gap: 12px; overflow-x: auto;
    padding: 12px 24px 6px; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; border: 0; border-radius: 999px;
    padding: 12px 22px; font: inherit; font-size: 18px; font-weight: 600;
    background: #fff; color: var(--ink);
    box-shadow: 0 1px 4px rgba(45, 42, 62, .18); cursor: pointer;
}
.chip.on { color: #fff; background: var(--chip, var(--accent)); }

/* Video grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 22px;
    padding: 14px 24px 48px;
}
.tile {
    display: flex; flex-direction: column; justify-content: flex-start;
    width: 100%; border: 0; padding: 0;
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    text-align: left; font: inherit; color: inherit; cursor: pointer;
    box-shadow: 0 2px 10px rgba(45, 42, 62, .10);
    transition: transform .12s ease;
}
.tile:active { transform: scale(.98); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #e9e4f5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur {
    position: absolute; right: 8px; bottom: 8px;
    background: rgba(0, 0, 0, .62); color: #fff;
    font-size: 13px; padding: 2px 9px; border-radius: 999px;
}
.tile h3 {
    margin: 12px 14px 16px; padding: 0;
    font-size: 17px; line-height: 1.3; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.empty { text-align: center; color: var(--muted); font-size: 20px; padding: 70px 24px; }

/* Player */
.player {
    position: fixed; inset: 0; z-index: 20;
    display: flex; flex-direction: column; background: #111;
}
.stage { position: relative; flex: 1; min-height: 0; background: #000; }
.stage iframe, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage video { background: #000; object-fit: contain; }
#shield { position: absolute; inset: 0; z-index: 2; }
.cover {
    position: absolute; inset: 0; z-index: 3; background: #15141c;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 96px; cursor: pointer;
}
.bar {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: #1b1a26; color: #fff;
}
.pill {
    border: 0; border-radius: 999px; padding: 12px 20px;
    font: inherit; font-size: 18px; font-weight: 600;
    background: #3a3857; color: #fff; cursor: pointer;
}
.bar input[type=range] { flex: 1; min-width: 80px; height: 32px; accent-color: #9a8cff; }
.now {
    flex: 0 1 28%; font-size: 15px; color: #cfcbe6;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Overlays */
.overlay {
    position: fixed; inset: 0; z-index: 30;
    display: flex; align-items: center; justify-content: center;
    background: rgba(45, 42, 62, .82);
}
.overlay.top-layer { z-index: 40; }
.card {
    width: calc(100% - 40px); max-width: 400px; padding: 30px 28px;
    background: #fff; border-radius: 28px; text-align: center;
}
.card h2 { margin: 0 0 8px; font-size: 26px; }
.card p { margin: 0 0 18px; color: var(--muted); font-size: 18px; }
.big { font-size: 64px; margin-bottom: 6px; }
.card input {
    width: 100%; padding: 14px; font-size: 26px; text-align: center; letter-spacing: 6px;
    border: 2px solid #ddd8ee; border-radius: 16px; margin: 12px 0 4px;
}
.msg { min-height: 24px; color: #d6455d !important; margin: 4px 0 8px !important; font-size: 16px !important; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn {
    border: 0; border-radius: 16px; padding: 14px 20px;
    font: inherit; font-size: 18px; font-weight: 600;
    background: var(--accent); color: #fff; cursor: pointer;
}
.btn.ghost { background: #eeeaf8; color: var(--ink); }

.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    z-index: 50; max-width: calc(100% - 40px);
    background: #2d2a3e; color: #fff; padding: 14px 22px; border-radius: 999px;
    font-size: 17px; text-align: center;
}

@media (max-width: 560px) {
    .top { padding: 14px 14px 2px; }
    .top h1 { font-size: 21px; }
    .right { font-size: 14px; gap: 10px; }
    .cats { padding: 10px 14px 4px; }
    .grid { grid-template-columns: 1fr 1fr; gap: 14px; padding: 12px 14px 40px; }
    .tile h3 { font-size: 15px; }
    .now { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .tile { transition: none; }
}
.noimg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 48px; background: linear-gradient(135deg, #7c6cf0, #f08cb0); }
.card.wide { max-width: 640px; width: 92%; }
.kids { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 18px; }
.kid { border: 0; border-radius: 24px; padding: 18px 26px; min-width: 130px; background: var(--kid, #7c6cf0); color: #fff; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 2px 8px rgba(45, 42, 62, .25); }
.kid-emoji { font-size: 54px; line-height: 1; }
.kid-name { font-size: 20px; font-weight: 700; }
.who { font-weight: 700; color: var(--ink); }
