/* =========================================================
   TRÆK ET NUMMER
   Main stylesheet
   ========================================================= */


/* =========================================================
   VARIABLES
   ========================================================= */

:root {
    --bg: #f5f7fb;
    --bg-secondary: #eef2f8;

    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --surface-hover: #f8faff;

    --text: #172033;
    --text-secondary: #5f6b80;
    --text-muted: #8993a5;

    --border: rgba(23, 32, 51, 0.09);
    --border-strong: rgba(23, 32, 51, 0.15);

    --accent: #6c5ce7;
    --accent-dark: #5546d4;
    --accent-light: #edeaff;

    --success: #27ae60;
    --danger: #e74c3c;

    --shadow-sm:
        0 4px 12px rgba(25, 35, 55, 0.06);

    --shadow:
        0 12px 35px rgba(25, 35, 55, 0.10);

    --shadow-lg:
        0 20px 60px rgba(25, 35, 55, 0.14);

    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;

    --transition-fast: 0.15s ease;
    --transition: 0.25s ease;
}


/* =========================================================
   DARK MODE
   ========================================================= */

@media (prefers-color-scheme: dark) {

    :root {
        --bg: #0c1020;
        --bg-secondary: #11172a;

        --surface: rgba(24, 30, 51, 0.88);
        --surface-solid: #181e33;
        --surface-hover: #202740;

        --text: #f3f5ff;
        --text-secondary: #aab2c7;
        --text-muted: #78839b;

        --border: rgba(255, 255, 255, 0.08);
        --border-strong: rgba(255, 255, 255, 0.14);

        --accent: #8173f2;
        --accent-dark: #6c5ce7;
        --accent-light: rgba(129, 115, 242, 0.15);

        --shadow-sm:
            0 4px 12px rgba(0, 0, 0, 0.20);

        --shadow:
            0 12px 35px rgba(0, 0, 0, 0.30);

        --shadow-lg:
            0 20px 60px rgba(0, 0, 0, 0.40);
    }
}


/* =========================================================
   RESET
   ========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    color: var(--text);

    background:
        radial-gradient(
            circle at 10% 10%,
            rgba(108, 92, 231, 0.08),
            transparent 35%
        ),
        radial-gradient(
            circle at 90% 20%,
            rgba(52, 152, 219, 0.07),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            var(--bg),
            var(--bg-secondary)
        );

    transition:
        background var(--transition),
        color var(--transition);
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(108, 92, 231, 0.35);
    outline-offset: 3px;
}

a {
    color: inherit;
    text-decoration: none;
}


/* =========================================================
   MAIN APP
   ========================================================= */

