/* 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-head h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

#game-settings {
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    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: 600;
    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: 125px;
}

.btn-small {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

#legend {
    max-width: 680px;
    margin: 0 auto 1.25rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    font-size: 0.78rem;
    line-height: 1.4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 1rem;
}

#legend .legend-row {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
}

#legend dt {
    flex: 0 0 5.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.67rem;
}

#legend dd {
    margin: 0;
    color: var(--dark);
}

.legend-swatch {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    flex: 0 0 auto;
}

.swatch-mirror {
    background: linear-gradient(135deg, transparent 42%, var(--accent) 42%, var(--accent) 58%, transparent 58%);
    border: 1px solid rgba(6, 182, 212, 0.5);
}

.swatch-mirror-fixed {
    background: linear-gradient(135deg, transparent 42%, #94a3b8 42%, #94a3b8 58%, transparent 58%);
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.swatch-wall {
    background: repeating-linear-gradient(45deg,
            rgba(0, 0, 0, 0.35),
            rgba(0, 0, 0, 0.35) 2px,
            rgba(0, 0, 0, 0.15) 2px,
            rgba(0, 0, 0, 0.15) 4px);
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.swatch-splitter {
    background: linear-gradient(90deg, transparent 38%, #a78bfa 38%, #a78bfa 62%, transparent 62%),
        linear-gradient(45deg, transparent 43%, #c4b5fd 43%, #c4b5fd 57%, transparent 57%);
    border: 1px solid rgba(167, 139, 250, 0.55);
}

.swatch-portal {
    background: radial-gradient(circle, #111827 31%, #f472b6 33%, #f472b6 50%, #111827 52%);
    border: 1px solid rgba(244, 114, 182, 0.65);
}

.swatch-target {
    background: radial-gradient(circle, #4ade80 0 25%, transparent 27% 100%);
    border: 2px solid rgba(74, 222, 128, 0.7);
}

#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.9rem 0.7rem 1rem;
    overflow: hidden;
}

.game-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        "moves status time"
        "mini mini mini";
    align-items: center;
    width: 100%;
    gap: 0.4rem 0.75rem;
    padding: 0.15rem 0.45rem 0.1rem;
}

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

.moves-stat {
    grid-area: moves;
    align-items: flex-start;
}

.time-stat {
    grid-area: time;
    align-items: flex-end;
}

.stat-block strong {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.68rem;
    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;
    color: var(--accent);
}

.stat-block .meta {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.03em;
}

.status-block {
    grid-area: status;
    justify-self: center;
    min-width: 0;
}

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

#status.blocked-message {
    color: #ef4444;
}

#status.lost-message {
    color: #fbbf24;
}

#status.win-message {
    color: #4ade80;
}

#status.limit-message {
    color: #fb7185;
}

.mini-stats {
    grid-area: mini;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    color: rgba(255, 255, 255, 0.5);
    font: 600 0.68rem/1 var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Puzzle counter sits first in the mini-stats row and is visually distinct. */
#level-counter {
    color: rgba(6, 182, 212, 0.85);
}

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

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

.cell-bg {
    fill: rgba(255, 255, 255, 0.045);
    stroke: rgba(255, 255, 255, 0.075);
    stroke-width: 1;
}

.cell-bg:hover {
    fill: rgba(255, 255, 255, 0.065);
}

.cell-wall {
    fill: rgba(0, 0, 0, 0.5);
}

.cell-wall-hatch {
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 2;
}

.cell-hit {
    fill: transparent;
    cursor: pointer;
}

.cell-hit.static {
    cursor: default;
}

.mirror-line {
    stroke: var(--accent);
    stroke-width: 5;
    stroke-linecap: round;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

g.mirror-group:hover .mirror-line {
    opacity: 0.72;
}

.g.mirror-group {
    transform-box: fill-box;
    transform-origin: center;
}

.mirror-group.fixed .mirror-line {
    stroke: #94a3b8;
    filter: drop-shadow(0 0 3px rgba(148, 163, 184, 0.4));
}

.mirror-group.fixed .cell-hit {
    cursor: not-allowed;
}

.mirror-lock {
    fill: #94a3b8;
    stroke: rgba(0, 0, 0, 0.4);
    stroke-width: 0.75;
    pointer-events: none;
}

.source-shape {
    fill: #ffd166;
    stroke: rgba(0, 0, 0, 0.3);
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(255, 209, 102, 0.3));
}

.target-ring {
    fill: none;
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 4;
    transition: stroke 0.25s ease, filter 0.25s ease;
}

.target-ring.lit {
    stroke: #4ade80;
    filter: drop-shadow(0 0 7px rgba(74, 222, 128, 0.95));
}

.target-dot {
    fill: rgba(255, 255, 255, 0.36);
    transition: fill 0.25s ease;
}

.target-dot.lit {
    fill: #4ade80;
}

.splitter-body {
    fill: rgba(167, 139, 250, 0.2);
    stroke: #a78bfa;
    stroke-width: 2;
}

.splitter-ray {
    stroke: #c4b5fd;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.portal-ring {
    fill: rgba(244, 114, 182, 0.12);
    stroke: #f472b6;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 4px rgba(244, 114, 182, 0.6));
}

.portal-core {
    fill: #111827;
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 1;
}

.portal-label {
    fill: #f9a8d4;
    font: 700 9px var(--font-mono);
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.beam-path {
    fill: none;
    stroke: #06b6d4;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 5px rgba(6, 182, 212, 0.85));
    transition: stroke 0.2s ease, filter 0.2s ease;
}

.beam-path.blocked {
    stroke: #ef4444;
    filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.85));
}

.beam-path.hit {
    stroke: #4ade80;
    filter: drop-shadow(0 0 6px rgba(74, 222, 128, 0.95));
}

.beam-path.lost {
    stroke: #f59e0b;
    filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.7));
}

.action-row {
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    flex-wrap: wrap;
}

.game-over-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    border-radius: var(--radius);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-align: center;
    padding: 1rem;
    z-index: 2;
    backdrop-filter: blur(3px);
}

.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;
    max-width: 360px;
}

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

.game-over-detail {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.25rem;
}

.star-row {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    font-size: 2rem;
    line-height: 1;
    margin: 0.1rem 0 0.3rem;
}

.star {
    color: rgba(255, 255, 255, 0.18);
    transition: color 0.2s ease;
}

.star.filled {
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.75);
    animation: star-pop 0.5s ease both;
}

@keyframes star-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.25);
        opacity: 1;
    }

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

.game-over-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.game-over-actions .btn[hidden] {
    display: none;
}

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

    50% {
        transform: scale(1.05);
    }

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

@media (max-width: 768px) {
    #legend {
        grid-template-columns: 1fr;
    }

    #game-settings {
        gap: 0.65rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 1rem;
    }

    #game-container {
        padding: 0.65rem 0.45rem 0.8rem;
    }

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

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

    #legend {
        font-size: 0.74rem;
        padding: 0.65rem 0.8rem;
    }

    #legend .legend-row {
        flex-direction: column;
        gap: 0.08rem;
    }

    #legend dt {
        flex: none;
    }

    .star-row {
        font-size: 1.75rem;
    }
}

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

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

    #status {
        white-space: normal;
    }

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