/* ==============================
   Base / Reset
============================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

:root {
    --bg: #0b1020;
    --text: #eef2ff;
    --muted: #a5b4fc;
    --card-bg: rgba(255, 255, 255, 0.04);
    --shadow: 0 12px 30px rgba(0, 0, 0, .25);
    --ring: #6366f1;
    --tooltip-bg: #111827;
    --tooltip-fg: #f9fafb;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*::selection {
    background: rgba(99, 102, 241, .35);
}

/* ==============================
   App Layout
============================== */
.app {
    /* real full-height across browsers */
    height: 100vh;
    height: 100dvh;
    height: 100svh;
    width: 100%;

    padding-top: max(16px, env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));

    display: flex;
    align-items: center;
    justify-content: center;
    overscroll-behavior: contain;
}

.card {
    width: min(760px, 92vw);
    min-height: 460px;
    /* nice presence on desktop */
    border-radius: 16px;
    padding: clamp(16px, 3vw, 32px);
    background: var(--card-bg);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .04);
    backdrop-filter: blur(8px);
    text-align: center;
    /* center title + subtitle + text */
    user-select: none;
    /* avoid accidental selections on tap */
}

/* Mobile: full-bleed card */
@media (max-width: 768px) {
    .app {
        padding: 0;
    }

    .card {
        width: 100vw;
        min-height: 100vh;
        min-height: 100dvh;
        min-height: 100svh;
        border-radius: 0;
        padding: 24px;

        display: flex;
        /* keep content from hugging the top */
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
    }
}

/* ==============================
   Typography
============================== */
.app-title {
    display: inline-flex;
    align-items: center;
    gap: 0rem;
    margin: 0 0 0 0;
    font-size: clamp(1.6rem, 2.4vw + 1rem, 2.4rem);
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: clamp(.95rem, 1.2vw + .4rem, 1.1rem);
}

.subtitle2 {
    margin: 0;
    color: var(--muted);
    font-size: clamp(.95rem, 1.2vw + .4rem, 1.1rem);
}


.phrase {
    font-size: clamp(1.2rem, 3.2vw + .5rem, 2.2rem);

    line-height: 1.35;
    box-sizing: content-box;
    padding-block: 0;
    min-height: calc(4 * 1lh + 1px);
    max-height: calc(4 * 1lh + 1px);

    /* 4-line clamp + ellipsis */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    text-overflow: ellipsis;

    /* prevent hyphenation / mid-word breaks */
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
    /* -webkit-hyphenate-character: ""; */
    word-break: normal;
    /* don’t split words */
    overflow-wrap: normal;
    /* don’t force breaks inside words */

    /* center */
    margin-inline: auto;
    max-width: min(92vw, var(--content-max));
    padding-inline: var(--gutter);
}



/* ==============================
   Buttons / Actions
============================== */
.actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 10px 0 14px;
}

button {
    font: inherit;
    color: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

button:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* Pill buttons */
.btn {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .14);
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 600;
    line-height: 1;
    min-width: 44px;
    /* thumb-friendly */
    min-height: 44px;
    transition: transform .06s ease, background .15s ease, border-color .15s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, .12);
}

.btn:active {
    transform: translateY(1px) scale(.99);
}

.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, .18);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, .06);
}

.btn-primary {
    background: #4f46e5;
    /* indigo-600 */
    border-color: #4f46e5;
    color: #fff;
}

.btn-primary:hover {
    background: #4338ca;
}

/* indigo-700 */

/* ==============================
   Tooltip (🔮 as trigger)
============================== */
.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tooltip__trigger {
    line-height: 1;
    font-size: 1.25em;
    /* scale emoji relative to title */
    display: grid;
    place-items: center;
    border-radius: 8px;
    padding: 0 .2rem;
    cursor: help;
    min-width: 44px;
    min-height: 44px;
}

.tooltip__content {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(4px);
    min-width: 220px;
    max-width: 320px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--tooltip-bg);
    color: var(--tooltip-fg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    font-size: .9rem;
    line-height: 1.25;
    pointer-events: none;

    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, transform .15s ease, visibility .15s linear;
    z-index: 1000;
}

