:root {
    --ink: #f4f1ea;
    --bg: #12101a;
    --panel: #1c1a26;
    --panel-2: #262433;
    --muted: #9c98ad;
    --accent: #f6b93b;
    --danger: #e55039;
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

/* Several components below are flex containers, which would otherwise win
   against the hidden attribute. */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1,
h2 {
    margin: 0 0 0.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 0.6rem;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.grow {
    flex: 1;
    min-width: 0;
}

/* ---------- shared shell ---------- */

.sheet {
    max-width: 34rem;
    margin: 0 auto;
    padding: 1.5rem 1.1rem 4rem;
}

.sheet.wide {
    max-width: 56rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.row.between {
    justify-content: space-between;
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

input[type="text"],
input[type="password"] {
    flex: 1;
    min-width: 8rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid #35323f;
    background: var(--panel-2);
    color: var(--ink);
    font-size: 1rem;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.85rem 1.2rem;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #241b06;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn.small {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.btn.ghost {
    background: var(--panel-2);
    color: var(--ink);
}

.btn.danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1px var(--danger);
}

.btn[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

.alert,
.notice {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(229, 80, 57, 0.15);
    color: #ffb1a2;
}

.notice {
    background: rgba(56, 173, 169, 0.15);
    color: #9fe6e3;
}

.link-box {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.link-box label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar.large {
    width: 96px;
    height: 96px;
}

.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #241b06;
    font-weight: 800;
}

.avatar.placeholder {
    font-size: 1rem;
}

.avatar.large.placeholder {
    font-size: 2rem;
}

.member-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.member-list audio {
    height: 2rem;
    max-width: 12rem;
}

/* ---------- family portal ---------- */

body.portal {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

/* A fixed height app shell: header, one visible panel, tab bar. Nothing scrolls
   except the message list, so the record button is always under the thumb. */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 34rem;
    margin: 0 auto;
}

.app-bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 1rem 0.7rem;
}

.app-avatar {
    position: relative;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.app-avatar img,
.app-avatar .placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    font-size: 0.95rem;
}

.app-avatar-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: #241b06;
    box-shadow: 0 0 0 2px var(--bg);
}

.app-bar-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.app-bar-text strong {
    font-size: 1.05rem;
}

.app-bar-text span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.panels {
    position: relative;
    flex: 1;
    min-height: 0;
}

.panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- record panel ---------- */

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 0 0.75rem 0.75rem;
    border-radius: 22px;
    overflow: hidden;
    background: #000;
}

.stage-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

#preview {
    transform: scaleX(-1);
}

#playback {
    object-fit: contain;
}

.voice-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 42%, #2f2a45, #12101a);
}

.voice-icon {
    position: relative;
    color: var(--accent);
}

/* Scaled from the live microphone level, so nobody records silence by accident. */
.level-ring {
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.28;
    transform: scale(0.7);
    transition: transform 90ms linear;
}

.stage-top {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.segmented {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.segment {
    padding: 0.45rem 0.95rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: rgba(255, 255, 255, 0.72);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.segment.is-active {
    background: #fff;
    color: #191722;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.timer::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    animation: blink 1.2s infinite;
}

@keyframes blink {
    50% { opacity: 0.2; }
}

.stage-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 9.5rem;
    z-index: 2;
    margin: 0;
    padding: 0 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    pointer-events: none;
}

.stage audio {
    position: absolute;
    left: 1rem;
    bottom: 8.5rem;
    z-index: 4;
    width: calc(100% - 2rem);
}

.stage-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 3rem 1rem 1.1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.35) 55%, transparent);
}

.level-meter {
    width: 110px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.level-meter-fill {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 90ms linear;
}

.stage-status {
    margin: 0;
    min-height: 1.15em;
    color: #fff;
    font-size: 0.85rem;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.stage-status.is-error {
    color: #ffb1a2;
}

.record-button {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.92);
    background: var(--danger);
    cursor: pointer;
    transition: border-radius 0.15s ease, transform 0.15s ease;
}

.record-button.is-recording {
    border-radius: 16px;
    transform: scale(0.78);
}

.review {
    display: flex;
    gap: 0.6rem;
    width: 100%;
}

.review .btn {
    flex: 1;
}

.progress {
    width: 100%;
    height: 6px;
    margin: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.2s ease;
}

/* ---------- messages panel ---------- */

#panel-messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.25rem 0.75rem 1rem;
}

.message-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    border-radius: 16px;
    background: var(--panel);
}

.message-item[data-status="pending"],
.message-item[data-status="processing"] {
    opacity: 0.6;
}

