/* ── Challenge Your Friends ─────────────────── */
/* Small icon buttons, right-aligned above the board */
.challenge-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.header-icons {
    display: flex;
    gap: 6px;
}

.header-icon {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: #ed6a5a;
    box-shadow: 0 1px 0 #aaaaaa;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.header-icon:hover,
.header-icon:focus-visible {
    background-color: #5ca4a9;
    outline: none;
}

.header-icon span {
    color: #ffffff;
    font-size: 16px;
    line-height: 32px;
}

.header-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: #333333;
    color: #ffffff;
    font-size: 12px;
    font-family: 'Maven Pro', sans-serif;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 5;
}

.header-icon[data-tooltip]:hover::after,
.header-icon[data-tooltip]:focus-visible::after {
    opacity: 1;
}

/* Rail colours are deliberately NOT the game's teal (cows) / coral (bulls):
   dark indigo shell, violet = playing, gold = solved, slate = out. */

/* Floating race rail (all screen sizes): one avatar per player, fixed to the
   right edge of the game column – on wide screens that's the column, not the
   window, so it stays next to the board. */
.race-rail {
    display: flex;
    position: fixed;
    right: max(6px, calc(50vw - 384px + 6px));
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 8px 5px;
    background: #2e2a4f;
    border: 2px solid #2e2a4f;
    border-radius: 24px;
    box-shadow: 0 3px 12px rgba(46, 42, 79, 0.45);
    font-family: 'Maven Pro', sans-serif;
    cursor: pointer;
}

.race-rail.hide {
    display: none;
}

/* Drawer-style tab on the rail's left edge: signals "tap to open" */
.race-rail-handle {
    position: absolute;
    left: -11px;
    top: 50%;
    transform: translateY(-50%);
    width: 11px;
    height: 36px;
    border-radius: 7px 0 0 7px;
    background: #2e2a4f;
    color: #f5b82e;
    font-size: 15px;
    font-weight: bold;
    line-height: 34px;
    text-align: center;
}

.race-rail:active {
    scale: 0.96;
}

.race-rail.nudge {
    animation: race-nudge 0.9s ease 0.8s 2;
}

@keyframes race-nudge {
    0%, 100% { translate: 0 0; }
    30%      { translate: -8px 0; }
    60%      { translate: 0 0; }
}

.race-rail-title {
    font-size: 16px;
    line-height: 1;
}

.race-rail-avatars {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.race-avatar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
}

.race-avatar.is-solved {
    background: #f5b82e;
    color: #3b2c00;
}

.race-avatar.is-playing {
    background: #8b7cf6;
    animation: race-pulse 1.8s ease-out infinite;
}

.race-avatar.is-out {
    background: #5d5a78;
    color: #c9c6dc;
}

.race-avatar.is-me {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* "+3" chip: more players than the 5 circles shown */
.race-more {
    min-width: 26px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #e6e3f7;
    font-size: 10px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
    align-self: center;
}

.race-badge {
    position: absolute;
    top: -5px;
    right: -6px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: #ffffff;
    color: #2e2a4f;
    font-size: 10px;
    font-weight: bold;
    line-height: 15px;
    text-align: center;
}

.race-rail-count {
    font-size: 11px;
    font-weight: bold;
    color: #f5b82e;
    white-space: nowrap;
}

/* "Priya cracked it – your move!" alert */
.race-toast {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    max-width: 92%;
    padding: 10px 18px;
    border-radius: 22px;
    background: #333333;
    color: #ffffff;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    animation: race-toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Short pulse when the standings change */
.bump {
    animation: race-bump 0.6s ease;
}

@keyframes race-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(139, 124, 246, 0.8); }
    70%  { box-shadow: 0 0 0 7px rgba(139, 124, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 124, 246, 0); }
}

