* {
    font-family: Helvetica, Arial, sans-serif;
}
html {
    background: #2E3440;
}
body {
    font-size: 14px;
    background: url('bg.jpg') no-repeat center center fixed;
    background-size: cover;
    color: #D8DEE9;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

#logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 10px;
}

#gameArea {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5em;
}
h1 {
    font-size: 1.5em;
    margin: 0 0 0.25em 0;
}
.fx-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.25em;
}
.fx-header h1 {
    margin-bottom: 0;
}
#canvas {
    z-index: 0;
}
#score,
#level {
    font-size: 2em;
}
#restartBtn {
    display: block;
    width: 100%;
    padding: 0.4em 0;
    background: #3B4252;
    color: #D8DEE9;
    border: none;
    border-bottom: 3px solid #1A1C23;
    border-radius: 4px;
    cursor: pointer;
    font-size: 2em;
    text-align: center;
    transition: background 0.15s, transform 0.1s;
    box-sizing: border-box;
}
#restartBtn:hover {
    background: #4C566A;
}
#restartBtn:active {
    border-bottom-width: 1px;
    transform: translateY(2px);
}
.containerBlock {
    background: rgba(46, 52, 64, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(76, 86, 106, 0.6);
    border-radius: 6px;
    margin-bottom: 1em;
    padding: 0.5em;
}
.containerBlock:after {
    content: "";
    display: table;
    clear: both;
}
#scoreContainer,
#levelContainer {
    width: 50%;
    float: left;
}
#author {
    font-size: 0.8em;
}
.sidebar {
    padding: 0 0.5em;
}
.cell {
    background: #3B4252;
    border: 2px solid #434C5E;
    width: 30px;
    height: 30px;
    float: left;
    opacity: 0.95;
    filter: blur(0.5px);
}
.cell.full {
    background-color: #4C566A;
    border-color: #3B4252;
}

@keyframes rectZoom {
    0% {
        transform: scaleY(0.5) scaleX(0.8);
        opacity: 1;
    }
    50% {
        transform: scaleY(1.2) scaleX(1.05);
        opacity: 0.6;
    }
    100% {
        transform: scaleY(2) scaleX(1.15);
        opacity: 0;
    }
}

.clear-rect {
    position: absolute;
    border-radius: 4px;
    background: linear-gradient(180deg, #A3BE8C, #2E7D32);
    box-shadow:
        0 0 30px rgba(46, 125, 50, 0.9),
        0 0 60px rgba(46, 125, 50, 0.4);
    pointer-events: none;
    z-index: 10;
    animation: rectZoom 0.3s ease-out forwards;
}
.clear-rect-red {
    position: absolute;
    border-radius: 4px;
    background: linear-gradient(180deg, #BF616A, #8f4350);
    box-shadow:
        0 0 30px rgba(191, 97, 106, 0.9),
        0 0 60px rgba(191, 97, 106, 0.4);
    pointer-events: none;
    z-index: 10;
    animation: rectZoom 0.3s ease-out forwards;
}
.cell.border-cell {
    background: #4C566A;
    border-color: #3B4252;
    box-shadow:
        inset 2px 2px 3px rgba(255,255,255,0.25),
        inset -2px -2px 3px rgba(0,0,0,0.35);
}
.cell.O,
.cell.T,
.cell.I,
.cell.J,
.cell.S {
    border: 2px solid #1A1C23;
    box-shadow:
        inset 4px 4px 8px rgba(255,255,255,0.6),
        inset -4px -4px 6px rgba(0,0,0,0.25),
        2px 2px 6px rgba(0,0,0,0.2);
}
.cell.O {
    background: linear-gradient(135deg, #fff5d6, #EBCB8B 50%, #c4a86a);
}
.cell.T {
    background: linear-gradient(135deg, #f5a5ad, #BF616A 50%, #8f4350);
}
.cell.J {
    background: linear-gradient(135deg, #c0def5, #81A1C1 50%, #5f7e9e);
}
.cell.I {
    background: linear-gradient(135deg, #c0ecf5, #88C0D0 50%, #5f9eae);
}
.cell.S {
    background: linear-gradient(135deg, #daf0c5, #A3BE8C 50%, #7da06a);
}
.adjacent-cell {
    background: #5E81AC;
}
.row {
    clear: both;
}
#canvasContainer {
    position: relative;
}
#osd {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    color: #A3BE8C;
    font-size: 6.75em;
    font-weight: 900;
    font-family: 'Orbitron', Helvetica, Arial, sans-serif;
    text-shadow:
        2px 2px 0 #000,
        -2px 2px 0 #000,
        2px -2px 0 #000,
        -2px -2px 0 #000,
        2px 0 0 #000,
        -2px 0 0 #000,
        0 2px 0 #000,
        0 -2px 0 #000;
    pointer-events: none;
    display: none;
    white-space: nowrap;
}

@keyframes osdZoomIn {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

#osd.show {
    display: block;
    animation: osdZoomIn 1.2s ease-out forwards;
}

#canvasOverlay {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10;
    width: 100%;
    height: 100%;
    background: rgba(46, 52, 64, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
}
#canvasOverlayText {
    color: #A3BE8C;
    font-size: 6.75em;
    font-weight: 900;
    font-family: 'Orbitron', Helvetica, Arial, sans-serif;
    text-shadow:
        2px 2px 0 #000,
        -2px 2px 0 #000,
        2px -2px 0 #000,
        -2px -2px 0 #000,
        2px 0 0 #000,
        -2px 0 0 #000,
        0 2px 0 #000,
        0 -2px 0 #000;
}
#canvasOverlayText.show {
    animation: overlayZoomIn 0.4s ease-out forwards;
}
@keyframes overlayZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}
#canvasOverlayText.hide {
    animation: overlayZoomOut 0.3s ease-in forwards;
}
@keyframes overlayZoomOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}
#canvasOverlayText.gameover-text {
    color: #A3BE8C;
    font-size: 6.75em;
    font-weight: 900;
    font-family: 'Orbitron', Helvetica, Arial, sans-serif;
    text-shadow:
        2px 2px 0 #000,
        -2px 2px 0 #000,
        2px -2px 0 #000,
        -2px -2px 0 #000,
        2px 0 0 #000,
        -2px 0 0 #000,
        0 2px 0 #000,
        0 -2px 0 #000;
}
#newGameBtn {
    display: none;
    margin-top: 1em;
    padding: 0.4em 1em;
    background: #5E81AC;
    color: #D8DEE9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    font-family: Helvetica, Arial, sans-serif;
    transition: background 0.15s;
}
#newGameBtn:hover {
    background: #81A1C1;
}

