/* =========================================================
   Rubioverlay System - Tetris Display Mode CSS
   16x9 Mathematical Grid & Retro Arcade Styling
   Styleguide Colors:
   - Green: #63B22F
   - Dark Gray: #414141
   - Neon: #D9FF3D
   - Pink: #FF8EAB
   ========================================================= */

:root {
    --tetris-cols: 16;
    --tetris-rows: 9;
    --tetris-color-green: #63B22F;
    --tetris-color-neon: #D9FF3D;
    --tetris-color-pink: #FF8EAB;
    --tetris-color-cyan: #00f0ff;
    --tetris-color-orange: #ff9800;
    --tetris-color-purple: #b388ff;
    --tetris-color-blue: #2979ff;
    --tetris-color-dark: #12141c;
}

/* Tetris Fullscreen Grid Container */
.tetris-grid-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1000;
    box-sizing: border-box;
}

/* Optional Matrix Grid Guide Lines (Preview / Active) */
.tetris-grid-lines {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(9, 1fr);
    pointer-events: none;
    opacity: 0.15;
    z-index: 1;
}

.tetris-grid-cell-guide {
    border: 1px dashed rgba(255, 255, 255, 0.12);
    box-sizing: border-box;
}

/* Tetris Block Unit */
.tetris-block {
    position: absolute;
    box-sizing: border-box;
    padding: 3px;
    z-index: 10;
    pointer-events: auto;
    user-select: none;
    transition: left 0.1s cubic-bezier(0.2, 0.9, 0.3, 1),
                top 0.1s cubic-bezier(0.2, 0.9, 0.3, 1),
                width 0.12s ease-out,
                height 0.12s ease-out;
}

.tetris-block.active-falling {
    z-index: 20;
    filter: drop-shadow(0 0 12px rgba(217, 255, 61, 0.45));
}

.tetris-block.locked {
    z-index: 10;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tetris-block.despawning {
    animation: tetrisBlockDissolve 0.6s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

/* Block Inner Box */
.tetris-block-inner {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    position: relative;
    overflow: hidden;
    background: rgba(18, 20, 28, 0.94);
    border: 2px solid var(--block-accent, var(--tetris-color-neon));
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6), 0 4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* Arcade Corner Bevels / Accent Bar */
.tetris-block-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--block-accent, var(--tetris-color-neon)), transparent);
    opacity: 0.9;
}

/* ORIENTATION: HORIZONTAL (3 Units Wide x 1 Unit High) */
.tetris-block.orientation-horizontal .tetris-block-inner {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.tetris-block.orientation-horizontal .tetris-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    max-width: 40%;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    padding-right: 8px;
}

.tetris-block.orientation-horizontal .tetris-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.25;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ORIENTATION: VERTICAL (1 Unit Wide x 3 Units High) */
.tetris-block.orientation-vertical .tetris-block-inner {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding: 10px 8px;
}

.tetris-block.orientation-vertical .tetris-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 6px;
    flex-shrink: 0;
}

.tetris-block.orientation-vertical .tetris-content {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    color: #ffffff;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tetris-block.orientation-vertical .tetris-content::-webkit-scrollbar {
    display: none;
}