.message-item[data-status="failed"] {
    box-shadow: inset 0 0 0 1px rgba(229, 80, 57, 0.55);
}

.thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel-2);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-glyph {
    color: var(--accent);
    font-size: 1.4rem;
}

.message-empty {
    padding: 3rem 1.5rem;
    border-radius: 18px;
    background: var(--panel);
    text-align: center;
}

.message-empty p {
    margin: 0 0 0.35rem;
}

/* ---------- tab bar ---------- */

.tab-bar {
    flex: none;
    display: flex;
    background: var(--bg);
    border-top: 1px solid #2a2836;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.55rem 0.5rem 0.65rem;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

.tab.is-active {
    color: var(--accent);
}

.tab-badge {
    position: absolute;
    top: 0.3rem;
    left: calc(50% + 0.55rem);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--ink);
    font-size: 0.65rem;
}

/* In the flex flow rather than floating, so it can never sit over the record
   button. */
.install-sheet {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0.75rem 0.75rem;
    padding: 0.7rem 0.8rem;
    border-radius: 16px;
    background: var(--panel-2);
}

.install-sheet p {
    margin: 0.1rem 0 0;
}

.name-clip {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0.75rem 0.75rem;
    padding: 0.7rem 0.8rem;
    border-radius: 16px;
    background: var(--panel-2);
    box-shadow: inset 0 0 0 1px rgba(246, 185, 59, 0.25);
}

.name-clip p {
    margin: 0.1rem 0 0;
}

.name-clip audio {
    width: 100%;
    height: 2.4rem;
}

/* ---------- Ben's screen ---------- */

body.kiosk {
    overflow: hidden;
    user-select: none;
    cursor: none;
    height: 100vh;
    height: 100dvh;
}

.kiosk-app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.age-bar {
    flex: none;
    display: flex;
    justify-content: center;
    gap: clamp(1.2rem, 4vw, 2.8rem);
    padding: 1.15rem 1rem 0.35rem;
}

.age-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 4.2rem;
}

.age-part strong {
    color: var(--accent);
    font-size: clamp(1.7rem, 4.4vw, 2.6rem);
    font-weight: 800;
    line-height: 1;
}

.age-part span {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: clamp(0.85rem, 1.8vw, 1.05rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}

.kiosk-stage {
    position: relative;
    flex: 1;
    min-height: 0;
}

.kiosk-panel {
    position: absolute;
    inset: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 3vh 3vw 2vh;
}

.kiosk-tabs {
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    padding: 0.9rem 1.1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid #2a2836;
}

.kiosk-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 6.8rem;
    padding: 0.9rem 0.5rem;
    border: 0;
    border-radius: 22px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: clamp(1.15rem, 3vw, 1.7rem);
    font-weight: 800;
    cursor: pointer;
}

.kiosk-tab i {
    font-size: 2.1em;
    line-height: 1;
}

.kiosk-tab.is-active {
    background: var(--panel-2);
    color: var(--accent);
    box-shadow: inset 0 0 0 3px rgba(246, 185, 59, 0.35);
}

.kiosk-tab-dot {
    position: absolute;
    top: 0.7rem;
    right: 1.1rem;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sized so the whole set is on screen at once. A tile Ben has to scroll to
   find is a tile he does not know exists. */
.learn-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
    gap: 2.5vh 2vw;
}

.learn-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem 1.2rem;
    border-radius: 28px;
    background: var(--panel);
    text-align: center;
}

.learn-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.6rem;
    height: 4.6rem;
    border-radius: 50%;
    background: var(--panel-2);
    color: var(--accent);
    font-size: 2rem;
}

.learn-card-name {
    font-size: clamp(1.3rem, 3.2vw, 2rem);
    font-weight: 800;
}

.learn-card-meta {
    color: var(--muted);
    font-size: 1.05rem;
}

.learn-card a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: inherit;
}

.learn-card.is-soon {
    opacity: 0.72;
}

/* ---------- Card deck: animals, food, faces ---------- */

body.deck {
    background: #000;
}

.deck-screen {
    position: fixed;
    inset: 0;
    background: #000;
}

.deck-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.deck-words {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    padding: 5rem 1.2rem 2.4rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2) 70%, transparent);
}

.deck-word {
    min-width: min(86vw, 520px);
    padding: 0.85rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font: inherit;
    font-size: clamp(2rem, 7vw, 3.6rem);
    font-weight: 800;
    line-height: 1.15;
    cursor: pointer;
}

.deck-word-th {
    font-family: "Noto Sans Thai", "SF Pro Rounded", sans-serif;
    font-size: clamp(1.8rem, 6vw, 3.1rem);
    background: rgba(246, 185, 59, 0.92);
    color: #241b06;
}

