/* Pounce -- pounce.html. Two halves: the board/engine (`pn-` prefix, pounce-engine.js) and the page
   around it (`pounce-` prefix: mode tabs, pickers, run cards, summary modal -- added in sprint 3).
   Brand: warm cream, ginger #F28C38, charcoal #3A3340; see docs/pounce-development-plan.md. */

.pn-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 14px 20px;
    background: var(--color-surface);
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.pn-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pn-stat-icon {
    font-size: 18px;
    line-height: 1;
}

.pn-stat-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-pounce-dark);
}

.pn-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.pn-stat-value.urgent {
    color: var(--color-danger);
}

.pn-round-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-secondary);
}

/* ---- Board ---- */

.pn-board {
    --pn-cell: 48px;
    --pn-ink: var(--color-pounce-ink);
    --pn-ginger: var(--color-pounce);
    --pn-cream: var(--color-pounce-cream);
    display: grid;
    /* minmax(0, 1fr), not 1fr: a plain 1fr track may grow to fit its content, and Safari does --
       placing a ✕ or a cat made that row taller. Fixed, equal tracks keep every cell square. */
    grid-template-columns: repeat(var(--pn-n), minmax(0, 1fr));
    grid-template-rows: repeat(var(--pn-n), minmax(0, 1fr));
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    margin: 0 auto;
    background: var(--pn-cream);
    border: 3px solid var(--pn-ink);
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.pn-row {
    display: contents;
}

.pn-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    background: var(--pn-region);
    border-right: 1px solid rgba(58, 51, 64, 0.16);
    border-bottom: 1px solid rgba(58, 51, 64, 0.16);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* Region borders: drawn on the right/bottom edge only, so a boundary is one thick line. */
.pn-cell.pn-br {
    border-right: max(2px, calc(var(--pn-cell) * 0.07)) solid var(--pn-ink);
}

.pn-cell.pn-bb {
    border-bottom: max(2px, calc(var(--pn-cell) * 0.07)) solid var(--pn-ink);
}

.pn-cell.pn-last-col {
    border-right: 0;
}

.pn-cell.pn-last-row {
    border-bottom: 0;
}

.pn-cell.pn-fixed {
    cursor: default;
}

@media (hover: hover) {
    .pn-cell:not(.pn-fixed):hover {
        background-image: linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35));
    }
}

.pn-cell:focus {
    outline: none;
}

.pn-cell:focus-visible {
    outline: 3px solid var(--pn-ginger);
    outline-offset: -3px;
    z-index: 1;
}

.pn-xmark {
    font-size: max(10px, calc(var(--pn-cell) * 0.4));
    font-weight: 700;
    line-height: 1;
    color: rgba(58, 51, 64, 0.5);
}

.pn-cat {
    display: block;
    width: 86%;
    height: 86%;
}

.pn-cat svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Sleeping dog (no cat here) and pawprint clue (how many cats touch this cell). */
.pn-dog {
    position: relative;
    font-size: max(12px, calc(var(--pn-cell) * 0.55));
    line-height: 1;
    filter: saturate(0.85);
}

.pn-dog-z {
    position: absolute;
    top: -0.35em;
    right: -0.45em;
    font-size: 0.42em;
    font-weight: 800;
    color: var(--pn-ink);
    opacity: 0.6;
}

.pn-paw {
    position: relative;
    display: block;
    width: 78%;
    height: 78%;
}

.pn-paw svg {
    width: 100%;
    height: 100%;
    fill: rgba(58, 51, 64, 0.82);
}

.pn-paw-n {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 9%;
    text-align: center;
    font-size: max(10px, calc(var(--pn-cell) * 0.32));
    font-weight: 800;
    color: #FFFFFF;
    font-variant-numeric: tabular-nums;
}

/* Whisker Tip highlight. */
.pn-cell.pn-hl {
    box-shadow: inset 0 0 0 max(2px, calc(var(--pn-cell) * 0.07)) var(--pn-ginger);
    animation: pn-glow 1.2s ease-in-out infinite alternate;
}

@keyframes pn-glow {
    from { background-image: linear-gradient(rgba(242, 140, 56, 0.08), rgba(242, 140, 56, 0.08)); }
    to { background-image: linear-gradient(rgba(242, 140, 56, 0.3), rgba(242, 140, 56, 0.3)); }
}

.pn-cell.pn-wrong {
    background-image: linear-gradient(rgba(192, 57, 43, 0.28), rgba(192, 57, 43, 0.28));
}

/* ---- Motion: pounce on place, hiss on a mistake, curl up on solve ---- */

.pn-pounce {
    animation: pn-pounce 0.38s cubic-bezier(0.3, 1.4, 0.5, 1);
}

@keyframes pn-pounce {
    0% { transform: translateY(-40%) scale(0.6) rotate(-10deg); opacity: 0; }
    45% { transform: translateY(5%) scale(1.1, 0.88); opacity: 1; }
    70% { transform: scale(0.95, 1.06); }
    100% { transform: none; }
}

.pn-hiss {
    animation: pn-hiss 0.42s ease-in forwards;
}

