/* Copyright (c) 2024-2026 Jericho Crosby (Chalwk). All Rights Reserved. */

.panel {
    background: var(--light);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 2rem;
}

/* ---------------------------------------------------------------------------
   Panel header
   --------------------------------------------------------------------------- */
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.panel-head h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.panel-head-text {
    min-width: 0;
}

.icon-btn {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--gray-light);
    background: #fff;
    color: var(--dark);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.icon-btn:hover {
    transform: scale(1.08);
}

.icon-btn:active {
    transform: scale(0.96);
}

.icon-btn.muted {
    background: #e5e7eb;
    opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   Controls
   --------------------------------------------------------------------------- */
#mode-selection {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

#game-settings {
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
}

#game-settings label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

#game-settings select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    background: white;
    color: var(--dark);
    font-family: var(--font-primary);
    min-width: 120px;
}

#difficulty-label.hidden {
    display: none !important;
}

#game-container {
    position: relative;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background: var(--darker);
    border-radius: var(--radius);
    padding: 0.75rem 0.5rem;
}

.board-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
}

#game-board {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------------------
   Board
   --------------------------------------------------------------------------- */
.fr-board-bg {
    fill: var(--primary);
}

.fr-hole {
    fill: var(--darker);
}

.fr-disc {
    fill: transparent;
    transform-box: fill-box;
    transform-origin: center;
    pointer-events: none;
}

.fr-disc.owner-1 {
    fill: #ef4444;
    animation: discDrop 0.35s ease-out;
}

.fr-disc.owner-2 {
    fill: #4ade80;
    animation: discDrop 0.35s ease-out;
}

.fr-disc.winning {
    stroke: #ffffff;
    stroke-width: 2.5;
    animation:
        discDrop 0.35s ease-out,
        winPulse 0.55s ease-in-out 0.4s infinite alternate;
}

.fr-preview {
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.fr-preview.visible {
    opacity: 0.4;
}

.fr-last-move {
    fill: none;
    stroke-width: 2.5;
    stroke-dasharray: 5 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fr-last-move.visible {
    opacity: 1;
}

.fr-last-move.owner-1 {
    stroke: #fecaca;
}

.fr-last-move.owner-2 {
    stroke: #bbf7d0;
}

.fr-column-hit {
    fill: transparent;
    cursor: pointer;
}

@keyframes discDrop {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }

    70% {
        transform: scale(1.08);
    }

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

@keyframes winPulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.12);
    }
}

/* ---------------------------------------------------------------------------
   Score / status bar
   --------------------------------------------------------------------------- */
.game-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "p1 status p2";
    align-items: center;
    width: 100%;
    gap: 0.5rem 0.75rem;
    padding: 0.25rem 0.5rem;
}

.stat-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.1;
}

.stat-block.player1 {
    grid-area: p1;
    align-items: flex-start;
}

.stat-block.player2 {
    grid-area: p2;
    align-items: flex-end;
}

.stat-block strong {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-block .score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.2rem;
}

.score-player-1 {
    color: #ef4444;
}

.score-player-2 {
    color: #4ade80;
}

.status-block {
    grid-area: status;
    justify-self: center;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#status {
    font-weight: bold;
    font-size: 0.95rem;
    text-align: center;
    color: #fff;
    white-space: nowrap;
}

.win-message {
    color: var(--warning);
    font-size: 1.2rem;
    animation: celebrate 0.5s ease;
}

.tie-message {
    color: var(--gray);
}

/* Turn timer bar */
.timer-bar {
    height: 4px;
    width: 100%;
    min-width: 130px;
    max-width: 200px;
    margin: 6px auto 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.timer-bar.active {
    opacity: 1;
}

#timer-fill {
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: #4ade80;
    transition: width 0.12s linear, background 0.25s ease;
}

#timer-fill.ok {
    background: #4ade80;
}

#timer-fill.warn {
    background: #facc15;
}

#timer-fill.danger {
    background: #ef4444;
}

/* ---------------------------------------------------------------------------
   Game over overlay
   --------------------------------------------------------------------------- */
.game-over-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    text-align: center;
    padding: 1rem;
}

.game-over-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.game-over-content {
    animation: celebrate 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.game-over-message {
    color: #fff;
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.game-over-score {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
}

@keyframes celebrate {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

/* ---------------------------------------------------------------------------
   Bottom controls, record, hints
   --------------------------------------------------------------------------- */
.controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.record {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.key-hint {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.32);
    text-align: center;
    margin: 0;
    letter-spacing: 0.03em;
}

/* ---------------------------------------------------------------------------
   Confetti canvas
   --------------------------------------------------------------------------- */
#confetti {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    #game-settings {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem 1.25rem;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 0.5rem;
    }

    #game-settings {
        gap: 0.5rem 0.75rem;
    }

    #game-settings label {
        font-size: 0.8rem;
        gap: 0.35rem;
    }

    #game-settings select {
        min-width: 0;
        padding: 0.4rem 0.5rem;
        font-size: 0.85rem;
    }

    .key-hint {
        display: none;
    }
}

@media (max-width: 420px) {
    .game-stats {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "p1 p2"
            "status status";
    }

    .status-block {
        margin-top: 0.15rem;
    }

    .game-over-message {
        font-size: 1.3rem;
    }
}