@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f2ece3;
    --bg-card: #fffcf7;
    --bg-cell: #f7f3ec;
    --border: #e0d8cc;
    --border-light: #ebe5db;
    --text: #1e1e1e;
    --text-muted: #7a7368;
    --accent: #2d6a4f;
    --accent-light: #40916c;
    --accent-bg: rgba(45, 106, 79, 0.08);
    --accent2: #e76f51;
    --accent2-bg: rgba(231, 111, 81, 0.08);
    --match-gold: #e9a820;
    --match-bg: rgba(233, 168, 32, 0.12);
    --p1-color: #3a7bd5;
    --p1-bg: rgba(58, 123, 213, 0.1);
    --p2-color: #c44569;
    --p2-bg: rgba(196, 69, 105, 0.1);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --radius-sm: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: -webkit-fill-available;
}

body {
    font-family: 'Manrope', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.bg-blur {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 15% 10%, rgba(45, 106, 79, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 50% 60% at 85% 90%, rgba(231, 111, 81, 0.05) 0%, transparent 70%);
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(24px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    justify-content: center;
}

.glass {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 28px 22px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 2px;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.logo-dot {
    color: var(--accent2);
}

.screen-title {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    color: var(--text);
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.input-group label i {
    font-size: 0.68rem;
    color: var(--accent);
}

.input-group input {
    width: 100%;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: 'Manrope', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.input-group input::placeholder {
    color: #bbb5a8;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 700;
    font-family: 'Manrope', sans-serif;
    cursor: pointer;
    transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
    color: #fff;
    background: var(--accent);
    box-shadow: var(--shadow-sm);
    -webkit-appearance: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn i {
    font-size: 0.85rem;
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border-color: var(--border);
    box-shadow: none;
}

.btn-secondary:active {
    background: var(--accent-bg);
}

.btn-ghost {
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    padding: 12px;
}

.btn-ghost i {
    color: var(--accent2);
}

.btn-ghost:active {
    background: rgba(0, 0, 0, 0.03);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-appearance: none;
}

.btn-icon:active {
    background: var(--border-light);
}

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

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 16px 0;
}

.bingo-cell {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 6px 5px;
    border-radius: var(--radius-sm);
    font-size: clamp(0.58rem, 2.2vw, 0.72rem);
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    border: 1.5px solid var(--border);
    background: var(--bg-cell);
    color: var(--text-muted);
    transition: all 0.18s ease;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    -webkit-hyphens: auto;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.bingo-cell:active {
    transform: scale(0.94);
}

.bingo-cell .cell-check {
    position: absolute;
    top: 4px;
    right: 5px;
    font-size: 0.5rem;
    color: var(--accent);
}

.bingo-cell.selected {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 2px 8px rgba(45, 106, 79, 0.12);
}

.bingo-cell.match {
    background: var(--match-bg);
    border-color: var(--match-gold);
    color: #8a6611;
    box-shadow: 0 2px 12px rgba(233, 168, 32, 0.15);
    animation: pulseGold 2.5s ease-in-out infinite;
}

.bingo-cell .cell-icon-match {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: 0.5rem;
    color: var(--match-gold);
    animation: flickerFire 0.8s ease-in-out infinite alternate;
}

@keyframes flickerFire {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.bingo-cell.only-p1 {
    background: var(--p1-bg);
    border-color: rgba(58, 123, 213, 0.35);
    color: var(--p1-color);
}

.bingo-cell.only-p2 {
    background: var(--p2-bg);
    border-color: rgba(196, 69, 105, 0.35);
    color: var(--p2-color);
}

@keyframes pulseGold {

    0%,
    100% {
        box-shadow: 0 2px 8px rgba(233, 168, 32, 0.1);
    }

    50% {
        box-shadow: 0 2px 18px rgba(233, 168, 32, 0.25);
    }
}

.result-percent {
    text-align: center;
    font-size: 3.8rem;
    font-weight: 800;
    color: var(--accent);
    margin: 8px 0 0;
    line-height: 1;
}

.result-label {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.ai-comment {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 16px 0 6px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    border-left: 3px solid var(--accent2);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.ai-comment i {
    color: var(--accent2);
    margin-top: 3px;
    flex-shrink: 0;
}

.share-link {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    margin: 16px 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    word-break: break-all;
    border: 1.5px solid var(--border);
}

.share-link i {
    flex-shrink: 0;
    color: var(--accent);
    opacity: 0.6;
}

.share-link span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invite-header {
    text-align: center;
    margin-bottom: 24px;
}

.invite-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: 0 4px 16px rgba(45, 106, 79, 0.2);
}

.invite-icon.pulse {
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(45, 106, 79, 0.2), 0 0 0 0 rgba(45, 106, 79, 0.15);
    }

    50% {
        box-shadow: 0 4px 16px rgba(45, 106, 79, 0.2), 0 0 0 10px rgba(45, 106, 79, 0);
    }
}

.invite-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.invite-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    margin: 14px 0 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 4px;
}

.dot-match {
    background: var(--match-gold);
}

.dot-p1 {
    background: var(--p1-color);
}

.dot-p2 {
    background: var(--p2-color);
}

.counter {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-weight: 600;
}

.counter i {
    font-size: 0.72rem;
    margin-right: 2px;
    color: var(--accent);
}

.names-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.name-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--bg);
    border: 1.5px solid var(--border);
}

.badge-p1 {
    border-color: rgba(58, 123, 213, 0.3);
    color: var(--p1-color);
}

.badge-p1 i {
    color: var(--p1-color);
}

.badge-p2 {
    border-color: rgba(196, 69, 105, 0.3);
    color: var(--p2-color);
}

.badge-p2 i {
    color: var(--p2-color);
}

.new-game-link {
    display: block;
    text-align: center;
    color: var(--accent2);
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 18px;
    text-decoration: none;
    cursor: pointer;
    letter-spacing: 0.2px;
}

.new-game-link i {
    font-size: 0.72rem;
    margin-right: 3px;
}

.new-game-link:hover {
    text-decoration: underline;
}

.fade-enter-active {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-leave-active {
    transition: opacity 0.15s ease;
}

.fade-enter-from {
    opacity: 0;
    transform: translateY(16px);
}

.fade-leave-to {
    opacity: 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner.dark {
    border-color: var(--border);
    border-top-color: var(--accent);
}

.spinner.lg {
    width: 34px;
    height: 34px;
    border-width: 3px;
}

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

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 0;
}

.loading-screen .spinner {
    border-color: var(--border);
    border-top-color: var(--accent);
}

.loading-screen p {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
}

.toast {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    padding: 11px 20px;
    border-radius: 10px;
    font-size: 0.82rem;
    color: var(--bg-card);
    z-index: 100;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
    white-space: nowrap;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        pointer-events: none;
    }
}

.catalog-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.catalog-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.catalog-card {
    background: var(--bg);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
}

.catalog-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

.catalog-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.catalog-title {
    font-size: 0.88rem;
    font-weight: 700;
    flex: 1;
    margin-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.catalog-percent {
    font-size: 1.05rem;
    font-weight: 800;
    flex-shrink: 0;
}

.catalog-meta {
    display: flex;
    gap: 14px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.catalog-meta i {
    margin-right: 3px;
    font-size: 0.62rem;
    color: var(--accent);
    opacity: 0.6;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}

.empty-state {
    text-align: center;
    padding: 36px 0;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.2rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.88rem;
}

.divider {
    width: 48px;
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    margin: 0 auto 20px;
}

.presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
    justify-content: center;
}

.preset-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Manrope', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.preset-chip:active {
    transform: scale(0.94);
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.grid-size-row {
    margin-bottom: 16px;
}

.grid-size-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.grid-size-row label i {
    font-size: 0.68rem;
    color: var(--accent);
}

.grid-size-options {
    display: flex;
    gap: 8px;
}

.grid-size-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Manrope', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

.grid-size-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(45, 106, 79, 0.2);
}

.grid-size-btn:active {
    transform: scale(0.95);
}

.mygame-status {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 8px;
    flex-shrink: 0;
}

.status-done {
    background: var(--accent-bg);
    color: var(--accent);
}

.status-waiting_p2 {
    background: var(--match-bg);
    color: #8a6611;
}

.status-waiting_p1,
.status-playing {
    background: var(--accent2-bg);
    color: var(--accent2);
}

@media (max-width: 380px) {
    .glass {
        padding: 22px 14px;
        border-radius: 18px;
    }

    .bingo-grid {
        gap: 6px;
    }

    .bingo-cell {
        border-radius: 10px;
        font-size: 0.63rem;
        padding: 4px 3px;
    }

    .logo {
        font-size: 1.8rem;
    }

    .result-percent {
        font-size: 3rem;
    }

    .btn {
        padding: 13px;
        font-size: 0.88rem;
    }

    .preset-chip {
        font-size: 0.68rem;
        padding: 5px 10px;
    }
}

@media (min-width: 441px) {
    .bingo-cell {
        font-size: 0.76rem;
        padding: 8px 6px;
    }
}

@media (min-height: 800px) {
    #app {
        padding-top: calc(40px + var(--safe-top));
    }
}