@keyframes race-bump {
    40% { scale: 1.12; border-color: #f5b82e; }
}

@keyframes race-toast-in {
    from { opacity: 0; top: -40px; }
    to   { opacity: 1; top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .race-avatar.is-playing,
    .race-rail.nudge,
    .meta-live,
    .bump,
    .race-toast {
        animation: none;
    }
}

/* Keep a lane free for the rail so it never covers the board or history */
body.is-racing .app-wrapper {
    padding-right: 72px;
}


/* Full standings overlay */
#standingsModal .standings-modal-content {
    width: 92%;
    max-width: 640px;
    height: auto;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}

#standingsModal h3 {
    font-family: 'Fredoka One', cursive;
    font-weight: normal;
    color: #5ca4a9;
    font-size: 18px;
    margin-bottom: 12px;
}

#standingsModal .play-button {
    padding: 6px 16px;
}

.challenge-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 20px;
}

.challenge-card h3 {
    font-family: 'Fredoka One', cursive;
    font-weight: normal;
    color: #5ca4a9;
    font-size: 18px;
    margin-bottom: 10px;
}

.challenge-card p {
    margin-bottom: 8px;
}

.challenge-expired {
    background: #edd4d4;
    color: #571515;
    border: 1px solid #e6c3c3;
}

.challenge-expired h3 {
    color: #571515;
}

.challenge-expired a {
    color: #571515;
    font-weight: bold;
}

.challenge-note {
    font-size: 13px;
    color: #777777;
    margin-bottom: 10px;
}

/* Info block: read-only status line + invite link */
.challenge-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* Status line: styled as plain metadata (no pills, borders or hover) so it
   reads as information, not something to tap. */
.challenge-meta {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    padding: 6px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 12px;
    letter-spacing: 0.2px;
    color: #6f766b;
    white-space: nowrap;
    cursor: default;
    font-variant-numeric: tabular-nums;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.meta-item + .meta-item {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(0, 0, 0, 0.15);
}

/* The rules text is the one item allowed to shrink on very narrow screens */
.meta-rules {
    flex: 0 1 auto;
    min-width: 0;
}

.meta-rules > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-icon {
    font-size: 12px;
    opacity: 0.75;
}

/* Small pulsing dot: this value is live */
.meta-live {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #0bbb62;
    animation: meta-live 2s ease-out infinite;
}

.meta-warn,
.meta-alert {
    color: #d9594a;
}

.meta-alert {
    font-weight: bold;
}

.meta-warn .meta-live {
    background: #ed6a5a;
}

.is-ended .meta-live {
    background: #bbbbbb;
    animation: none;
}

@keyframes meta-live {
    0%   { box-shadow: 0 0 0 0 rgba(11, 187, 98, 0.6); }
    70%  { box-shadow: 0 0 0 5px rgba(11, 187, 98, 0); }
    100% { box-shadow: 0 0 0 0 rgba(11, 187, 98, 0); }
}

.invite-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.invite-bar input[type="text"] {
    flex: 1 1 260px;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px dotted #aeaeae;
    border-radius: 3px;
    font-family: 'Maven Pro', sans-serif;
    font-size: 13px;
    color: #555555;
    background: #ffffff;
}

.invite-bar .share-button {
    margin: 0;
    padding: 8px 14px;
    font-size: 14px;
}

/* Play page: compact link + copy button */
.invite-bar-compact {
    flex-wrap: nowrap;
    max-width: 340px;
    gap: 4px;
}

.invite-bar-compact input[type="text"] {
    flex: 1 1 auto;
    height: 26px;
    padding: 0 8px;
    font-size: 11px;
    color: #777777;
    text-overflow: ellipsis;
}

.copy-btn {
    flex: 0 0 auto;
    height: 26px;
    padding: 0 10px;
    border: 0;
    border-radius: 3px;
    background: #6c757d;
    color: #ffffff;
    font-family: 'Maven Pro', sans-serif;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease;
}

.copy-btn:hover {
    background: #555c63;
}

/* Copied: the button turns green and shows ✓✓ for a moment */
.copy-btn.is-copied,
.share-button.is-copied {
    background: #0bbb62;
    letter-spacing: -2px;
}

/* After the game: lean result card (left) + "create your own" invitation (right) */
.result-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 170px;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 20px;
}