.tooltip__content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--tooltip-bg);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 2px 2px 2px rgba(0, 0, 0, .04);
}

.tooltip:hover .tooltip__content,
.tooltip:focus-within .tooltip__content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Motion preference */
@media (prefers-reduced-motion: reduce) {
    .tooltip__content {
        transition: none;
    }
}

/* ==============================
   Utilities
============================== */
.center {
    text-align: center;
}

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

.hidden {
    display: none !important;
}

/* Packs row */
.packs,
#packs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 8px;
}

/* Chip button */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .06);
    color: inherit;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    transition: background .15s ease, border-color .15s ease, transform .06s ease;
}

.chip:hover {
    background: rgba(255, 255, 255, .10);
}

.chip:active {
    transform: translateY(1px) scale(.99);
}

.chip.active {
    background: #4f46e5;
    /* indigo-600 */
    border-color: #4f46e5;
    color: #fff;
}

/* Small count bubble */
.chip-count {
    font-size: .8em;
    opacity: .85;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .18);
}

.chip.active .chip-count {
    background: rgba(255, 255, 255, .22);
}

/* Empty state */
.packs-empty {
    opacity: .7;
    font-style: italic;
}

/* Prevent double-tap zoom & grey tap flash on iOS */
.card,
.actions,
.packs {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Keep text size stable on iOS */
html {
    -webkit-text-size-adjust: 100%;
}


.phrase {
    font-size: clamp(1.2rem, 3.2vw + .5rem, 2.2rem);

    line-height: 1.35;
    box-sizing: content-box;
    padding-block: 0;
    min-height: calc(4 * 1lh + 1px);
    max-height: calc(4 * 1lh + 1px);

    /* 4-line clamp + ellipsis */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    text-overflow: ellipsis;

    /* prevent hyphenation / mid-word breaks */
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
    /* -webkit-hyphenate-character: ""; */
    word-break: normal;
    /* don’t split words */
    overflow-wrap: normal;
    /* don’t force breaks inside words */

    /* center */
    margin-inline: auto;
    max-width: min(92vw, var(--content-max));
    padding-inline: var(--gutter);
}



/* --- Mobile layout polish: center vertically, prevent side cutoffs --- */
:root {
    --content-max: 680px;
    /* soft max width for text blocks */
    --gutter: 16px;
    /* side padding */
}

/* Ensure the app actually centers on small screens */
@media (max-width: 768px) {
    .app {
        height: 100vh;
        height: 100dvh;
        /* modern mobile viewport */
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        /* let the card fill edge-to-edge */
    }

    .card {
        width: 100vw;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        /* center content vertically inside the card */
        display: flex;
        flex-direction: column;
        justify-content: center;
        /* <- key change (was flex-start) */
        align-items: center;

        /* safe areas + side gutters so text never touches the edge */
        padding-top: max(24px, env(safe-area-inset-top));
        padding-right: max(var(--gutter), env(safe-area-inset-right));
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        padding-left: max(var(--gutter), env(safe-area-inset-left));
        gap: 10px;
        text-align: center;
        /* center title/subtitle/phrase */
    }

    /* Constrain line length + add side breathing room for all key blocks */
    .app-title,
    .subtitle,
    #packs,
    .actions,
    /*.phrase {
        max-width: min(92vw, var(--content-max));
        padding-inline: var(--gutter);
        margin-left: auto;
        margin-right: auto;
    }*/

    /* Phrase: wrap safely; never overflow horizontally */
    /*.phrase {
        max-width: min(92vw, var(--content-max));
        padding-inline: var(--gutter);
        hyphens: none;
        word-break: normal;
        overflow-wrap: normal;
    }*
}

/* Also helpful on all screens to avoid side cutoffs on narrow widths */
    .app-title,
    .subtitle,
    #packs,
    .actions,
    /*.phrase {
    max-width: min(92vw, var(--content-max));
    margin-left: auto;
    margin-right: auto;
}*/

    /* --- Desktop: prevent side truncation on the phrase --- */
    @media (min-width: 769px) {
        .card {
            overflow: visible;
        }


    }