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

/* --- Palette / theme vars -------------------------------------------------- */
:root {
    --sd-bg: #020617;
    --sd-panel: #0b1222;
    --sd-line: rgba(255, 255, 255, 0.08);
    --sd-text: #e5e7eb;
    --sd-muted: rgba(255, 255, 255, 0.55);
    --sd-accent: #6ea8fe;
    --sd-good: #86efac;
    --sd-warn: #fde68a;
    --sd-danger: #f87171;
    --radius: 0.6rem;
}

/* --- Settings row ------------------------------------------------------- */
#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;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark, #111827);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

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

/* --- Game container ------------------------------------------------------ */
#game-container {
    position: relative;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background: var(--darker, #020617);
    border-radius: var(--radius, 0.6rem);
    padding: 0.85rem 0.65rem;
}

/* --- HUD ------------------------------------------------------------------ */
.hud {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hud-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem 0.75rem;
    width: 100%;
    padding: 0.15rem 0.35rem;
}

.hud-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    line-height: 1.15;
}

.hud-block>strong {
    color: var(--sd-text);
}

.score-block {
    align-items: flex-start;
}

.hints-block {
    align-items: flex-end;
}

.status-block {
    align-items: center;
    text-align: center;
    min-width: 0;
}

.round-label {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-weight: 800;
    color: #fff;
    font-size: 1rem;
}

.theme-label {
    color: #93c5fd;
    font-size: 0.72rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 28rem;
}

#status {
    font-weight: bold;
    font-size: 0.85rem;
    color: #fff;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-bar {
    width: 140px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
}

.time-fill {
    height: 100%;
    width: 100%;
    background: #22c55e;
    transition: width 0.2s linear, background 0.2s ease;
}

.time-fill.warn {
    background: #f59e0b;
}

.time-fill.danger {
    background: #ef4444;
    animation: timeUrgent 0.6s ease-in-out infinite;
}

@keyframes timeUrgent {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.55;
    }
}

.time-text,
.score-count {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.85);
}

.hud-subrow {
    grid-template-columns: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 0.6rem;
}

.hud-chip {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.found-chip {
    border-color: rgba(134, 239, 172, 0.25);
}

.combo-chip {
    border-color: rgba(251, 191, 36, 0.25);
}

.hints-chip {
    border-color: rgba(103, 232, 249, 0.2);
}

/* --- Event log -------------------------------------------------------------- */
.log-panel {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    height: 96px;
    min-height: 96px;
    max-height: 96px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-anchor: none;
    scrollbar-gutter: stable;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius, 0.6rem);
    padding: 0.45rem 0.7rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.45;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 5px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 5px);
}

.log-panel div {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
    padding: 0.1rem 0;
}

.log-panel div:last-child {
    border-bottom: none;
    color: #fff;
}

.log-entry-loot {
    color: #fde68a;
}

.log-entry-good {
    color: #86efac;
}

.log-entry-danger {
    color: #f87171;
    font-weight: 700;
}

/* --- Scene boards ------------------------------------------------------------ */
#scene-wrap {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.25rem;
}

.scene-board {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius, 0.6rem);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.35);
    cursor: crosshair;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.scene-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.65);
}

.diff-found-mark .diff-ring {
    fill: none;
    stroke: #4ade80;
    stroke-width: 2.5;
    stroke-dasharray: 5 4;
    animation: ringSpin 6s linear infinite;
    pointer-events: none;
}

@keyframes ringSpin {
    to {
        stroke-dashoffset: -40;
    }
}

.diff-found-mark .diff-check {
    fill: none;
    stroke: #4ade80;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.diff-miss-mark {
    pointer-events: none;
    animation: missFade 0.55s ease forwards;
}

.diff-miss-mark line {
    stroke: #f87171;
    stroke-width: 3;
    stroke-linecap: round;
}

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

    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

.diff-hint-mark {
    pointer-events: none;
}

.diff-hint-mark circle {
    fill: none;
    stroke: #67e8f9;
    stroke-width: 3;
    animation: hintPulse 0.9s ease-in-out infinite;
}

@keyframes hintPulse {

    0%,
    100% {
        opacity: 0.35;
        stroke-width: 2;
    }

    50% {
        opacity: 1;
        stroke-width: 4;
    }
}

/* --- Actions ------------------------------------------------------------- */
.board-actions {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

/* --- Overlay --------------------------------------------------------------- */
.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, 0.6rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    text-align: center;
    padding: 1rem;
    z-index: 10;
}

.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.5rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.game-over-detail {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
    white-space: pre-line;
}

.game-over-hint {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.65);
}

.game-over-hint strong {
    color: #fff;
}

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

    50% {
        transform: scale(1.1);
    }

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

.key-hint {
    display: block;
    font-size: 0.68rem;
    color: inherit;
    margin: 0.15rem 0 0;
    letter-spacing: 0.03em;
}

/* --- Panel sizing ----------------- */
#game-panel {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    padding: 0.85rem 1rem;
    margin-top: 1rem;
}

#game-panel .panel-head {
    margin-bottom: 0.5rem;
    align-items: center;
}

/* --- Responsive ------------------------------------------------------------- */
@media (max-width: 768px) {
    #game-settings {
        gap: 0.75rem 1.25rem;
    }

    .hud-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "score hints" "status status";
    }

    .score-block {
        grid-area: score;
    }

    .hints-block {
        grid-area: hints;
    }

    .status-block {
        grid-area: status;
    }

    #scene-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        justify-items: center;
    }

    .scene-divider {
        transform: rotate(90deg);
        width: 2rem;
        height: 2rem;
        font-size: 0.9rem;
    }

    .time-bar {
        width: 110px;
    }
}

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

    .theme-label {
        max-width: 12rem;
    }

    .board-actions .btn {
        font-size: 0.85rem;
        padding: 0.45rem 0.8rem;
    }
}