.app {
    width: 100%;
    max-width: 1100px;

    min-height: 100vh;

    margin: 0 auto;
    padding: 0 20px;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   HEADER / LOGO
   ========================================================= */

.site-header {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: flex-start;

    padding: 24px 0 12px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;

    gap: 10px;

    width: fit-content;

    color: var(--text);

    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.4px;

    transition:
        transform var(--transition-fast),
        opacity var(--transition-fast);
}

.logo:hover {
    transform: translateY(-1px);
    opacity: 0.85;
}

.logo-icon {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    width: 38px;
    height: 38px;

    border-radius: 11px;

    background: var(--accent-light);

    font-size: 21px;

    flex-shrink: 0;
}

.logo-text {
    white-space: nowrap;
}


/* =========================================================
   VIEWS
   ========================================================= */

.view {
    display: none;
    width: 100%;
}

.view.active {
    display: block;

    animation:
        view-in 0.35s ease both;
}

@keyframes view-in {

    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   HERO
   ========================================================= */

.hero {
    text-align: center;

    padding:
        clamp(38px, 8vw, 75px)
        10px
        clamp(35px, 7vw, 60px);
}

.hero-icon {
    font-size: clamp(50px, 9vw, 76px);

    margin-bottom: 18px;

    line-height: 1;

    filter:
        drop-shadow(
            0 8px 15px rgba(0, 0, 0, 0.10)
        );

    animation:
        hero-float 3.5s ease-in-out infinite;
}

@keyframes hero-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.hero h1 {
    max-width: 700px;

    margin: 0 auto 12px;

    font-size: clamp(30px, 6vw, 52px);
    line-height: 1.08;

    letter-spacing: -1.8px;

    font-weight: 850;
}

.hero p {
    max-width: 620px;

    margin: 0 auto;

    color: var(--text-secondary);

    font-size: clamp(16px, 2.5vw, 19px);
    line-height: 1.6;
}


/* =========================================================
   CATEGORY GRID
   ========================================================= */

.category-grid {
    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 13px;

    padding-bottom: 35px;
}

.category-card {
    min-height: 145px;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 10px;

    padding: 20px 14px;

    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow-sm);

    cursor: pointer;

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        background var(--transition),
        border-color var(--transition);
}

.category-card:hover {
    transform: translateY(-4px);

    background: var(--surface-hover);

    border-color: var(--border-strong);

    box-shadow: var(--shadow);
}

.category-card:active {
    transform: translateY(-1px) scale(0.98);
}

.category-icon {
    display: block;

    font-size: 37px;

    line-height: 1;
}

.category-title {
    text-align: center;

    font-size: 15px;
    font-weight: 750;

    line-height: 1.25;
}


/* =========================================================
   OPTIONS VIEW
   ========================================================= */

.options-view {
    padding-top: 12px;
}

.options-header {
    display: flex;
    align-items: center;

    gap: 12px;

    margin-bottom: 28px;
}

.back-button {
    width: 44px;
    height: 44px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 13px;

    box-shadow: var(--shadow-sm);

    cursor: pointer;

    font-size: 20px;

    transition:
        transform var(--transition-fast),
        background var(--transition-fast),
        box-shadow var(--transition-fast);
}

.back-button:hover {
    transform: translateX(-2px);

    background: var(--surface-hover);

    box-shadow: var(--shadow);
}

.back-button:active {
    transform: scale(0.95);
}

.options-title {
    display: flex;
    align-items: center;

    gap: 10px;

    min-width: 0;

    font-size: clamp(21px, 4vw, 30px);
    line-height: 1.2;

    letter-spacing: -0.7px;
}

.options-title-icon {
    flex-shrink: 0;
}

.options-title-text {
    overflow-wrap: anywhere;
}


/* =========================================================
   OPTIONS LIST
   ========================================================= */

#options-list {
    display: flex;
    flex-direction: column;

    gap: 11px;

    margin-bottom: 16px;
}

.option-row {
    display: flex;
    align-items: center;

    gap: 10px;

    width: 100%;
}

.option-input {
    width: 100%;
    min-width: 0;

    height: 52px;

    padding: 0 16px;

    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 14px;

    box-shadow: var(--shadow-sm);

    outline: none;

    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.option-input::placeholder {
    color: var(--text-muted);
}

.option-input:hover {
    border-color: var(--border-strong);
}

.option-input:focus {
    background: var(--surface-solid);

    border-color: var(--accent);

    box-shadow:
        0 0 0 4px rgba(108, 92, 231, 0.10);
}

.remove-option {
    width: 44px;
    height: 44px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    color: var(--text-muted);

    background: transparent;

    border-radius: 12px;

    cursor: pointer;

    font-size: 19px;

    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        transform var(--transition-fast);
}

.remove-option:hover {
    color: var(--danger);

    background: rgba(231, 76, 60, 0.10);

    transform: scale(1.05);
}

.remove-option:active {
    transform: scale(0.95);
}


/* =========================================================
   ADD OPTION
   ========================================================= */

.add-option {
    width: 100%;

    min-height: 50px;

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 8px;

    margin-bottom: 26px;

    padding: 12px 16px;

    color: var(--accent);

    background: var(--accent-light);

    border: 1px dashed rgba(108, 92, 231, 0.35);

    border-radius: 14px;

    cursor: pointer;

    font-size: 15px;
    font-weight: 750;

    transition:
        background var(--transition-fast),
        border-color var(--transition-fast),
        transform var(--transition-fast);
}

.add-option:hover {
    background: rgba(108, 92, 231, 0.14);

    border-color: rgba(108, 92, 231, 0.55);

    transform: translateY(-1px);
}

.add-option:active {
    transform: scale(0.99);
}


/* =========================================================
   DRAW BUTTON
   ========================================================= */

.draw-button {
    position: relative;

    overflow: hidden;

    width: 100%;

    min-height: 70px;

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 12px;

    margin: 4px 0 40px;

    padding: 15px 24px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            var(--accent),
            #8c5de8
        );

    border-radius: 18px;

    box-shadow:
        0 12px 30px rgba(108, 92, 231, 0.28);

    cursor: pointer;

    font-size: clamp(18px, 3vw, 21px);
    font-weight: 850;

    letter-spacing: 0.3px;

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        filter var(--transition);
}

