/* === Custom Properties === */
:root {
    --tile-size: 20px;
    --bg-primary: #2b2d30;
    --bg-surface: #1e1f22;
    --text-primary: #dcdcdc;
    --text-secondary: #9a9a9a;
    --border-subtle: #444;
}

/* === Base === */
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

h1:focus {
    outline: none;
}

/* === Game Page Layout === */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100dvh;
    padding: 8px 8px 4px;
    box-sizing: border-box;
}

.game-title {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* === Score Bar === */
.score-bar {
    display: flex;
    gap: 24px;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
}

.score-label {
    color: var(--text-primary);
}

/* === Toolbar === */
.toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.toolbar-btn {
    background-color: #555;
    color: var(--text-primary);
    border: 1px solid #777;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 3px;
    min-height: 36px;
    min-width: 44px;
}

.toolbar-btn:hover:not(:disabled) {
    background-color: #666;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* === Game Board === */
.board-container {
    position: relative;
    background-color: var(--bg-surface);
    padding: 2px;
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    flex: 0 0 auto;
}

.game-board {
    position: relative;
}

/* === Brick Cell === */
.brick-cell {
    position: absolute;
    width: var(--tile-size);
    height: var(--tile-size);
    opacity: 0.8;
    cursor: pointer;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease, bottom 0.3s ease, opacity 0.1s ease;
}

.brick-cell.removing {
    animation: brick-remove 0.3s ease forwards;
}

@keyframes brick-remove {
    0%   { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.brick-cell.highlighted {
    opacity: 1.0;
    filter: brightness(1.3);
}

.brick-cell.hl-border-top    { border-top:    2px solid rgba(255,255,255,0.9); }
.brick-cell.hl-border-bottom { border-bottom: 2px solid rgba(255,255,255,0.9); }
.brick-cell.hl-border-left   { border-left:   2px solid rgba(255,255,255,0.9); }
.brick-cell.hl-border-right  { border-right:  2px solid rgba(255,255,255,0.9); }

.brick-cell.highlighted {
    animation: glow-pulse 1.2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 3px 1px rgba(255,255,255,0.3); }
    50%      { box-shadow: 0 0 8px 3px rgba(255,255,255,0.7); }
}

.brick-red { background-color: #e74c3c; }
.brick-blue { background-color: #3498db; }
.brick-green { background-color: #2ecc71; }
.brick-yellow { background-color: #f1c40f; }

/* === Overlay Panels === */
.overlay-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(30, 31, 34, 0.96);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 16px;
    z-index: 10;
    min-width: 240px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
}

/* === High Scores Table === */
.scores-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.85rem;
}

.scores-table th,
.scores-table td {
    padding: 3px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.scores-table th {
    color: var(--text-secondary);
}

/* === Submit Score Form === */
.form-group {
    margin: 8px 0;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.score-input {
    width: 100%;
    padding: 4px 6px;
    background-color: #333;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
}

/* === Game Over Panel === */
.game-over-panel {
    padding: 20px;
}

/* === Media Queries === */
@media (max-width: 768px) {
    .game-container {
        gap: 6px;
        padding: 6px 4px 2px;
    }

    .score-bar {
        gap: 16px;
    }

    .toolbar {
        gap: 4px;
    }

    .toolbar-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .game-container {
        gap: 4px;
        padding: 4px 2px 2px;
    }

    .score-bar {
        gap: 10px;
        font-size: 0.78rem;
    }

    .toolbar-btn {
        padding: 3px 6px;
        font-size: 0.75rem;
        min-width: 38px;
    }

    .overlay-panel {
        min-width: 200px;
        padding: 12px;
    }
}

/* === Loading / Error (from template) === */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #333;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}