.deck-word.is-empty {
    visibility: hidden;
    pointer-events: none;
}

/* Hidden is not enough on its own: with no text the button shrinks to its
   padding and the English word slides down to meet it. */
.deck-word.is-empty::before {
    content: "\00a0";
}

.deck-nav {
    position: absolute;
    top: 50%;
    z-index: 7;
    width: 4.4rem;
    height: 4.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 1.8rem;
    transform: translateY(-50%);
    cursor: pointer;
}

.deck-prev {
    left: 1.2rem;
}

.deck-next {
    right: 1.2rem;
}

.deck-screen.is-portrait {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.deck-screen.is-portrait .deck-image {
    width: auto;
    height: auto;
    /* Clear of the words along the bottom and the arrows either side. */
    max-width: min(52vh, 60vw);
    max-height: 52vh;
    aspect-ratio: 1;
    margin-bottom: 14vh;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.deck-screen.is-portrait .deck-words {
    background: none;
    padding-top: 1rem;
}

/* The arrows sit on a dark background here, not on a picture. */
.deck-screen.is-portrait .deck-nav {
    background: rgba(255, 255, 255, 0.14);
}

/* ---------- Peekaboo ---------- */

.peekaboo-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 2vh 2vw;
}

.flap-grid {
    list-style: none;
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2vh 2vw;
}

.flap {
    position: relative;
    perspective: 1400px;
}

.flap-button {
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 26px;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.flap-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 520ms cubic-bezier(0.22, 0.8, 0.3, 1);
    transform-style: preserve-3d;
}

.flap.is-open .flap-inner {
    transform: rotateY(-168deg);
}

.flap-front,
.flap-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 26px;
    backface-visibility: hidden;
}

.flap-front {
    color: rgba(0, 0, 0, 0.35);
    font-size: clamp(2.6rem, 9vh, 5.5rem);
}

.flap-back {
    flex-direction: column;
    background: var(--panel);
    transform: rotateY(180deg);
}

.flap-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* A door is wider than it is tall, so a square photo has to be sized off the
   height or the circle comes out as an oval. */
.flap-back.is-portrait img {
    width: auto;
    height: 82%;
    aspect-ratio: 1;
    border-radius: 50%;
}

.flap-word {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.6rem 0.6rem 0.7rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: #fff;
    font-size: clamp(1.1rem, 2.6vh, 1.9rem);
    font-weight: 800;
    text-align: center;
}

.peekaboo-foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 5.5rem;
    padding-top: 1.5vh;
}

.peekaboo-foot .home-button {
    position: static;
    width: 4rem;
    height: 4rem;
    font-size: 1.7rem;
}

.peekaboo-again {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 2.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #241b06;
    font: inherit;
    font-size: clamp(1.2rem, 3vh, 1.9rem);
    font-weight: 800;
    cursor: pointer;
}

/* ---------- Paint ---------- */

.paint-screen {
    position: fixed;
    inset: 0;
    display: flex;
    background: #f7f4ec;
}

.paint-canvas {
    flex: 1;
    min-width: 0;
    display: block;
    touch-action: none;
}

/* Two narrow columns rather than one long one: a single stack of buttons is
   taller than a 768px screen, which pushed the way out off the bottom. */
.paint-tools {
    flex: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2.5vh;
    padding: 1.5vh 1rem calc(1.5vh + env(safe-area-inset-bottom, 0px));
    background: var(--panel);
}

.paint-group {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;
    gap: 1.2vh 0.7rem;
}

.paint-group + .paint-group {
    padding-top: 2.5vh;
    border-top: 2px solid #3a3748;
}

.paint-tool,
.paint-swatch,
.paint-screen .home-button {
    width: clamp(3.2rem, 6.4vh, 4.6rem);
    height: clamp(3.2rem, 6.4vh, 4.6rem);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.paint-tool,
.paint-screen .home-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    color: var(--muted);
    font-size: clamp(1.3rem, 2.8vh, 1.9rem);
}

.paint-tool.is-active {
    color: var(--ink);
    box-shadow: inset 0 0 0 3px var(--accent);
}

.paint-swatch.is-active {
    box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px currentColor;
}

.paint-screen .home-button {
    position: static;
    color: var(--ink);
}

.wifi-splash {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    background: var(--bg);
}

.wifi-splash-face {
    width: min(42vw, 280px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--splash-icon, url("/icons/icon-512.png")) center / cover no-repeat;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.wifi-splash p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(1rem, 2.4vw, 1.35rem);
    font-weight: 600;
}