.draw-button::before {
    content: "";

    position: absolute;

    top: 0;
    left: -100%;

    width: 70%;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.22),
            transparent
        );

    transform: skewX(-20deg);

    animation:
        button-shine 3.5s ease-in-out infinite;
}

@keyframes button-shine {

    0%,
    55% {
        left: -100%;
    }

    75%,
    100% {
        left: 150%;
    }
}

.draw-button:hover {
    transform: translateY(-3px);

    box-shadow:
        0 17px 38px rgba(108, 92, 231, 0.34);

    filter: brightness(1.04);
}

.draw-button:active {
    transform: translateY(0) scale(0.985);

    box-shadow:
        0 8px 20px rgba(108, 92, 231, 0.24);
}

.draw-button:disabled {
    opacity: 0.55;

    cursor: not-allowed;

    transform: none;

    box-shadow:
        0 6px 15px rgba(108, 92, 231, 0.15);
}

.draw-button:disabled::before {
    display: none;
}


/* =========================================================
   RESULT VIEW
   ========================================================= */

.result-view {
    min-height: 0;

    padding:
        clamp(45px, 9vw, 90px)
        10px
        40px;

    text-align: center;
}

.result-subtitle {
    margin-bottom: 8px;

    color: var(--text-secondary);

    font-size: clamp(16px, 3vw, 19px);
    font-weight: 650;
}

.result-heading {
    margin-bottom: 35px;

    font-size: clamp(28px, 6vw, 46px);

    line-height: 1.1;

    letter-spacing: -1.4px;
}


/* =========================================================
   ROLLING NUMBER
   ========================================================= */

#rolling-number {
    min-height: 90px;

    margin-bottom: 25px;

    display: flex;

    align-items: center;
    justify-content: center;

    color: var(--accent);

    font-size: clamp(65px, 15vw, 110px);
    font-weight: 900;

    line-height: 1;

    font-variant-numeric: tabular-nums;

    text-shadow:
        0 8px 25px rgba(108, 92, 231, 0.16);

    transition:
        transform 0.18s ease;
}

#rolling-number.rolling {
    animation:
        number-pulse 0.18s ease-in-out infinite alternate;
}

@keyframes number-pulse {

    from {
        transform: scale(0.96);
        opacity: 0.75;
    }

    to {
        transform: scale(1.04);
        opacity: 1;
    }
}


/* =========================================================
   RESULT
   ========================================================= */

.result {
    position: relative;

    margin: 0 auto 35px;

    max-width: 700px;

    padding: 28px 24px;

    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-lg);

    font-size: clamp(25px, 6vw, 42px);
    font-weight: 900;

    line-height: 1.15;

    letter-spacing: -1px;

    overflow-wrap: anywhere;

    transform-origin: center center;
}

.result-reveal {
    animation:
        result-reveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes result-reveal {

    0% {
        opacity: 0;

        transform:
            scale(0.70)
            translateY(15px);

        filter: blur(8px);
    }

    55% {
        opacity: 1;

        transform:
            scale(1.08)
            translateY(-4px);

        filter: blur(0);
    }

    75% {
        transform:
            scale(0.96)
            translateY(1px);
    }

    90% {
        transform:
            scale(1.025)
            translateY(-1px);
    }

    100% {
        opacity: 1;

        transform:
            scale(1)
            translateY(0);
    }
}


/* =========================================================
   WINNER CELEBRATION
   ========================================================= */

/*
   The celebration container is created dynamically
   by JavaScript when a winner is revealed.
*/

.winner-celebration {
    position: fixed;

    inset: 0;

    z-index: 1000;

    pointer-events: none;

    overflow: hidden;
}


/* ---------------------------------------------------------
   Confetti pieces
   --------------------------------------------------------- */

.confetti {
    position: absolute;

    top: var(--origin-y);
    left: var(--origin-x);

    width: 10px;
    height: 16px;

    opacity: 0;

    border-radius: 2px;

    animation:
        confetti-explode 1.35s cubic-bezier(0.12, 0.7, 0.2, 1) forwards;
}


/*
   Individual pieces receive their direction and rotation
   through CSS variables set by JavaScript.
*/

@keyframes confetti-explode {

    0% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(0.2)
            rotate(0deg);
    }

    8% {
        opacity: 1;
    }

    45% {
        opacity: 1;
    }

    100% {
        opacity: 0;

        transform:
            translate(
                calc(-50% + var(--x)),
                calc(-50% + var(--y))
            )
            rotate(var(--rotation))
            scale(var(--scale));
    }
}