/* Typography & Elements inside Block */
.tetris-badges {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.tetris-badges:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.tetris-badge {
    width: 17px;
    height: 17px;
    border-radius: 3px;
    object-fit: contain;
    vertical-align: middle;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.tetris-username {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--user-color, #D9FF3D);
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tetris-content img.emote-1x,
.tetris-content img.chat-emote {
    height: 22px;
    width: auto;
    vertical-align: middle;
    margin: 0 2px;
    display: inline-block;
}

/* Color Accent Variants for Blocks */
.tetris-block[data-color-scheme="green"] .tetris-block-inner {
    --block-accent: #63B22F;
    border-color: #63B22F;
    box-shadow: inset 0 0 10px rgba(99, 178, 47, 0.25), 0 0 14px rgba(99, 178, 47, 0.35);
}
.tetris-block[data-color-scheme="neon"] .tetris-block-inner {
    --block-accent: #D9FF3D;
    border-color: #D9FF3D;
    box-shadow: inset 0 0 10px rgba(217, 255, 61, 0.25), 0 0 14px rgba(217, 255, 61, 0.4);
}
.tetris-block[data-color-scheme="pink"] .tetris-block-inner {
    --block-accent: #FF8EAB;
    border-color: #FF8EAB;
    box-shadow: inset 0 0 10px rgba(255, 142, 171, 0.25), 0 0 14px rgba(255, 142, 171, 0.4);
}
.tetris-block[data-color-scheme="cyan"] .tetris-block-inner {
    --block-accent: #00f0ff;
    border-color: #00f0ff;
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.25), 0 0 14px rgba(0, 240, 255, 0.4);
}
.tetris-block[data-color-scheme="orange"] .tetris-block-inner {
    --block-accent: #ff9800;
    border-color: #ff9800;
    box-shadow: inset 0 0 10px rgba(255, 152, 0, 0.25), 0 0 14px rgba(255, 152, 0, 0.4);
}
.tetris-block[data-color-scheme="purple"] .tetris-block-inner {
    --block-accent: #b388ff;
    border-color: #b388ff;
    box-shadow: inset 0 0 10px rgba(179, 136, 255, 0.25), 0 0 14px rgba(179, 136, 255, 0.4);
}

/* Ghost / Landing Target Projection Block */
.tetris-ghost-block {
    position: absolute;
    box-sizing: border-box;
    padding: 3px;
    pointer-events: none;
    z-index: 5;
    transition: left 0.08s ease, top 0.08s ease, width 0.1s ease, height 0.1s ease;
}

.tetris-ghost-inner {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 2px dashed rgba(217, 255, 61, 0.4);
    background: rgba(217, 255, 61, 0.05);
    box-sizing: border-box;
}

/* Line Clear Flash Effect */
.tetris-line-flash-overlay {
    position: absolute;
    left: 0;
    width: 100%;
    height: calc(100% / 9);
    background: linear-gradient(90deg, rgba(217, 255, 61, 0.9), rgba(255, 255, 255, 1), rgba(0, 240, 255, 0.9));
    box-shadow: 0 0 35px #D9FF3D, 0 0 70px #00f0ff;
    z-index: 50;
    pointer-events: none;
    animation: tetrisLineClearFlash 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tetrisLineClearFlash {
    0% {
        opacity: 0;
        transform: scaleY(0.2);
    }
    30% {
        opacity: 1;
        transform: scaleY(1.2);
        filter: brightness(2);
    }
    100% {
        opacity: 0;
        transform: scaleY(0.1);
        filter: brightness(1);
    }
}

/* Dissolve / Despawn Animation */
@keyframes tetrisBlockDissolve {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.04);
        filter: brightness(1.6) drop-shadow(0 0 10px var(--tetris-color-pink));
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
        filter: brightness(0);
    }
}

/* Interactive Controller Bar in Chat Designer */
.tetris-designer-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: #181b26;
    border: 1px solid var(--border-color, #272a38);
    border-radius: 10px;
    margin-top: 12px;
    user-select: none;
}

.tetris-ctrl-btn {
    background: #222634;
    border: 1px solid #32384d;
    color: #f3f4f6;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.tetris-ctrl-btn:hover {
    background: var(--primary, #63B22F);
    color: #fff;
    border-color: var(--primary, #63B22F);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(99, 178, 47, 0.3);
}

.tetris-ctrl-btn:active {
    transform: translateY(1px);
}

.tetris-ctrl-btn.btn-accent {
    background: rgba(217, 255, 61, 0.15);
    border-color: #D9FF3D;
    color: #D9FF3D;
}
.tetris-ctrl-btn.btn-accent:hover {
    background: #D9FF3D;
    color: #12141c;
}

/* =========================================================
   Game Over Sequence & Retro Stacking Curtain Animation
   ========================================================= */
.tetris-gameover-curtain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 90;
}

.tetris-gameover-block {
    position: absolute;
    box-sizing: border-box;
    padding: 3px;
    z-index: 95;
    pointer-events: none;
}

.tetris-gameover-block-inner {
    width: 100%;
    height: 100%;
    background: #181a24;
    border: 2px solid #414141;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.6);
    position: relative;
    box-sizing: border-box;
}

.tetris-gameover-block-inner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #414141, #666666, transparent);
}

.tetris-gameover-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(18, 20, 28, 0.96);
    border: 3px solid #FF8EAB;
    box-shadow: 0 0 35px rgba(255, 142, 171, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.9);
    border-radius: 14px;
    padding: 20px 42px;
    text-align: center;
    color: #ffffff;
    z-index: 105;
    animation: tetrisGameOverPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tetris-gameover-banner-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: #FF8EAB;
    text-shadow: 0 0 14px rgba(255, 142, 171, 0.8), 2px 2px 0px #000;
    letter-spacing: 3px;
    margin-bottom: 8px;
    font-family: 'Press Start 2P', monospace, sans-serif;
}

.tetris-gameover-banner-sub {
    font-size: 0.95rem;
    font-weight: 700;
    color: #D9FF3D;
    text-shadow: 0 0 10px rgba(217, 255, 61, 0.7);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

@keyframes tetrisGameOverPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

