@theme-color: #d34b7a;
@theme-color-highlighted: #f15f93;
@theme-color-selected: #ea86b1;
@background-color: #222629;
@empty-color: #151716;
@dark-accent-color: #2e353b;
@warning-red: #9b5c5c;

@bingo-b: #2f6fed;
@bingo-i: #e0457b;
@bingo-n: #f0a500;
@bingo-g: #2baf6a;
@bingo-o: #8a4fd6;

@import "core.less";

#game-over-modal {
  --victory-winning-cell-color: @theme-color-highlighted;
}

body {
    color: white;
}

.column-letter-color(@letter, @color) {
    .letter-@{letter} { color: @color; }
}

.bingo-letter-bg(@letter, @color) {
    &.letter-@{letter} { background-color: @color; border-color: darken(@color, 10%); }
}

// caller area
// ===========

#bingo-caller-row {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 18px;
}

.bingo-caller-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 150px;
}

.bingo-ball {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #d7d7d7 60%, #9a9a9a 100%);
    color: #1d1d1d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    box-shadow: inset -4px -4px 8px rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.4);
    border: 3px solid #ededed;
    transition: transform 0.2s ease;
}

.bingo-ball.empty {
    background: @empty-color;
    color: #555;
    border-color: @dark-accent-color;
    box-shadow: none;
}

.bingo-ball.letter-b { box-shadow: inset 0 0 0 5px @bingo-b, inset -4px -4px 8px rgba(0,0,0,0.25); }
.bingo-ball.letter-i { box-shadow: inset 0 0 0 5px @bingo-i, inset -4px -4px 8px rgba(0,0,0,0.25); }
.bingo-ball.letter-n { box-shadow: inset 0 0 0 5px @bingo-n, inset -4px -4px 8px rgba(0,0,0,0.25); }
.bingo-ball.letter-g { box-shadow: inset 0 0 0 5px @bingo-g, inset -4px -4px 8px rgba(0,0,0,0.25); }
.bingo-ball.letter-o { box-shadow: inset 0 0 0 5px @bingo-o, inset -4px -4px 8px rgba(0,0,0,0.25); }

.bingo-caller-meta {
    text-align: center;
}

.bingo-pattern-label {
    font-weight: 700;
    font-size: 14px;
    color: @theme-color-selected;
}

.bingo-called-count {
    font-size: 12px;
    color: #b9c0c6;
}

.bingo-called-board {
    display: flex;
    gap: 6px;
    background-color: @dark-accent-color;
    border-radius: 8px;
    padding: 8px;
}

.bingo-called-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bingo-called-letter {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 4px;
}
.bingo-called-letter.letter-b { color: lighten(@bingo-b, 12%); }
.bingo-called-letter.letter-i { color: lighten(@bingo-i, 8%); }
.bingo-called-letter.letter-n { color: lighten(@bingo-n, 4%); }
.bingo-called-letter.letter-g { color: lighten(@bingo-g, 8%); }
.bingo-called-letter.letter-o { color: lighten(@bingo-o, 8%); }

.bingo-called-nums {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bingo-called-num {
    font-size: 10px;
    width: 22px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    color: #5a6166;
    border-radius: 3px;
}

.bingo-called-num.called {
    color: #fff;
    background-color: @theme-color;
    font-weight: 700;
}

.bingo-called-num.current {
    outline: 2px solid #fff;
    transform: scale(1.08);
}

// controls
// ========

// controls live under the ball in the caller panel, stacked to fill the space
#bingo-controls-row {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

#bingo-controls-row .button {
    margin: 0;
    white-space: nowrap;
}

#bingo-call-button {
    background-color: @theme-color;
    color: #fff;
}
#bingo-call-button:hover {
    background-color: @theme-color-highlighted;
}

#bingo-claim-button {
    background-color: @dark-accent-color;
    color: #fff;
    opacity: 0.65;
    cursor: not-allowed;
}

#bingo-claim-button.ready {
    background-color: @bingo-n;
    color: #1d1d1d;
    opacity: 1;
    cursor: pointer;
    font-weight: 800;
    animation: bingo-pulse 1s infinite;
}