html.is-idle .wifi-splash-face {
    animation: pulse 2.8s ease-in-out infinite;
}

html.is-waiting-wifi .wifi-splash,
html.is-idle .wifi-splash {
    display: flex !important;
}

.grid-screen {
    min-height: 100%;
}

.profile-screen {
    min-height: 100vh;
    padding: 3vh 3vw 6vh;
}

.kiosk-head {
    text-align: center;
    margin-bottom: 3vh;
}

.kiosk-head h1 {
    font-size: clamp(2rem, 6vw, 4rem);
}

.kiosk-head p {
    color: var(--muted);
    font-size: clamp(1rem, 2.5vw, 1.6rem);
}

.face-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    /* Two big faces on a phone, three on the 1080px-wide wall screen. */
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 4vh 4vw;
}

.face a,
.face .face-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.face-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: visible;
}

.face-photo img,
.face-photo .placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    font-size: clamp(2rem, 8vw, 5rem);
}

.face.has-content:not(.is-new) .face-photo {
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.28);
}

.face.is-quiet {
    opacity: 0.72;
}

.face.is-new .face-photo {
    box-shadow: 0 0 0 8px var(--danger), 0 0 40px rgba(229, 80, 57, 0.6);
    border-radius: 50%;
    animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
    50% { transform: translateY(-10px); }
}

.new-dot {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 2.6rem;
    height: 2.6rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 5px var(--bg);
}

.face-name {
    font-size: clamp(1.1rem, 3vw, 2rem);
    font-weight: 700;
    text-align: center;
}

.kiosk-empty {
    text-align: center;
    color: var(--muted);
    font-size: 1.5rem;
    margin-top: 20vh;
}

/* ---------- profile ---------- */

.profile-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 4vh;
}

.face-photo.big {
    width: 40vw;
    max-width: 320px;
}

.profile-head h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
}

.home-button,
.exit-button {
    position: fixed;
    top: 2vh;
    width: 4.5rem;
    height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    font-size: 2rem;
    text-decoration: none;
    z-index: 10;
    cursor: pointer;
}

.home-button {
    left: 2vw;
}

.home-button i,
.kiosk-tab i,
.learn-card-icon i {
    line-height: 1;
}

.exit-button {
    right: 2vw;
    background: rgba(255, 255, 255, 0.2);
}

.clip-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3vh 3vw;
}

.clip a {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    overflow: hidden;
    background: var(--panel);
}

.clip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clip-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 4rem;
    color: var(--accent);
}

.clip-meta {
    position: absolute;
    bottom: 0.6rem;
    left: 0.6rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.clip.is-new a {
    box-shadow: inset 0 0 0 5px var(--danger);
}

.clip .new-dot {
    top: 0.6rem;
    right: 0.6rem;
    min-width: 1.6rem;
    height: 1.6rem;
    box-shadow: none;
}

/* ---------- player ---------- */

body.player {
    background: #000;
}

.player-screen {
    position: fixed;
    inset: 0;
    background: #000;
}

.player-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    background: #000;
}

.audio-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-face img,
.audio-face .placeholder {
    width: 60vw;
    max-width: 420px;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
    font-size: 6rem;
}

.pulse-ring {
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.25;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(0.92); opacity: 0.2; }
    50% { transform: scale(1.06); opacity: 0.35; }
}

.audio-face .pulse-ring {
    position: absolute;
    width: 60vw;
    max-width: 420px;
    aspect-ratio: 1;
    height: auto;
}

.pause-overlay,
.tap-start {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 5;
}

.pause-icon {
    font-size: 6rem;
    color: #fff;
    opacity: 0.9;
}

.tap-start span {
    padding: 1rem 2rem;
    border-radius: 999px;
    background: var(--accent);
    color: #241b06;
    font-size: 2rem;
    font-weight: 800;
}

.player-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
}

.player-progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
}

.kiosk-opening {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    background: #12101a;
    pointer-events: none;
}

.kiosk-opening[hidden] {
    display: none;
}

.kiosk-opening-photo {
    width: min(38vw, 240px);
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.22);
}

.kiosk-opening-photo:empty {
    display: none;
}

.kiosk-opening-photo img,
.kiosk-opening-photo .placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.kiosk-opening-spin {
    width: 2.3rem;
    height: 2.3rem;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.kiosk-opening p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    font-weight: 700;
}

.face a:active .face-photo,
.face a.is-opening .face-photo {
    transform: scale(0.94);
}

.clip a:active,
.clip a.is-opening {
    transform: scale(0.97);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