.result-row.hide {
    display: none;
}

.result-card {
    padding: 12px 14px;
    border-radius: 8px;
    border-left: 4px solid #0bbb62;
    background: #ffffff;
}

.result-card.is-lose {
    border-left-color: #cc4b3c;
}

.result-title {
    font-family: 'Fredoka One', cursive;
    font-size: 18px;
    color: #10683c;
}

.result-card.is-lose .result-title {
    color: #8a2f25;
}

.result-sub {
    margin: 2px 0 10px;
    font-size: 12px;
    color: #777777;
}

.result-sub strong {
    color: #555555;
    letter-spacing: 1px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    gap: 6px 22px;
    margin: 0;
}

.result-stats dt {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #999999;
}

.result-stats dd {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #444444;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.result-stats dd small {
    font-size: 12px;
    font-weight: normal;
    color: #999999;
}

/* Certificate buttons inside the result card */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.result-actions.hide {
    display: none;
}

.cert-btn {
    padding: 5px 12px;
    border: 1px solid #5ca4a9;
    border-radius: 14px;
    background: #ffffff;
    color: #3f8a8f;
    font-family: 'Maven Pro', sans-serif;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cert-btn:hover:not(:disabled),
.cert-btn:focus-visible {
    background: #5ca4a9;
    color: #ffffff;
    outline: none;
}

.cert-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.cert-note {
    margin-top: 6px;
    font-size: 11px;
    color: #777777;
}

.create-cta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 12px;
    border: 2px dashed #5ca4a9;
    border-radius: 8px;
    background: #ffffff;
    text-align: center;
}

.create-cta-title {
    font-family: 'Fredoka One', cursive;
    font-size: 15px;
    color: #5ca4a9;
}

.create-cta-text {
    font-size: 12px;
    line-height: 1.35;
    color: #777777;
}

.create-cta-button {
    align-self: center;
    margin-top: 4px;
    padding: 5px 14px;
    border-radius: 14px;
    background: #0bbb62;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    transition: background 0.15s ease;
}

.create-cta-button:hover {
    background: #10683c;
}

/* Finished game: board + history collapse into a "Your game" card */
.game-panel.is-done {
    margin-bottom: 20px;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.game-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    background: transparent;
    color: #555555;
    font-family: 'Maven Pro', sans-serif;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.game-card-head.hide {
    display: none;
}

.game-card-head:hover,
.game-card-head:focus-visible {
    background: #f6f8f3;
    outline: none;
}

.game-card-title {
    font-family: 'Fredoka One', cursive;
    font-size: 15px;
    color: #5ca4a9;
}

.game-card-summary {
    flex: 1 1 auto;
    min-width: 0;
    color: #888888;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-chevron {
    flex: 0 0 auto;
    color: #5ca4a9;
    font-size: 14px;
    transition: transform 0.2s ease;
}

.game-panel.is-open .game-card-chevron {
    transform: rotate(180deg);
}

/* Rubber-stamp label */
.game-stamp {
    flex: 0 0 auto;
    padding: 2px 7px;
    border: 2px solid currentColor;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    transform: rotate(-4deg);
}

.game-stamp.is-solved {
    color: #0b9a52;
}

.game-stamp.is-lost {
    color: #cc4b3c;
}

.game-stamp.is-ended {
    color: #888888;
}

.game-panel.is-done .game-card-body {
    padding: 14px 14px 4px;
    border-top: 1px solid #e6ebe0;
}

.game-panel.is-done .history-container {
    min-height: 0;
}

/* Join form */
.join-form {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

/* .play-button:focus adds a 1px border; reserve it so the button doesn't grow
   (and wrap away from under the pointer) on mousedown. */
.join-form .play-button,
.setup-actions .play-button {
    border: 1px solid transparent;
}

.join-form input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 2px solid #cccccc;
    border-radius: 22px;
    font-family: 'Maven Pro', sans-serif;
    font-size: 15px;
}

.join-form input[type="text"]:focus {
    outline: none;
    border-color: #5ca4a9;
}

/* Setup page: optional creator name for the invite message */
.setup-name {
    width: 100%;
    max-width: 300px;
    height: 44px;
    padding: 0 16px;
    border: 2px solid #cccccc;
    border-radius: 22px;
    background: #ffffff;
    font-family: 'Maven Pro', sans-serif;
    font-size: 15px;
    color: #555555;
}

.setup-name:focus {
    outline: none;
    border-color: #5ca4a9;
}

.optional-label {
    font-family: 'Maven Pro', sans-serif;
    font-size: 13px;
    color: #888888;
}

.share-button.more {
    background: #5ca4a9;
}

.setup-play:disabled,
#goButton:disabled {
    opacity: 0.6;
    cursor: wait;
}