.cell.afterglow-glow {
    opacity: 0.5;
    animation: afterglowFade 0.2s ease-out forwards;
    pointer-events: none;
    position: absolute;
    float: none;
    margin: 0;
}

@keyframes afterglowFade {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.08); }
}

@keyframes afterglowSmoke {
    0% { opacity: 0.6; transform: translateY(0) translateX(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) translateX(var(--smoke-x, 0)) scale(1.35); }
}

@keyframes afterglowPulse {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0; transform: scale(2); }
}

@keyframes afterglowSmokePulse {
    0% { opacity: 0.7; transform: translateY(0) translateX(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) translateX(var(--smoke-x, 0)) scale(2); }
}

.cell.afterglow-glow.wireframe {
    background: transparent !important;
    box-shadow: 0 0 5px rgba(216, 222, 233, 0.3) !important;
    border-color: rgba(216, 222, 233, 0.6) !important;
}

.fader-group {
    margin: 0.5em 0;
}
.fader-group label {
    display: block;
    font-size: 0.85em;
    margin-bottom: 0.25em;
    color: #D8DEE9;
}
.fader-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.fader-val {
    color: #A3BE8C;
    font-weight: bold;
    font-size: 0.85em;
    min-width: 2.5em;
    text-align: right;
}

input[type="range"].knob {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: #4C566A;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
input[type="range"].knob::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #D8DEE9, #81A1C1);
    border: 2px solid #5E81AC;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(94, 129, 172, 0.4);
    transition: box-shadow 0.15s;
}
input[type="range"].knob::-webkit-slider-thumb:hover {
    box-shadow: 0 0 12px rgba(94, 129, 172, 0.7);
}
input[type="range"].knob::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #D8DEE9, #81A1C1);
    border: 2px solid #5E81AC;
    cursor: pointer;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #4C566A;
    border-radius: 22px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    bottom: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #D8DEE9;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider {
    background: #4c566a;
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.control-row {
    font-size: 0.85em;
    margin: 0.3em 0;
    display: flex;
    align-items: center;
    gap: 0.4em;
}
.control-row kbd {
    display: inline-block;
    background: #3B4252;
    border: 1px solid #4C566A;
    border-radius: 3px;
    padding: 0.1em 0.5em;
    font-family: monospace;
    font-size: 0.9em;
    color: #D8DEE9;
    min-width: 1.5em;
    text-align: center;
}
