:root {
    color-scheme: dark;
    --ink: #f7f7fb;
    --muted: #a7a8b7;
    --night: #090b18;
    --panel: #121528;
    --panel-2: #191d34;
    --line: rgba(255, 255, 255, .12);
    --yellow: #ffd84d;
    --cyan: #61e7f2;
    --pink: #ff6699;
    --danger: #ff7d7d;
    --shadow: 0 32px 90px rgba(0, 0, 0, .42);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 12%, rgba(97, 231, 242, .11), transparent 28rem),
        radial-gradient(circle at 85% 88%, rgba(255, 102, 153, .09), transparent 30rem),
        var(--night);
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header {
    width: min(1180px, calc(100% - 40px));
    height: 84px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 850; letter-spacing: -.03em; text-decoration: none; font-size: 1.18rem; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--night); background: var(--yellow); border-radius: 11px 11px 11px 3px; font-size: .9rem; transform: rotate(-3deg); box-shadow: 4px 4px 0 var(--cyan); }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a, .nav-button { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 650; }
.site-nav a:hover, .site-nav a[aria-current="page"], .nav-button:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.site-nav .nav-join { color: var(--night); background: var(--yellow); }

.joke-shell { width: min(940px, calc(100% - 40px)); min-height: calc(100vh - 84px); margin: 0 auto; padding: clamp(32px, 6vh, 72px) 0 48px; }
.joke-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.field-inline select, .admin-form select { appearance: none; color: var(--ink); background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23a7a8b7' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 42px 10px 14px; }
.switch { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: .9rem; font-weight: 650; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--yellow); }

.joke-card {
    position: relative;
    min-height: min(55vh, 540px);
    padding: clamp(24px, 5vw, 54px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(25,29,52,.98), rgba(15,18,34,.98));
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 28px;
    box-shadow: var(--shadow);
    cursor: pointer;
    outline: none;
}
.joke-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: linear-gradient(90deg, var(--cyan), var(--yellow) 48%, var(--pink)); }
.joke-card::after { content: "{ HA }"; position: absolute; right: -15px; bottom: 52px; color: rgba(255,255,255,.025); font: 900 clamp(5rem, 16vw, 11rem)/1 ui-monospace, monospace; transform: rotate(-8deg); pointer-events: none; }
.joke-card:focus-visible { box-shadow: var(--shadow), 0 0 0 4px var(--cyan); }
.card-topline { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; }
.category-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 11px; border: 1px solid rgba(97,231,242,.35); border-radius: 999px; color: var(--cyan); background: rgba(97,231,242,.06); font: 700 .75rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(255,255,255,.04); cursor: pointer; font-size: 1.55rem; transition: transform .18s, background .18s; }
.icon-button:hover { transform: scale(1.06); background: rgba(255,255,255,.1); }
.favorite-button.is-saved { color: var(--pink); border-color: rgba(255,102,153,.45); background: rgba(255,102,153,.1); }
.joke-copy { position: relative; z-index: 1; margin: clamp(42px, 8vh, 80px) 0; max-width: 790px; }
.joke-kicker, .eyebrow { margin: 0 0 20px; color: var(--yellow); font: 800 .78rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .13em; }
.joke-copy h1 { margin: 0; font-size: clamp(2rem, 5.2vw, 4.4rem); line-height: 1.07; letter-spacing: -.045em; text-wrap: balance; }
.punchline { max-width: 690px; margin-top: 26px; padding-top: 25px; color: var(--yellow); border-top: 1px solid var(--line); font-size: clamp(1.35rem, 2.8vw, 2.15rem); font-weight: 750; line-height: 1.25; letter-spacing: -.02em; animation: punch-in .28s ease-out; }
.tap-hint { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: .9rem; }
.tap-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: var(--yellow); border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,216,77,.1); }
@keyframes punch-in { from { opacity: 0; transform: translateY(8px); } }

.player-controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 12px; margin-top: 18px; }
.control-button, .submit-button { min-height: 50px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--panel); font-weight: 750; cursor: pointer; text-decoration: none; transition: transform .15s, border-color .15s, background .15s; }
.control-button:hover, .submit-button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.3); }
.control-primary, .submit-button { color: var(--night); background: var(--yellow); border-color: var(--yellow); }
.member-nudge { display: flex; justify-content: center; gap: 10px; margin-top: 28px; color: var(--muted); font-size: .9rem; }
.member-nudge a { color: var(--cyan); font-weight: 700; }