@keyframes bingo-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(240, 165, 0, 0.6); }
    70% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(240, 165, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(240, 165, 0, 0); }
}

// cards
// =====

// the player's own box: avatar + name on top, the bingo card below, all highlighted together
#bingo-my-info-row {
    margin-top: 14px;
}

.bingo-my-info {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background-color: @dark-accent-color;
    border-radius: 12px;
    padding: 8px;
}

// inside the player box the card merges with the box background so the whole thing reads as one unit
.bingo-my-info .bingo-card {
    background-color: transparent;
    padding: 0;
}

.bingo-my-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.bingo-my-name {
    font-size: 15px;
    font-weight: 700;
    color: @theme-color-selected;
}

.bingo-card-heading {
    font-weight: 700;
    margin-bottom: 8px;
    color: @theme-color-selected;
}

.bingo-card {
    display: inline-block;
    background-color: @dark-accent-color;
    border-radius: 10px;
    padding: 8px;
}

.bingo-card-row {
    display: flex;
}

.bingo-card-cell {
    width: 46px;
    height: 46px;
    margin: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
    background-color: @empty-color;
    color: #fff;
    cursor: pointer;
    user-select: none;
    border: 2px solid transparent;
    transition: transform 0.1s ease, background-color 0.15s ease;
}

.bingo-card-cell:hover:not(.bingo-card-letter):not(.free) {
    border-color: @theme-color-selected;
}

.bingo-card-cell.marked {
    background-color: @theme-color;
    color: #fff;
}

.bingo-card-cell.marked span {
    position: relative;
}

.bingo-card-cell.marked span::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.18);
    z-index: -1;
}

.bingo-card-cell.free {
    background-color: @theme-color-selected;
    color: #1d1d1d;
    cursor: default;
    font-size: 12px;
}

.bingo-card-cell.winning {
    background-color: @bingo-n;
    color: #1d1d1d;
    animation: bingo-pulse 1.2s infinite;
}

.bingo-card-cell.bingo-card-letter {
    cursor: default;
    background-color: transparent;
    height: 26px;
    font-size: 19px;
    font-weight: 900;
}
.bingo-card-cell.bingo-card-letter.letter-b { color: lighten(@bingo-b, 12%); }
.bingo-card-cell.bingo-card-letter.letter-i { color: lighten(@bingo-i, 8%); }
.bingo-card-cell.bingo-card-letter.letter-n { color: lighten(@bingo-n, 4%); }
.bingo-card-cell.bingo-card-letter.letter-g { color: lighten(@bingo-g, 8%); }
.bingo-card-cell.bingo-card-letter.letter-o { color: lighten(@bingo-o, 8%); }

// other players
// =============

// up to 3 players across the top
#bingo-other-top {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
}

#bingo-other-top:empty {
    margin-top: 0;
}

// three-column play area: side players flank the central board.
// gap and margin-top share one value so the spacing around the board is uniform
// on every side (top row above, side columns left/right, my box below).
.bingo-play-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 14px;
    margin-top: 14px;
}

.bingo-center-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.bingo-center-col > .row {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

.bingo-side-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-top: 0;
}

.bingo-side-col:empty {
    display: none;
}

.bingo-other-player {
    background-color: @dark-accent-color;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    // fixed width so every other-player tile is the same size (long names truncate)
    width: 150px;
    box-sizing: border-box;
}

// Highlight every player while the game is running (like Set). We use box-shadow
// rather than ::before/::after so it never collides with the seasonal theme corner
// decorations, which own those pseudo-elements on .player-info / .other-player.
.bingo-other-player.bingo-active,
.bingo-my-info.bingo-active {
    animation: bingo-active-pulse 2s ease-in-out infinite;
}

// The bingo win highlight (yellow) takes precedence over the active ring.
.bingo-other-player.is-bingo,
.bingo-other-player.is-bingo.bingo-active {
    box-shadow: 0 0 0 3px @bingo-n;
    animation: none;
}

@keyframes bingo-active-pulse {
    0%, 100% { box-shadow: 0 0 0 2px fade(@theme-color, 65%); }
    50%      { box-shadow: 0 0 0 3px @theme-color; }
}

.bingo-other-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.bingo-other-avatar {
    flex: 0 0 auto;
}