@keyframes pn-hiss {
    0% { transform: scale(1); }
    18% { transform: scale(1.2) translateX(-7%); }
    36% { transform: scale(1.2) translateX(7%); }
    54% { transform: scale(1.2) translateX(-5%); }
    100% { transform: translateY(-45%) scale(0.6); opacity: 0; }
}

.pn-solved .pn-cat {
    animation: pn-curl 0.6s ease-out both;
    animation-delay: var(--pn-delay, 0ms);
}

@keyframes pn-curl {
    0% { transform: none; }
    40% { transform: scale(1.12) rotate(-6deg); }
    100% { transform: scale(0.94) rotate(0); }
}

.pn-zzz {
    position: absolute;
    top: 4%;
    right: 8%;
    font-size: max(9px, calc(var(--pn-cell) * 0.26));
    font-weight: 800;
    color: var(--pn-ink);
    opacity: 0;
    animation: pn-zzz 1.6s ease-out forwards;
    animation-delay: calc(var(--pn-delay, 0ms) + 400ms);
}

@keyframes pn-zzz {
    0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
    30% { opacity: 0.8; }
    100% { opacity: 0.55; transform: translate(20%, -60%) scale(1); }
}

/* Lost round: the answer's cats appear faded. */
.pn-ghost {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.pn-failed .pn-cell {
    cursor: default;
}

@media (prefers-reduced-motion: reduce) {
    .pn-board *,
    .pn-board {
        animation: none !important;
        transition: none !important;
    }

    .pn-zzz {
        opacity: 0.55;
    }
}

/* ---- Tip, message, controls ---- */

.pn-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 560px;
    margin: 14px auto 0;
    padding: 12px 16px;
    background: var(--color-pounce-tint);
    border: 1px solid var(--color-pounce-soft);
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.45;
    color: var(--color-text);
}

.pn-tip[hidden] {
    display: none;
}

.pn-tip-icon {
    font-size: 18px;
    line-height: 1.3;
}

.pn-message {
    min-height: 1.6em;
    margin: 12px 0 8px;
    text-align: center;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.pn-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.pn-control-btn {
    padding: 10px 18px;
    border: 0.5px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.15s;
}

.pn-control-btn:not(:disabled):hover {
    border-color: var(--color-pounce);
    background: var(--color-pounce-tint);
}

.pn-control-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.pn-tip-btn {
    border-color: var(--color-pounce-soft);
    background: var(--color-pounce-tint);
}

.pn-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 20px;
    margin-top: 12px;
}

.pn-options-done {
    visibility: hidden;
}

.pn-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.pn-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-pounce);
}

@media (max-width: 420px) {
    .pn-stats {
        padding: 12px 14px;
    }

    .pn-stat-label {
        display: none;
    }

    .pn-control-btn {
        padding: 10px 14px;
    }
}

/* ==================== Page ==================== */

.pounce-mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 460px;
    margin: 0 auto 20px;
}

.pounce-mode-tab {
    flex: 1;
    min-width: 140px;
    padding: 10px 14px;
    border: 0.5px solid var(--color-border);
    background: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.pounce-mode-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pounce-mode-tab:not(.active):hover {
    background: var(--color-bg);
    border-color: var(--color-border-strong);
}

.game-container {
    max-width: 460px;
    margin: 0 auto;
}

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

.pounce-subtitle {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}


.pounce-difficulty-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pounce-difficulty-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 16px 20px;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.pounce-difficulty-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-tint);
}

.pounce-difficulty-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.pounce-difficulty-points {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
}

.pounce-tournament-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pounce-tournament-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px 24px;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

.pounce-tournament-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pounce-tournament-name {
    font-weight: 800;
    font-size: 22px;
    color: var(--color-text);
}

.pounce-tournament-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 15px;
    color: var(--color-text-secondary);
}

.pounce-tournament-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.pounce-tournament-meta-icon {
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.pounce-tournament-sep {
    color: var(--color-border-strong);
}

.pounce-tournament-card .btn {
    flex: 0 0 auto;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .pounce-tournament-card {
        flex-direction: column;
        align-items: stretch;
    }

    .pounce-tournament-card .btn {
        width: 100%;
    }
}

.pounce-tournament-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}