a.setup-play {
    display: inline-block;
    text-decoration: none;
}

/* Leaderboard */
.leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 10px;
}

.leaderboard th,
.leaderboard td {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 1px solid #e6ebe0;
}

.leaderboard th {
    font-family: 'Fredoka One', cursive;
    font-weight: normal;
    color: #5ca4a9;
}

.leaderboard td:nth-child(1),
.leaderboard td:nth-child(3),
.leaderboard td:nth-child(4),
.leaderboard td:nth-child(5) {
    white-space: nowrap;
}

/* Score decides the rank, so make it stand out */
.leaderboard td:nth-child(5) {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.leaderboard td:nth-child(2) {
    word-break: break-word;
}

.leaderboard tr.is-me td {
    background: #fff3cd;
    font-weight: bold;
}

@media (max-width: 481px) {
    .result-row {
        grid-template-columns: minmax(0, 1fr) 118px;
        gap: 8px;
    }

    .result-card {
        padding: 10px;
    }

    .result-title {
        font-size: 16px;
    }

    .result-stats {
        grid-template-columns: repeat(2, auto);
        gap: 6px 16px;
    }

    .result-stats dd {
        font-size: 16px;
    }

    .create-cta {
        padding: 10px 8px;
    }

    .game-card-head {
        gap: 8px;
        padding: 10px;
    }

    .game-panel.is-done .game-card-body {
        padding: 12px 10px 4px;
    }

    .challenge-meta {
        font-size: 11px;
    }

    .meta-item + .meta-item {
        margin-left: 8px;
        padding-left: 8px;
    }

    .meta-long {
        display: none;
    }

    body.is-racing .app-wrapper {
        padding-right: 54px;
    }

    /* ...and compact the cow/bull icons + timer so 6 digits still fit on one line */
    body.is-racing .find-wrapper .cow-bull-icon-wrapper {
        margin-left: 6px;
        min-width: 62px;
    }

    body.is-racing .find-wrapper .cow-bull-icon-wrapper .icon-cow {
        font-size: 28px;
        top: -14px;
        left: 2px;
    }

    body.is-racing .find-wrapper .cow-bull-icon-wrapper .icon-bull {
        font-size: 30px;
        top: -16px;
        left: 32px;
    }

    body.is-racing .timer-display-wrapper {
        padding-left: 8px;
    }

    #standingsModal .standings-modal-content {
        padding: 18px 12px;
    }

    .header-icon {
        width: 28px;
        height: 28px;
    }

    .header-icon span {
        font-size: 14px;
        line-height: 28px;
    }

    .leaderboard {
        font-size: 13px;
    }

    .leaderboard th,
    .leaderboard td {
        padding: 6px 4px;
    }
}

/* Cloudflare Turnstile on the setup page – empty (no height) unless Cloudflare
   asks the visitor to click */
.captcha-box:not(:empty) {
    margin: 4px 0 14px;
}
.captcha-note {
    margin: 0 0 12px;
    font-size: 14px;
    color: #777777;
}