/* ---------------------------------------------------------
   Celebration stars
   --------------------------------------------------------- */

.celebration-star {
    position: absolute;

    top: var(--origin-y);
    left: var(--origin-x);

    width: 14px;
    height: 14px;

    opacity: 0;

    color: var(--accent);

    font-size: 22px;

    line-height: 1;

    animation:
        star-burst 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes star-burst {

    0% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(0)
            rotate(0deg);
    }

    20% {
        opacity: 1;
    }

    60% {
        opacity: 1;
    }

    100% {
        opacity: 0;

        transform:
            translate(
                calc(-50% + var(--x)),
                calc(-50% + var(--y))
            )
            scale(1.3)
            rotate(180deg);
    }
}


/* ---------------------------------------------------------
   Celebration ring
   --------------------------------------------------------- */

.celebration-ring {
    position: absolute;

    top: var(--origin-y);
    left: var(--origin-x);

    width: 50px;
    height: 50px;

    border: 3px solid var(--accent);

    border-radius: 50%;

    opacity: 0;

    animation:
        celebration-ring 0.8s ease-out forwards;
}

@keyframes celebration-ring {

    0% {
        opacity: 0.75;

        transform:
            translate(-50%, -50%)
            scale(0.2);
    }

    100% {
        opacity: 0;

        transform:
            translate(-50%, -50%)
            scale(5);
    }
}


/* =========================================================
   RESULT ACTIONS
   ========================================================= */

.result-actions {
    width: 100%;
    max-width: 600px;

    margin: 0 auto;

    display: flex;
    flex-direction: column;

    gap: 11px;
}

.result-actions button {
    min-height: 52px;

    padding: 12px 20px;

    border-radius: 14px;

    cursor: pointer;

    font-weight: 750;

    transition:
        transform var(--transition-fast),
        background var(--transition-fast),
        box-shadow var(--transition-fast),
        opacity var(--transition-fast);
}


/* ---------------------------------------------------------
   Draw again / Best of three
   --------------------------------------------------------- */

.draw-again-button {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            var(--accent),
            #8c5de8
        );

    box-shadow:
        0 8px 22px rgba(108, 92, 231, 0.22);
}

.draw-again-button:hover {
    transform: translateY(-2px);

    box-shadow:
        0 12px 28px rgba(108, 92, 231, 0.30);
}

.draw-again-button:active {
    transform: scale(0.985);
}

.draw-again-button:disabled {
    opacity: 0.55;

    cursor: not-allowed;

    transform: none;
}


/* ---------------------------------------------------------
   Share result
   --------------------------------------------------------- */

.share-result-button {
    color: var(--accent);

    background: var(--accent-light);

    border: 1px solid rgba(108, 92, 231, 0.18);

    box-shadow: var(--shadow-sm);
}

.share-result-button:hover {
    transform: translateY(-2px);

    background: rgba(108, 92, 231, 0.14);

    border-color: rgba(108, 92, 231, 0.30);

    box-shadow: var(--shadow);
}

.share-result-button:active {
    transform: scale(0.985);
}

.share-result-button:disabled {
    opacity: 0.45;

    cursor: not-allowed;

    transform: none;

    box-shadow: var(--shadow-sm);
}


/* ---------------------------------------------------------
   Edit options
   --------------------------------------------------------- */

.edit-options-button {
    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);

    box-shadow: var(--shadow-sm);
}

.edit-options-button:hover {
    transform: translateY(-2px);

    background: var(--surface-hover);

    box-shadow: var(--shadow);
}

.edit-options-button:active {
    transform: scale(0.985);
}

.edit-options-button:disabled {
    opacity: 0.55;

    cursor: not-allowed;

    transform: none;
}


/* ---------------------------------------------------------
   New decision
   --------------------------------------------------------- */

.new-decision-button {
    color: var(--text-secondary);

    background: transparent;
}

.new-decision-button:hover {
    color: var(--text);

    background: var(--surface);
}

.new-decision-button:disabled {
    opacity: 0.55;

    cursor: not-allowed;
}


/* =========================================================
   TEMPORARY MESSAGES
   ========================================================= */

.temporary-message {
    width: 100%;

    margin: 0 0 16px;

    padding: 12px 16px;

    color: var(--danger);

    background: rgba(231, 76, 60, 0.09);

    border: 1px solid rgba(231, 76, 60, 0.18);

    border-radius: 12px;

    text-align: center;

    font-size: 14px;
    font-weight: 650;

    animation:
        message-in 0.25s ease both;
}