.bingo-other-meta {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

.bingo-other-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bingo-other-status {
    font-size: 12px;
    font-weight: 600;
    color: #b9c0c6;
}

.bingo-other-status.is-ready {
    color: @theme-color-selected;
}

.bingo-other-status.is-bingo {
    color: @bingo-n;
    font-weight: 800;
}

.bingo-expand-caret {
    display: none;
    margin-left: auto;
    color: @theme-color-selected;
    font-size: 14px;
    transition: transform 0.2s ease;
}

.bingo-mini-card {
    display: inline-block;
    background-color: @empty-color;
    border-radius: 6px;
    padding: 3px;
}

.bingo-mini-row {
    display: flex;
}

.bingo-mini-cell {
    width: 18px;
    height: 18px;
    margin: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    border-radius: 3px;
    background-color: @background-color;
    color: #8d949a;
}

.bingo-mini-cell.covered {
    background-color: @theme-color;
    color: #fff;
}

.bingo-mini-cell.free {
    background-color: @theme-color-selected;
    color: #1d1d1d;
}

.bingo-mini-cell.winning {
    background-color: @bingo-n;
    color: #1d1d1d;
}

.bingo-spectators {
    font-size: 12px;
    margin-top: 4px;
    color: #b9c0c6;
}

// lobby pattern selector
// ======================

#bingo-lobby-options-row {
    margin-top: 10px;
    justify-content: center;
}

.bingo-lobby-options {
    background-color: @dark-accent-color;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
}

.bingo-options-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: @theme-color-selected;
}

#bingo-pattern-select {
    max-width: 240px;
    margin: 0 auto;
}

// responsive
// ==========

@media (max-width: 575px) {
    // shrink the card and squeeze the dead space so the whole board fits a phone
    .bingo-card-cell {
        width: 38px;
        height: 38px;
        font-size: 13px;
        margin: 1.5px;
    }
    .bingo-card-cell.bingo-card-letter {
        height: 18px;
        font-size: 15px;
    }
    .bingo-my-info {
        padding: 6px;
        gap: 2px;
    }
    .bingo-my-header .buddy-avatar {
        width: 32px;
        height: 32px;
        margin-bottom: 0;
        bottom: 0;
    }
    .bingo-my-name {
        font-size: 13px;
    }
    .bingo-ball {
        width: 64px;
        height: 64px;
        font-size: 20px;
    }
    .bingo-called-num {
        width: 18px;
    }

    // Mobile: condense all other players into a single wrapping row of compact
    // tiles across the top (the JS places everyone in #bingo-other-top here).
    .bingo-play-area {
        flex-direction: column;
        align-items: stretch;
        margin-top: 6px;
    }
    #bingo-my-info-row {
        margin-top: 6px;
    }
    .bingo-side-col {
        display: none;
    }
    #bingo-other-top {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        gap: 5px;
        margin-top: 4px;
    }

    // compact avatar + name tile; tap to reveal that player's mini card beneath it
    .bingo-other-player {
        width: 72px;
        min-width: 0;
        max-width: none;
        margin: 0;
        padding: 4px;
        gap: 1px;
        cursor: pointer;
    }
    .bingo-other-header {
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 2px;
        cursor: pointer;
    }
    .bingo-other-player .buddy-avatar {
        width: 30px;
        height: 30px;
        margin-bottom: 0;
        bottom: 0;
    }
    .bingo-other-meta {
        flex: 0 0 auto;
        width: 100%;
        text-align: center;
    }
    .bingo-other-name {
        font-size: 11px;
        max-width: 100%;
    }
    .bingo-other-status {
        font-size: 10px;
    }
    .bingo-expand-caret {
        display: none;
    }

    // The seasonal theme corner decorations are 50px and would swamp these small
    // tiles, so hide them here (the box-shadow highlight is unaffected).
    .bingo-other-player::before,
    .bingo-other-player::after {
        display: none !important;
    }

    .bingo-other-player .bingo-mini-card {
        display: none;
    }
    .bingo-other-player.expanded {
        width: auto;
    }
    .bingo-other-player.expanded .bingo-mini-card {
        display: inline-block;
    }
    .bingo-mini-cell {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
}
