:root {
    --bg-top: #ffd67c;
    --bg-mid: #ff9f6c;
    --bg-bottom: #ff5f5f;
    --ink: #291f31;
    --ink-soft: #533b52;
    --paper: rgba(255, 247, 232, 0.9);
    --paper-strong: #fff9ee;
    --brand-a: #ff7a18;
    --brand-b: #ffbc42;
    --brand-c: #2f89fc;
    --accent: #0e8573;
    --danger: #cc2f52;
    --shadow: 0 18px 45px rgba(35, 12, 26, 0.2);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
    color: var(--ink);
    background: linear-gradient(165deg, var(--bg-top) 0%, var(--bg-mid) 42%, var(--bg-bottom) 100%);
    overflow-x: hidden;
}

h1,
h2,
h3,
button {
    font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
}

.backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 999px;
    filter: blur(4px);
    opacity: 0.55;
    animation: floatBlob 13s ease-in-out infinite;
}

.blob-a {
    width: 360px;
    height: 360px;
    left: -100px;
    top: -80px;
    background: radial-gradient(circle at 20% 20%, #fff9d6, #ffc54d 65%);
}

.blob-b {
    width: 290px;
    height: 290px;
    right: -70px;
    top: 18%;
    background: radial-gradient(circle at 70% 15%, #fff3db, #ff8842 70%);
    animation-duration: 16s;
}

.blob-c {
    width: 420px;
    height: 420px;
    left: 35%;
    bottom: -220px;
    background: radial-gradient(circle at 35% 35%, #ffd5ad, #fe7050 75%);
    animation-duration: 19s;
}

.app-shell,
.admin-shell {
    position: relative;
    width: min(1060px, calc(100vw - 32px));
    margin: 20px auto 30px;
    z-index: 2;
}

.screen {
    display: none;
}

.screen.is-active {
    display: block;
}

.card {
    background: linear-gradient(160deg, var(--paper) 0%, rgba(255, 242, 226, 0.98) 100%);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    padding: 26px 28px;
}

.eyebrow {
    margin: 0;
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 999px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    background: #2b2548;
    color: #fff;
}

.lead {
    margin: 8px 0 20px;
    font-weight: 500;
    color: var(--ink-soft);
}

.intro-card {
    text-align: center;
}

.intro-card h1 {
    margin: 10px 0 6px;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1;
}

.name-label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
}

.name-input {
    width: min(430px, 100%);
    border: 2px solid rgba(67, 48, 84, 0.18);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    font-weight: 600;
    background: #fffdf8;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.name-input:focus {
    outline: none;
    border-color: var(--brand-a);
    box-shadow: 0 0 0 4px rgba(255, 122, 24, 0.17);
}

.photo-label {
    display: block;
    margin: 14px 0 7px;
    font-weight: 700;
}

.photo-upload-control {
    width: min(430px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px dashed rgba(67, 48, 84, 0.22);
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.84);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.photo-upload-control:focus-within {
    border-color: var(--brand-a);
    box-shadow: 0 0 0 4px rgba(255, 122, 24, 0.17);
}

.photo-picker-btn {
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 1rem;
    font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #2f89fc, #0f67d8);
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease;
}

.photo-picker-btn:hover {
    filter: brightness(1.06);
}

.photo-picker-btn:focus-visible {
    outline: 2px solid rgba(18, 95, 210, 0.45);
    outline-offset: 2px;
}

.photo-file-name {
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-file-name.is-empty {
    opacity: 0.82;
}

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

.photo-note {
    margin: 7px 0 0;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.yes-no-question {
    margin: 18px 0 10px;
    font-size: clamp(1.4rem, 2.8vw, 2rem);
    font-weight: 800;
}

.yes-no-arena {
    position: relative;
    width: min(700px, 100%);
    height: 200px;
    margin: 0 auto;
    border-radius: 18px;
    border: 2px dashed rgba(83, 59, 82, 0.25);
    background: linear-gradient(160deg, rgba(255, 214, 124, 0.22), rgba(255, 255, 255, 0.26));
    overflow: hidden;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    border-radius: 999px;
    text-decoration: none;
    transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn:hover {
    filter: brightness(1.05);
}

.btn-yes {
    --yes-scale: 1;
    position: absolute;
    left: calc(50% - 16px);
    top: 50%;
    transform: translate(-100%, -50%) scale(var(--yes-scale));
    transform-origin: right center;
    min-width: 210px;
    padding: 14px 28px;
    font-size: 1.1rem;
    color: #fff;
    background: linear-gradient(135deg, #18a572, #0d6e6a);
    box-shadow: 0 10px 30px rgba(15, 120, 105, 0.35);
    z-index: 1;
}

.btn-no {
    position: absolute;
    left: calc(50% + 16px);
    top: 50%;
    right: auto;
    transform: translateY(-50%);
    min-width: 90px;
    padding: 10px 16px;
    color: #fff;
    background: linear-gradient(135deg, #d53767, #8f2053);
    box-shadow: 0 9px 18px rgba(117, 21, 63, 0.34);
    z-index: 2;
}

.yes-no-arena.is-chaos .btn-yes {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(var(--yes-scale));
    transform-origin: center;
}

.yes-no-arena.is-chaos .btn-no {
    right: auto;
}

.btn-no.is-ghost {
    opacity: 0.5;
    pointer-events: none;
}

.yes-no-arena.yes-takeover .btn-yes {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    transform: none;
    font-size: clamp(1.4rem, 3.7vw, 2.4rem);
    font-weight: 800;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
    z-index: 3;
}

.yes-no-arena.yes-takeover .btn-no {
    opacity: 0.25;
}

.hint {
    margin: 14px 0 0;
    color: var(--ink-soft);
}

.quiz-card,
.result-card {
    max-width: 900px;
    margin: 0 auto;
}

.quiz-head {
    margin-bottom: 18px;
}

.progress-label {
    margin: 0 0 8px;
    font-weight: 700;
    color: var(--ink-soft);
}

.progress-track,
.power-track,
.ranking-track {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: rgba(73, 54, 96, 0.13);
    overflow: hidden;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(95deg, #fd6e2a, #ffc13d);
    transition: width 0.35s ease;
}

.question-text {
    margin: 0;
    font-size: clamp(1.3rem, 3vw, 2rem);
    line-height: 1.25;
}

.selection-count {
    margin: 10px 0 18px;
    font-weight: 700;
    color: #6f4d60;
    transition: color 0.2s ease;
}

.selection-count.is-ready {
    color: #0a836f;
}

.options-grid {
    display: grid;
    gap: 11px;
}

.options-grid.is-image-grid {
    grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
    gap: 12px;
}

.options-grid.is-donut-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.option-btn {
    width: 100%;
    text-align: left;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-radius: 16px;
    border: 2px solid rgba(56, 34, 72, 0.14);
    padding: 12px 14px;
    font: inherit;
    background: #fffefb;
    cursor: pointer;
    animation: fadeSlide 0.4s ease both;
}

.option-btn:hover {
    border-color: rgba(255, 122, 24, 0.55);
    transform: translateX(1px);
}

.option-btn.is-selected {
    border-color: rgba(18, 128, 108, 0.9);
    box-shadow: 0 10px 20px rgba(13, 115, 102, 0.15);
    background: linear-gradient(160deg, #edfff9, #f4fffd);
}

.option-btn-image {
    padding: 8px;
    gap: 8px;
    align-items: stretch;
    flex-direction: column;
}

.option-letter {
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #2f89fc, #6f5bff);
}

.option-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(56, 34, 72, 0.2);
}

.option-caption {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.quiz-footer {
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.btn-first {
    padding: 12px 22px;
    color: #2a2150;
    background: linear-gradient(135deg, #ffe7b4, #ffd37e);
    box-shadow: 0 11px 26px rgba(174, 105, 10, 0.23);
}

.btn-next,
.btn-restart,
.btn-ranking,
.btn-download {
    padding: 12px 22px;
    color: #fff;
    background: linear-gradient(135deg, #ff7a18, #ff9f1c);
    box-shadow: 0 11px 26px rgba(225, 107, 19, 0.27);
}

.result-card h2 {
    margin: 10px 0 8px;
    font-size: clamp(1.6rem, 3.3vw, 2.4rem);
    line-height: 1.15;
}

.result-tagline {
    margin: 4px 0 16px;
    font-weight: 700;
    color: #6f4d60;
}

.result-intro,
.result-value {
    margin: 0 0 14px;
    line-height: 1.5;
}

.result-bullets {
    margin: 0 0 14px;
    padding-left: 20px;
    display: grid;
    gap: 6px;
}

.power-wrap {
    margin-bottom: 18px;
}

.photo-result-panel {
    margin: 14px 0 18px;
    border: 2px solid rgba(16, 111, 96, 0.2);
    border-radius: 16px;
    padding: 14px;
    background: linear-gradient(160deg, rgba(237, 255, 251, 0.86), rgba(255, 255, 255, 0.72));
}

.photo-result-title {
    margin: 0;
    font-size: 1.15rem;
}

.photo-result-status {
    margin: 8px 0 0;
    font-weight: 600;
    color: #275a52;
}

.photo-result-image {
    display: block;
    width: min(460px, 100%);
    margin: 12px auto 0;
    border-radius: 14px;
    border: 2px solid rgba(16, 111, 96, 0.3);
    box-shadow: 0 12px 26px rgba(22, 77, 67, 0.16);
}

.photo-result-download {
    display: flex;
    margin: 12px auto 0;
}

#power-label {
    display: inline-block;
    margin-bottom: 7px;
    font-weight: 700;
}

.power-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0fa36f, #4ecdc4);
    transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.ranking-panel {
    margin-top: 12px;
    border: 2px solid rgba(56, 34, 72, 0.12);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.6);
}

.ranking-panel h3,
.admin-ranking h2 {
    margin-top: 0;
}

.ranking-list {
    display: grid;
    gap: 10px;
}

.ranking-row {
    border-radius: 12px;
    padding: 10px;
    border: 1px solid rgba(56, 34, 72, 0.16);
    background: rgba(255, 255, 255, 0.77);
}

.ranking-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.ranking-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(95deg, #2f89fc, #40c9ff);
    transition: width 0.45s ease;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%) translateY(10px);
    background: rgba(27, 22, 39, 0.92);
    color: #fff;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 100;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.confetti-piece {
    position: fixed;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 300;
}

.admin-body {
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-logout-form {
    margin: 0;
}

.admin-login-shell {
    max-width: 620px;
}

.admin-login-card {
    margin: 80px auto 0;
}

.admin-login-card h1 {
    margin: 10px 0 8px;
}

.admin-login-form {
    display: grid;
    gap: 10px;
}

.admin-login-form label {
    font-weight: 700;
}

.admin-password-input {
    border: 2px solid rgba(67, 48, 84, 0.18);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    font-weight: 600;
    background: #fffdf8;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.admin-password-input:focus {
    outline: none;
    border-color: var(--brand-a);
    box-shadow: 0 0 0 4px rgba(255, 122, 24, 0.17);
}

.admin-login-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-prompt {
    margin-top: 12px;
}

.admin-prompt-form {
    display: grid;
    gap: 10px;
}

.admin-prompt-form label {
    font-weight: 700;
}

.admin-prompt-input {
    width: 100%;
    border: 2px solid rgba(67, 48, 84, 0.18);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    line-height: 1.45;
    background: #fffdf8;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical;
}

.admin-prompt-input:focus {
    outline: none;
    border-color: var(--brand-a);
    box-shadow: 0 0 0 4px rgba(255, 122, 24, 0.17);
}

.admin-prompt-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.hint.is-success {
    color: #0b7f66;
    font-weight: 700;
}

.hint.is-error {
    color: #9d1f45;
    font-weight: 700;
}

.admin-gallery {
    margin-top: 12px;
}

.gallery-stage {
    position: relative;
    border-radius: 16px;
    border: 2px solid rgba(56, 34, 72, 0.13);
    background: rgba(255, 255, 255, 0.62);
    padding: 14px;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image {
    display: block;
    width: min(760px, 100%);
    max-height: 58vh;
    object-fit: contain;
    border-radius: 14px;
    border: 2px solid rgba(16, 111, 96, 0.24);
    box-shadow: 0 12px 26px rgba(22, 77, 67, 0.18);
}

.gallery-thumbs {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}

.gallery-thumb {
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.gallery-thumb:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 122, 24, 0.5);
}

.gallery-thumb.is-active {
    border-color: rgba(15, 130, 109, 0.95);
    box-shadow: 0 6px 14px rgba(15, 130, 109, 0.2);
}

.gallery-thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.admin-error {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(204, 47, 82, 0.14);
    border: 1px solid rgba(204, 47, 82, 0.28);
    color: #7e1230;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 10px 0;
}

.stat-box {
    text-align: center;
}

.stat-box p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 700;
}

.stat-box strong {
    display: block;
    margin-top: 6px;
    font-size: 2rem;
    line-height: 1;
}

.admin-ranking {
    margin-top: 6px;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatBlob {
    0%,
    100% {
        transform: translateY(0px) translateX(0px);
    }
    50% {
        transform: translateY(18px) translateX(-14px);
    }
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell,
    .admin-shell {
        width: calc(100vw - 20px);
        margin: 10px auto 18px;
    }

    .card {
        padding: 18px;
    }

    .yes-no-arena {
        height: 220px;
    }

    .btn-yes {
        min-width: 180px;
        padding: 12px 18px;
        font-size: 1rem;
    }

    .btn-no {
        min-width: 74px;
        padding: 8px 10px;
    }

    .question-text {
        font-size: 1.15rem;
    }

    .option-btn {
        font-size: 0.95rem;
    }

    .options-grid.is-donut-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 9px;
    }

    .photo-upload-control {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .photo-picker-btn {
        width: 100%;
    }

    .photo-file-name {
        text-align: center;
    }

    .result-actions {
        flex-direction: column;
    }

    .quiz-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .quiz-footer .btn {
        width: 100%;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }
}