/* ---------- Post-round summary modal ----------
   Same overlay/dialog/close pattern as index.html's sign-in modal / wordle.html's summary modal,
   duplicated here rather than shared since only one page's CSS loads at a time. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 44, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 300;
}

.modal-dialog {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 52px 24px 24px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
    z-index: 1;
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.pounce-summary-celebrate {
    position: relative;
    display: flex;
    justify-content: center;
    height: 64px;
    margin-bottom: 8px;
}

.pounce-summary-trophy-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary-tint);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pounce-summary-trophy-wrap svg {
    width: 30px;
    height: 30px;
}

.pounce-summary-confetti {
    position: absolute;
    top: 8px;
    width: 7px;
    height: 7px;
    border-radius: 2px;
}

.pounce-summary-confetti-1 {
    left: calc(50% - 92px);
    background: #F2B705;
    transform: rotate(20deg);
}

.pounce-summary-confetti-2 {
    left: calc(50% - 68px);
    top: 34px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-danger);
}

.pounce-summary-confetti-3 {
    right: calc(50% - 92px);
    background: var(--color-primary);
    transform: rotate(-20deg);
}

.pounce-summary-confetti-4 {
    right: calc(50% - 68px);
    top: 34px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-success);
}

.pounce-summary-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 4px;
}

.pounce-summary-subtitle {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 20px;
}

.pounce-summary-breakdown {
    border-top: 0.5px solid var(--color-border);
    padding-top: 12px;
    margin-bottom: 16px;
}

.pounce-summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--color-text-secondary);
    padding: 4px 0;
}

.pounce-summary-line-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pounce-summary-line-icon {
    display: flex;
    flex: 0 0 auto;
    color: var(--color-primary);
}

.pounce-summary-line-icon svg {
    width: 16px;
    height: 16px;
}

.pounce-summary-total {
    border-top: 0.5px solid var(--color-border);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 700;
    color: var(--color-text);
    font-size: 16px;
}

/* ---------- Share options (Daily/Classic/Tournament completion) ---------- */
.pounce-share-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pounce-share-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-lg);
    background: var(--color-primary-tint);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: filter 0.15s;
}

.pounce-share-option:hover {
    filter: brightness(0.97);
}

.pounce-share-friends {
    border-color: var(--color-success);
    background: #E3F5EE;
}

.pounce-share-option-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pounce-share-friends .pounce-share-option-icon {
    color: var(--color-success);
}

.pounce-share-option-icon svg {
    width: 22px;
    height: 22px;
}

.pounce-share-option-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pounce-share-option-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--color-primary);
}

.pounce-share-friends .pounce-share-option-title {
    color: var(--color-success);
}

.pounce-share-option-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

/* Badge + chevron live in their own column on the right, out of the title's text flow, so a long
   title never pushes the badge onto its own visual row underneath. */
.pounce-share-option-side {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    color: var(--color-primary);
}

.pounce-share-friends .pounce-share-option-side {
    color: var(--color-success);
}

.pounce-share-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--color-primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.pounce-share-badge-green {
    background: var(--color-success);
}

.pounce-share-option-side svg {
    width: 18px;
    height: 18px;
}

/* Set by markClaimed() once this specific option's bonus has been awarded -- the other option
   stays fully interactive regardless. */
.pounce-share-option-claimed {
    cursor: default;
    opacity: 0.7;
}

.pounce-share-option-claimed:hover {
    filter: none;
}

.pounce-share-or {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 12px;
}

.pounce-share-or::before,
.pounce-share-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* Classic picker: name + size on one line, a short blurb under it. */
.pounce-difficulty-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
}

.pounce-difficulty-points {
    flex-shrink: 0;
    margin-left: 12px;
    white-space: nowrap;
}

.pounce-difficulty-blurb {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.pounce-summary-perfect {
    display: block;
    width: fit-content;
    margin: -8px auto 14px;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--color-primary-tint);
    color: var(--color-primary-dark);
    font-size: 13px;
    font-weight: 700;
}

/* Nine Lives Run progress: one pip per board + lives left (pounce-page.js#runStripHtml). */
.pounce-run-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    max-width: 560px;
    margin: 0 auto 14px;
}

.pounce-run-pips {
    display: flex;
    gap: 6px;
}

.pounce-run-pip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 30px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1.5px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text-muted);
}

.pounce-run-pip-current {
    border-color: var(--color-pounce);
    background: var(--color-pounce-tint);
    color: var(--color-pounce-dark);
}

.pounce-run-pip-passed {
    border-color: var(--color-success);
    background: var(--color-success);
    color: #FFFFFF;
    font-size: 15px;
}

.pounce-run-pip-failed {
    border-color: var(--color-danger);
    background: rgba(192, 57, 43, 0.1);
    color: var(--color-danger);
    font-size: 15px;
}

.pounce-run-lives {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-pounce-dark);
}

.pounce-run-lives svg {
    width: 20px;
    height: 20px;
    color: var(--color-pounce);
}

.pounce-run-lives span {
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

/* The Cat Café cat a Daily solve adopts, at the top of the summary modal. */
.pounce-summary-cat {
    width: 120px;
    height: 120px;
    margin: 4px auto 6px;
    animation: pn-pounce 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.pounce-summary-cat svg {
    width: 100%;
    height: 100%;
}

.pounce-summary-adopted {
    margin: -2px 0 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-pounce-dark);
}

/* Already-played Daily: today's solved board, small and static. */
.pounce-played-board {
    max-width: 320px;
    margin: 16px auto 0;
    pointer-events: none;
}

/* ---------- How to Play: Pounce-specific mini visuals (shared .htp-* layout is in components.css) */
.htp-mini-pounce {
    width: 152px;
    max-width: 152px;
    --pn-cell: 38px;
    border-width: 2px;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    .pounce-summary-cat {
        animation: none;
    }
}
