/* 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.85rem;
    background: var(--darker);
    border-radius: var(--radius);
    padding: 1rem 0.75rem;
}

/* ---------------------------------------------------------------------------
   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;
}

#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);
}

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

    50% {
        transform: scale(1.1);
    }

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

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

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

.cc-board-bg {
    fill: var(--primary);
}

.cc-cell.light {
    fill: rgba(255, 255, 255, 0.08);
}

.cc-cell.dark {
    fill: rgba(255, 255, 255, 0.035);
}

.cc-num {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    fill: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* Ladders */
.cc-ladder line {
    stroke: #22c55e;
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0.85;
}

/* Snakes */
.cc-snake path {
    stroke: #ef4444;
    stroke-width: 5;
    stroke-linecap: round;
    opacity: 0.8;
    fill: none;
}

.cc-snake circle {
    fill: #ef4444;
    opacity: 0.95;
}

/* Power tiles */
.cc-power-tile circle {
    fill: rgba(251, 191, 36, 0.22);
    stroke: #fbbf24;
    stroke-width: 1.5;
}

.cc-power-tile text {
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Player tokens */
.cc-token {
    transition: transform 0.18s ease;
}

.cc-token circle {
    stroke: #ffffff;
    stroke-width: 2;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.cc-token.token-1 circle {
    fill: #ef4444;
}

.cc-token.token-2 circle {
    fill: #4ade80;
}

.cc-token text {
    fill: #ffffff;
    font-family: var(--font-mono);
    font-weight: 800;
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Dice tray + power row
   --------------------------------------------------------------------------- */
.tray {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.tray-dice {
    display: flex;
    gap: 0.75rem;
}

.die {
    width: 3rem;
    height: 3rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
    font-family: var(--font-primary);
    padding: 0;
}

.die:hover:not(.disabled) {
    background: var(--accent);
    transform: translateY(-2px);
}

.die.rolled {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.6);
}

.die.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tray-powers {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 2.2rem;
}

.tray-powers.empty {
    min-height: 0;
}

.power-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.15);
    color: #fde68a;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.power-btn:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.3);
    transform: translateY(-1px);
}

.power-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.power-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.power-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.8;
}

/* ---------------------------------------------------------------------------
   Note bar
   --------------------------------------------------------------------------- */
.note-bar {
    min-height: 1.4rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #bfdbfe;
    text-align: center;
    letter-spacing: 0.02em;
    transition: opacity 0.2s ease;
}

.note-bar:empty {
    opacity: 0;
}

.note-bar.pulse {
    animation: notePulse 0.5s ease;
}

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

    50% {
        transform: scale(1.08);
        color: #fbbf24;
    }

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

/* ---------------------------------------------------------------------------
   Bottom controls
   --------------------------------------------------------------------------- */
.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;
}

/* ---------------------------------------------------------------------------
   Game over overlay
   --------------------------------------------------------------------------- */
.game-over-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    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;
}

/* ---------------------------------------------------------------------------
   Confetti
   --------------------------------------------------------------------------- */
#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;
    }

    .die {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.5rem;
    }

    .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;
    }
}