.auth-shell { width: min(1040px, calc(100% - 40px)); min-height: calc(100vh - 84px); margin: 0 auto; padding: clamp(52px, 10vh, 110px) 0; display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(40px, 8vw, 100px); align-items: center; }
.auth-intro h1, .page-heading h1, .error-shell h1 { margin: 0; font-size: clamp(2.6rem, 6vw, 5.8rem); line-height: .96; letter-spacing: -.055em; text-wrap: balance; }
.auth-intro > p:last-child, .page-heading > p:last-child, .error-shell > p { max-width: 540px; color: var(--muted); font-size: 1.1rem; line-height: 1.65; }
.auth-card, .admin-form { padding: clamp(24px, 4vw, 38px); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card label, .admin-form label { display: grid; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: .88rem; font-weight: 700; }
.auth-card input, .admin-form textarea { width: 100%; padding: 14px 15px; color: var(--ink); background: #0c0f20; border: 1px solid var(--line); border-radius: 11px; outline: none; }
.auth-card input:focus, .admin-form textarea:focus, .admin-form select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(97,231,242,.12); }
.form-note { margin: -10px 0 20px; color: var(--muted); font-size: .8rem; }
.form-error { padding: 10px 12px; color: var(--danger); background: rgba(255,125,125,.08); border-radius: 9px; font-size: .88rem; }
.submit-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 0 20px; }
.auth-switch { margin: 22px 0 0; color: var(--muted); text-align: center; font-size: .9rem; }
.auth-switch a { color: var(--cyan); }