@keyframes message-in {

    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   FOOTER
   ========================================================= */

.site-footer {
    width: 100%;

    margin-top: auto;

    padding: 34px 0 22px;

    text-align: center;

    color: var(--text-muted);

    font-size: 12px;

    line-height: 1.5;
}

.site-footer p {
    margin: 0;
}

.site-footer strong {
    color: var(--text-secondary);

    font-weight: 700;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (min-width: 600px) {

    .app {
        padding: 0 28px;
    }

    .site-header {
        padding-top: 28px;
    }

    .category-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 16px;
    }

    .category-card {
        min-height: 155px;
    }

    .result-actions {
        flex-direction: row;
        flex-wrap: wrap;

        justify-content: center;
    }

    .result-actions button {
        flex: 1 1 180px;
    }

    .new-decision-button {
        flex-basis: 100%;
    }
}


/* =========================================================
   DESKTOP
   ========================================================= */

@media (min-width: 850px) {

    .app {
        padding: 0 35px;
    }

    .site-header {
        padding-top: 30px;
        padding-bottom: 10px;
    }

    .hero {
        padding-top: 70px;
    }

    .category-grid {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));

        gap: 17px;

        padding-bottom: 45px;
    }

    .category-card {
        min-height: 175px;
    }

    .category-icon {
        font-size: 43px;
    }

    .category-title {
        font-size: 16px;
    }

    .options-view {
        max-width: 760px;

        margin: 0 auto;
    }

    .result-view {
        max-width: 800px;

        margin: 0 auto;
    }

    .result-actions {
        max-width: 700px;
    }
}


/* =========================================================
   LARGE DESKTOP
   ========================================================= */

@media (min-width: 1100px) {

    .app {
        padding-left: 0;
        padding-right: 0;
    }

    .hero {
        padding-top: 80px;
    }

    .category-card {
        min-height: 185px;
    }
}


/* =========================================================
   SMALL PHONES
   ========================================================= */

@media (max-width: 380px) {

    .app {
        padding-left: 14px;
        padding-right: 14px;
    }

    .site-header {
        padding-top: 18px;
    }

    .logo {
        font-size: 17px;
    }

    .logo-icon {
        width: 34px;
        height: 34px;

        font-size: 19px;
    }

    .hero {
        padding-top: 35px;
    }

    .hero h1 {
        font-size: 28px;
    }

    .category-grid {
        gap: 9px;
    }

    .category-card {
        min-height: 130px;

        padding:
            15px
            10px;
    }

    .category-icon {
        font-size: 31px;
    }

    .category-title {
        font-size: 13px;
    }

    .options-title {
        font-size: 20px;
    }

    .option-input {
        height: 49px;

        padding-left: 13px;
        padding-right: 13px;
    }

    .draw-button {
        min-height: 64px;

        font-size: 17px;
    }

    .result {
        padding:
            24px 18px;

        font-size: 27px;
    }
}


/* =========================================================
   TOUCH DEVICES
   ========================================================= */

