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

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

#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.85rem 0.65rem;
}

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

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

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

.hud-block strong {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hp-bar {
    width: 100px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

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

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

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

.hp-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.75);
}

.gold-count {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.05rem;
    color: #fbbf24;
}

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

.floor-label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    color: #7ee7c7;
    letter-spacing: 0.03em;
}

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

.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);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.key-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
}

.key-dot-red.active {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
}

.key-dot-gold.active {
    background: #fbbf24;
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.9);
}

.log-panel {
    width: 100%;
    max-width: 100%;
    max-height: 96px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius);
    padding: 0.45rem 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.45;
}

.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-combat {
    color: #fca5a5;
}

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

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

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

.board-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0.25rem;
    overflow: auto;
}

.dungeon-board {
    display: grid;
    gap: 1px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px;
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04),
        0 10px 30px rgba(0, 0, 0, 0.35);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    position: relative;
    font-size: calc(var(--cell-size) * 0.62);
    line-height: 1;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cell.wall {
    background: linear-gradient(180deg, #26324a, #182236);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.cell.floor {
    background: #0d1830;
}

.cell.door {
    background: #3b2a17;
    color: #d9a86b;
}

.cell.door-red {
    background: #3a1414;
    color: #f87171;
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.55);
}

.cell.door-gold {
    background: #3a2f10;
    color: #facc15;
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.55);
}

.cell.secret-hint {
    animation: secretShimmer 2.4s ease-in-out infinite;
}

@keyframes secretShimmer {

    0%,
    100% {
        box-shadow: none;
    }

    50% {
        box-shadow: inset 0 0 8px rgba(126, 231, 199, 0.55);
    }
}

.cell.stairs {
    background: radial-gradient(circle, #3a2f10, #1e1a0c);
    color: #fbbf24;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
    animation: stairsPulse 1.6s ease-in-out infinite;
}

@keyframes stairsPulse {

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

    50% {
        transform: scale(1.1);
    }
}

.cell.dim {
    filter: brightness(0.45) saturate(0.7);
}

.cell.dim .entity-icon {
    display: none;
}

.cell.fogged {
    background: #020617 !important;
    box-shadow: none !important;
    color: transparent !important;
}

.cell.player-cell::before {
    content: '';
    position: absolute;
    inset: 14%;
    border-radius: 50%;
    background: radial-gradient(circle, #6ea8fe, #2563eb);
    box-shadow: 0 0 10px rgba(110, 168, 254, 0.9);
    animation: playerPulse 1.3s ease-in-out infinite;
    z-index: 2;
}

@keyframes playerPulse {

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

    50% {
        transform: scale(1.12);
    }
}

.cell.enemy-cell {
    background: rgba(239, 68, 68, 0.08);
}

.cell.enemy-cell.elite {
    box-shadow: inset 0 0 0 2px rgba(250, 204, 21, 0.75);
}

.cell.enemy-cell.hit-flash {
    animation: hitFlash 0.3s ease;
}

@keyframes hitFlash {
    0% {
        background: rgba(255, 255, 255, 0.85);
    }

    100% {
        background: rgba(239, 68, 68, 0.08);
    }
}

.cell.item-gold {
    color: #fbbf24;
}

.cell.item-potion {
    color: #4ade80;
}

.cell.item-key-red {
    box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.75);
}

.cell.item-key-gold {
    box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.75);
}

.cell.item-weapon {
    color: #cbd5e1;
}

.cell.item-secret {
    color: #67e8f9;
}

.cell.player-hit {
    animation: playerShake 0.35s ease;
}

@keyframes playerShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

.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;
    z-index: 3;
}

.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);
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
    white-space: pre-line;
}

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

    50% {
        transform: scale(1.1);
    }

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

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

.dpad {
    display: none;
}

.dpad-row {
    display: flex;
    gap: 0.5rem;
}

.dpad-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dpad-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.dpad-btn:active {
    transform: translateY(1px);
    background: var(--accent);
}

@media (hover: none) and (pointer: coarse) {
    .dpad {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.15rem;
        user-select: none;
        -webkit-user-select: none;
    }
}

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

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

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

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

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

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

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

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

    .hp-bar {
        width: 80px;
    }

    .log-panel {
        max-height: 72px;
        font-size: 0.68rem;
    }

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

    .dpad-btn {
        width: 52px;
        height: 52px;
    }

    .key-hint {
        display: none;
    }
}