.library-shell, .admin-shell, .error-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 70px 0 90px; }
.page-heading { margin-bottom: 42px; }
.page-heading h1 { font-size: clamp(2.8rem, 7vw, 5rem); }
.joke-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.mini-joke { display: flex; flex-direction: column; align-items: flex-start; min-height: 270px; padding: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.mini-joke h2 { margin: 26px 0 12px; font-size: 1.4rem; line-height: 1.28; }
.mini-joke p { margin: 0; color: var(--yellow); line-height: 1.5; }
.mini-joke > div { display: flex; justify-content: space-between; width: 100%; margin-top: auto; padding-top: 24px; }
.mini-joke a, .mini-joke button { color: var(--cyan); background: none; border: 0; padding: 0; font-weight: 700; cursor: pointer; }
.mini-joke button { color: var(--muted); }
.empty-state { padding: 70px 30px; text-align: center; background: var(--panel); border: 1px dashed rgba(255,255,255,.2); border-radius: 22px; }
.empty-state > span { color: var(--pink); font-size: 3rem; }
.empty-state h2 { margin: 12px 0 4px; }
.empty-state p { color: var(--muted); }
.empty-state a { color: var(--cyan); font-weight: 700; }

.admin-shell { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.admin-shell .page-heading { grid-column: 1 / -1; margin-bottom: 0; }
.admin-form { align-self: start; position: sticky; top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.admin-form select { width: 100%; }
.admin-list { display: grid; gap: 9px; }
.admin-list-item { padding: 16px; color: var(--ink); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.admin-list-item:hover { border-color: var(--cyan); }
.admin-list-item span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.admin-list-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-shell { min-height: calc(100vh - 84px); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.error-shell .submit-button { width: auto; margin-top: 18px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; color: var(--night); background: var(--cyan); border-radius: 999px; box-shadow: var(--shadow); font-weight: 750; }

@media (max-width: 720px) {
    .site-header { width: min(100% - 24px, 1180px); height: 70px; }
    .site-nav a:not(.nav-join), .site-nav .nav-button { display: none; }
    .joke-shell { width: min(100% - 24px, 940px); min-height: calc(100vh - 70px); padding: 22px 0 34px; }
    .joke-card { min-height: 58vh; padding: 24px; border-radius: 21px; }
    .joke-copy { margin: 38px 0; }
    .joke-copy h1 { font-size: clamp(1.85rem, 9vw, 3rem); }
    .player-controls { grid-template-columns: 1fr 1fr; }
    .control-primary { grid-column: 1 / -1; grid-row: 1; }
    .member-nudge { flex-direction: column; align-items: center; }
    .auth-shell { min-height: calc(100vh - 70px); grid-template-columns: 1fr; gap: 32px; padding: 45px 0; }
    .auth-intro h1 { font-size: 3.1rem; }
    .joke-grid, .admin-shell { grid-template-columns: 1fr; }
    .admin-form { position: static; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Playful comedy-club theme */
:root {
    color-scheme: light;
    --ink: #261940;
    --muted: #695d7d;
    --night: #fff3bd;
    --panel: #fffdf5;
    --panel-2: #f2eaff;
    --line: #261940;
    --yellow: #ffd83d;
    --cyan: #53ddd4;
    --pink: #ff6b9d;
    --purple: #8568ff;
    --danger: #c7325c;
    --shadow: 10px 12px 0 #261940;
    font-family: "Trebuchet MS", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

html { background: var(--night); }
body {
    color: var(--ink);
    background-color: var(--night);
    background-image:
        radial-gradient(circle, rgba(38, 25, 64, .13) 1.5px, transparent 1.7px),
        radial-gradient(circle at 12% 18%, rgba(83, 221, 212, .9) 0 5rem, transparent 5.1rem),
        radial-gradient(circle at 88% 76%, rgba(255, 107, 157, .78) 0 7rem, transparent 7.1rem),
        linear-gradient(135deg, #fff8d6, #ffedaa 58%, #ffe4af);
    background-size: 22px 22px, auto, auto, auto;
    background-attachment: fixed;
}

.site-header {
    border-bottom: 3px solid var(--ink);
}
.brand { font-size: 1.3rem; letter-spacing: -.045em; }
.brand-mark {
    width: 42px;
    height: 42px;
    color: var(--ink);
    background: var(--yellow);
    border: 3px solid var(--ink);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 4px 4px 0 var(--cyan);
    transform: rotate(-6deg);
    animation: logo-bob 3.5s ease-in-out infinite;
}
@keyframes logo-bob { 50% { transform: rotate(3deg) translateY(-2px); } }
.site-nav a, .nav-button { color: var(--ink); font-weight: 850; }
.site-nav a:hover, .site-nav a[aria-current="page"], .nav-button:hover { color: var(--ink); background: rgba(255,255,255,.62); }
.site-nav .nav-join {
    color: var(--ink);
    background: var(--pink);
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    transform: rotate(1deg);
}
.site-nav .nav-join:hover { background: #ff87b0; transform: rotate(-1deg) translateY(-1px); }

.joke-shell { width: min(980px, calc(100% - 40px)); padding: clamp(20px, 3vh, 36px) 0 42px; }
.joke-toolbar { margin-bottom: 18px; }
.field-inline select, .admin-form select {
    color: var(--ink);
    background-color: var(--panel);
    border: 2px solid var(--ink);
    border-radius: 999px;
    font-weight: 800;
    box-shadow: 3px 3px 0 var(--ink);
}
.show-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 13px;
    color: var(--ink);
    background: var(--cyan);
    border: 2px solid var(--ink);
    border-radius: 999px;
    font-size: .83rem;
    font-weight: 900;
    transform: rotate(1deg);
}
.show-status span { color: #168e75; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.switch { color: var(--ink); }

.joke-card {
    min-height: min(50vh, 500px);
    background: var(--panel);
    border: 4px solid var(--ink);
    border-radius: 28px 35px 25px 32px;
    box-shadow: 12px 14px 0 var(--purple), 18px 20px 0 var(--ink);
    transform: rotate(-.25deg);
    transition: transform .18s ease, box-shadow .18s ease;
}
.joke-card:hover { transform: rotate(.15deg) translateY(-2px); box-shadow: 14px 17px 0 var(--purple), 20px 23px 0 var(--ink); }
.joke-card::before {
    inset: 0;
    width: 100%;
    height: 13px;
    background: repeating-linear-gradient(90deg, var(--cyan) 0 45px, var(--yellow) 45px 90px, var(--pink) 90px 135px, var(--purple) 135px 180px);
    border-bottom: 3px solid var(--ink);
}
.joke-card::after { content: ""; }
.joke-card:focus-visible { box-shadow: 12px 14px 0 var(--purple), 18px 20px 0 var(--ink), 0 0 0 6px white; }
.comic-scribble { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.comic-scribble span { position: absolute; z-index: 0; color: rgba(133, 104, 255, .08); font-weight: 1000; letter-spacing: -.08em; }
.comic-scribble span:nth-child(1) { right: -1rem; bottom: 2rem; font-size: clamp(6rem, 16vw, 11rem); transform: rotate(-10deg); }
.comic-scribble span:nth-child(2) { left: 45%; top: 1.8rem; font-size: 3.5rem; color: rgba(255, 107, 157, .08); transform: rotate(9deg); }
.comic-scribble span:nth-child(3) { left: -1rem; bottom: 1rem; font: 900 2.5rem/1 ui-monospace, monospace; color: rgba(83, 221, 212, .12); transform: rotate(90deg); }
.card-topline { margin-top: 6px; }
.category-chip {
    min-height: 34px;
    padding: 6px 13px;
    color: var(--ink);
    background: var(--cyan);
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-weight: 900;
    transform: rotate(-1.5deg);
}
.icon-button {
    width: 50px;
    height: 50px;
    color: var(--ink);
    background: #fff;
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    font-weight: 900;
}
.icon-button:hover { background: #ffe3ed; transform: rotate(10deg) scale(1.08); }
.favorite-button.is-saved { color: var(--ink); border-color: var(--ink); background: var(--pink); }
.joke-kicker, .eyebrow { color: #6746e8; font-weight: 950; }
.joke-copy { margin: clamp(32px, 6vh, 58px) 0; }
.joke-copy h1 {
    max-width: 820px;
    font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
    font-weight: 950;
    line-height: 1.02;
    text-shadow: 2px 2px 0 rgba(255, 216, 61, .7);
}
.punchline {
    position: relative;
    max-width: 720px;
    margin-top: 30px;
    padding: 20px 24px;
    color: var(--ink);
    background: var(--yellow);
    border: 3px solid var(--ink);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 5px 5px 0 var(--ink);
    font-weight: 900;
    transform: rotate(.4deg);
    animation: punch-pop .35s cubic-bezier(.18, .89, .32, 1.4);
}
.punchline::after { content: ""; position: absolute; left: 20px; bottom: -15px; width: 22px; height: 22px; background: var(--yellow); border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: skewY(-35deg); }
@keyframes punch-pop { from { opacity: 0; transform: scale(.82) rotate(-2deg) translateY(15px); } }
.joke-card.is-revealed { box-shadow: 12px 14px 0 var(--pink), 18px 20px 0 var(--ink); }
.tap-hint { color: var(--muted); font-weight: 750; }
.tap-dot { background: var(--pink); box-shadow: 0 0 0 5px rgba(255,107,157,.18); }

.player-controls { gap: 15px; margin-top: 30px; }
.control-button, .submit-button {
    min-height: 54px;
    color: var(--ink);
    background: var(--panel);
    border: 3px solid var(--ink);
    border-radius: 15px;
    box-shadow: 4px 5px 0 var(--ink);
    font-weight: 950;
}
.control-button:hover, .submit-button:hover { transform: translateY(-3px) rotate(-.5deg); border-color: var(--ink); box-shadow: 5px 8px 0 var(--ink); }
.control-button:active, .submit-button:active { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.control-primary, .submit-button { color: var(--ink); background: var(--yellow); border-color: var(--ink); }
#previous-button { background: var(--cyan); }
#next-button { background: #ffa9c6; }
.member-nudge { color: var(--ink); font-weight: 700; }
.member-nudge a { color: #5a35dc; text-decoration-thickness: 2px; }

.auth-intro h1, .page-heading h1, .error-shell h1 { color: var(--ink); font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif; text-shadow: 4px 4px 0 var(--yellow); }
.auth-intro > p:last-child, .page-heading > p:last-child, .error-shell > p { color: var(--ink); }
.auth-card, .admin-form, .mini-joke, .empty-state, .admin-list-item {
    background: var(--panel);
    border: 3px solid var(--ink);
    box-shadow: 7px 8px 0 var(--ink);
}
.auth-card { transform: rotate(.5deg); }
.auth-card label, .admin-form label, .form-note, .auth-switch, .mini-joke button { color: var(--muted); }
.auth-card input, .admin-form textarea {
    color: var(--ink);
    background: white;
    border: 2px solid var(--ink);
}
.mini-joke:nth-child(3n+1) { box-shadow: 7px 8px 0 var(--pink); }
.mini-joke:nth-child(3n+2) { box-shadow: 7px 8px 0 var(--cyan); }
.mini-joke:nth-child(3n) { box-shadow: 7px 8px 0 var(--purple); }
.mini-joke p { color: #5a35dc; font-weight: 850; }
.mini-joke a, .auth-switch a, .empty-state a { color: #5a35dc; }
.toast { color: var(--ink); background: var(--cyan); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 5px 6px 0 var(--ink); }

@media (max-width: 720px) {
    .site-header { width: min(100% - 24px, 1180px); }
    .joke-shell { width: min(100% - 30px, 980px); padding-top: 20px; }
    .show-status { display: none; }
    .joke-card { min-height: 57vh; padding: 24px; border-width: 3px; box-shadow: 7px 8px 0 var(--purple), 11px 12px 0 var(--ink); }
    .joke-card:hover { transform: rotate(-.25deg); box-shadow: 7px 8px 0 var(--purple), 11px 12px 0 var(--ink); }
    .joke-copy h1 { font-size: clamp(2rem, 9.5vw, 3.1rem); }
    .joke-card.is-revealed { box-shadow: 7px 8px 0 var(--pink), 11px 12px 0 var(--ink); }
    .player-controls { margin-top: 23px; }
    .member-nudge { margin-top: 25px; }
}