@media (hover: none) {

    .category-card:hover,
    .draw-button:hover,
    .add-option:hover,
    .back-button:hover,
    .result-actions button:hover {
        transform: none;
    }

    .category-card:active {
        transform: scale(0.98);
    }

    .draw-button:active {
        transform: scale(0.985);
    }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.best-of-three-note {
    margin: 14px 0 0;
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

.best-of-three-note[hidden] {
    display: none;
}

/* Side 2 tools reuse the existing category cards and form controls. */
.side2-view { max-width: 1000px; margin: 0 auto; padding-top: 36px; }
.side2-heading { text-align: center; margin: 0 auto 28px; }
.side2-heading h1 { margin: 14px 0 8px; font-size: clamp(30px, 6vw, 46px); letter-spacing: -1.2px; }
.side2-heading p:not(.side2-kicker) { color: var(--text-secondary); }
.side2-kicker { color: var(--accent); font-weight: 800; }
.side2-back { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 13px; cursor: pointer; font-weight: 700; }
.side2-back:hover { color: var(--accent); background: var(--surface-hover); }
.side2-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; padding-bottom: 38px; }
.side2-card { min-height: 160px; gap: 8px; }
.side2-card .category-icon { font-size: 35px; }
.side3-view .side2-heading .back-button { margin: 0 auto 14px 0; }
.side3-view .side2-heading .tool-hint { margin-top: 12px; }
.tool-description { color: var(--text-secondary); font-size: 13px; font-weight: 500; line-height: 1.4; }
.tool-panel { width: 100%; max-width: 680px; margin: 0 auto 38px; padding: clamp(18px, 5vw, 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.tool-view { width: 100%; max-width: 760px; margin: 0 auto; padding-top: clamp(20px, 6vw, 55px); }
.tool-panel h2 { margin: 0; font-size: clamp(23px, 5vw, 32px); }
.tool-panel h3 { margin: 10px 0; }
.tool-label { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; font-weight: 700; }
.tool-inputs { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.tool-add { margin: 0 0 14px; }
.tool-hint { color: var(--text-secondary); line-height: 1.5; }
.tool-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tool-columns .tool-inputs { min-width: 0; }
.tool-check { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.tool-action { min-height: 54px; margin: 12px 0 0; }
.tool-reset { margin-top: 10px; width: 100%; }
.tool-result { white-space: pre-line; text-align: center; color: var(--accent); font-size: clamp(24px, 6vw, 38px); font-weight: 850; line-height: 1.45; margin-top: 20px; overflow-wrap: anywhere; }
.tool-result-reveal { animation: result-reveal .65s cubic-bezier(.16,1,.3,1) both; }
.tool-action:disabled { opacity: .65; cursor: wait; }
.side2-best-of-three { display: inline-flex; width: auto; min-width: 190px; min-height: 52px; align-items: center; justify-content: center; margin: 12px auto 0 0; padding: 12px 20px; border-radius: 14px; cursor: pointer; font-weight: 750; }
.side2-best-of-three[hidden] { display: none; }
.side2-best-of-three:disabled { opacity: .6; cursor: wait; }
.tool-rolling-number { min-height: 90px; margin: 20px 0; display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: clamp(65px, 15vw, 110px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 8px 25px rgba(108, 92, 231, .16); transition: transform .18s ease; scroll-margin-top: 18px; }
.tool-rolling-number[hidden] { display: none; }
.tool-rolling-number.rolling { animation: number-pulse .18s ease-in-out infinite alternate; }
.adult-gate { max-width: 680px; margin: auto; padding-top: 50px; }
.adult-gate p { margin: 14px 0; color: var(--text-secondary); line-height: 1.5; }
.adult-gate .draw-button { margin-bottom: 12px; }
.adult-gate .side2-back { width: 100%; }
.view:not(.active) { display: none; }

@media (min-width: 750px) { .side2-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (max-width: 430px) { .side2-view { padding-top: 18px; } .side2-tools { gap: 9px; } .side2-card { min-height: 145px; padding: 13px 10px; } .side2-card .category-icon { font-size: 29px; } .side2-card .category-title { font-size: 14px; } .tool-columns { grid-template-columns: 1fr; gap: 0; } }
.tool-input-row { display: flex; align-items: center; gap: 8px; }
.tool-input-row .option-input { flex: 1; }
.tool-input-row .remove-option { height: 44px; }

/* Keep Side 2 and Side 3 comfortable on narrow phones and tablets. */
.side2-view,
.tool-view,
.adult-gate,
.tool-panel,
.tool-columns > * {
    min-width: 0;
}

.side2-card {
    overflow-wrap: anywhere;
}

.tool-input-row {
    width: 100%;
    min-width: 0;
}

.tool-input-row .option-input {
    width: 0;
    min-width: 0;
    flex: 1 1 0;
}

@media (min-width: 750px) and (max-width: 849px) {
    .side2-tools {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .tool-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .tool-columns > div,
    .tool-columns > label {
        width: 100%;
    }
}

@media (max-width: 599px) {
    .side2-view,
    .adult-gate {
        padding-top: 20px;
    }

    .tool-view {
        padding-top: 16px;
    }

    .tool-panel {
        padding: 16px;
        border-radius: 20px;
    }

    .side2-heading {
        margin-bottom: 22px;
    }

    .side2-heading h1 {
        font-size: clamp(27px, 7vw, 36px);
        overflow-wrap: anywhere;
    }

    .side2-tools {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .side2-card {
        min-height: 142px;
        padding: 14px 10px;
    }

    .tool-description {
        font-size: 12px;
    }

    .tool-result {
        font-size: clamp(21px, 7vw, 32px);
    }

    .tool-rolling-number {
        min-height: 72px;
        font-size: clamp(58px, 18vw, 90px);
    }

    .side2-best-of-three {
        min-width: min(190px, 100%);
    }
}
