/* CuginiParty — Tetris */

.tetris-page {
    --tetris-ink: #18213f;
    --tetris-muted: #6d7693;
    --tetris-panel: rgba(255, 255, 255, .92);
    --tetris-line: rgba(59, 77, 132, .14);
    --tetris-well: #111936;
    --tetris-well-grid: rgba(154, 177, 239, .10);
    --tetris-accent: #6366f1;
    --tetris-blue: #3b82f6;
    min-height: 100svh;
    color: var(--tetris-ink);
    background:
        radial-gradient(circle at 12% 2%, rgba(99, 102, 241, .15), transparent 330px),
        radial-gradient(circle at 92% 26%, rgba(45, 185, 255, .12), transparent 360px),
        linear-gradient(145deg, #f7f9ff 0%, #eef3ff 100%);
}

.tetris-container {
    max-width: 1060px;
}

.tetris-topbar {
    margin-bottom: 12px;
}

.tetris-status {
    color: #4a5a94;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.tetris-status span:first-child {
    color: #28c76f;
    font-size: .9rem;
    text-shadow: 0 0 10px rgba(40, 199, 111, .45);
}

.tetris-header {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "mark title"
        "mark subtitle";
    align-items: center;
    column-gap: 16px;
    max-width: 520px;
    margin: 0 auto 20px;
    text-align: left;
}

.tetris-title-mark {
    grid-area: mark;
    width: 64px;
    height: 64px;
    display: grid;
    grid-template-columns: repeat(4, 12px);
    grid-template-rows: repeat(4, 12px);
    place-content: center;
    gap: 3px;
    border-radius: 19px;
    background: linear-gradient(135deg, #e6e8ff, #d7f0ff);
    box-shadow: 0 12px 25px rgba(58, 95, 194, .18), inset 0 1px 0 #fff;
    transform: rotate(-3deg);
}

.tetris-title-mark span {
    border-radius: 4px;
    box-shadow: inset 0 2px 2px rgba(255, 255, 255, .55), inset 0 -2px 2px rgba(0, 0, 0, .1);
}

.tetris-title-mark span:nth-child(1),
.tetris-title-mark span:nth-child(2),
.tetris-title-mark span:nth-child(3) { background: #58a4ff; }
.tetris-title-mark span:nth-child(1) { grid-area: 1 / 2; }
.tetris-title-mark span:nth-child(2) { grid-area: 2 / 2; }
.tetris-title-mark span:nth-child(3) { grid-area: 2 / 3; }
.tetris-title-mark span:nth-child(4) { grid-area: 2 / 4; background: #fdc83e; }
.tetris-title-mark span:nth-child(5) { grid-area: 3 / 1; background: #bd78f4; }
.tetris-title-mark span:nth-child(6) { grid-area: 3 / 2; background: #bd78f4; }
.tetris-title-mark span:nth-child(7) { grid-area: 3 / 3; background: #f15c7d; }

.tetris-header h1 {
    grid-area: title;
    margin: 0;
    font-size: clamp(2rem, 6vw, 3.1rem);
    line-height: 1;
    letter-spacing: -.06em;
}

.tetris-header p {
    grid-area: subtitle;
    margin: 7px 0 0;
    color: var(--tetris-muted);
    font-size: .92rem;
    line-height: 1.45;
}

.tetris-panel {
    padding: 20px;
    overflow: visible;
    background: var(--tetris-panel);
    border-color: rgba(99, 102, 241, .13);
    box-shadow: 0 18px 50px rgba(41, 67, 132, .14), inset 0 1px 0 rgba(255,255,255,.85);
}

.tetris-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.tetris-score-strip {
    display: flex;
    gap: 10px;
    min-width: 0;
}

.tetris-stat {
    min-width: 105px;
    padding: 9px 14px;
    border: 1px solid var(--tetris-line);
    border-radius: 14px;
    background: rgba(246, 248, 255, .82);
    text-align: center;
}

.tetris-stat span,
.tetris-final-stats span {
    display: block;
    color: var(--tetris-muted);
    font-size: .61rem;
    font-weight: 900;
    letter-spacing: .11em;
}

.tetris-stat strong {
    display: block;
    margin-top: 2px;
    color: var(--tetris-ink);
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.tetris-score-stat strong.is-bumping {
    animation: tetris-score-bump .28s ease;
}

@keyframes tetris-score-bump {
    50% { transform: scale(1.13); color: #4f46e5; }
}

.tetris-new-button {
    min-height: 46px;
    padding: 10px 16px;
    white-space: nowrap;
}

.tetris-layout {
    display: grid;
    grid-template-columns: minmax(145px, 174px) minmax(260px, 410px) minmax(145px, 174px);
    justify-content: center;
    align-items: start;
    gap: 18px;
}

.tetris-board-column {
    min-width: 0;
}

.tetris-board-shell {
    position: relative;
    width: min(100%, 410px);
    margin: 0 auto;
    padding: 8px;
    border: 1px solid rgba(132, 157, 233, .34);
    border-radius: 23px;
    background: linear-gradient(145deg, #dce8ff, #cbd9fb);
    box-shadow: 0 16px 34px rgba(33, 59, 124, .24), inset 0 1px 0 rgba(255,255,255,.8);
}

.tetris-board {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 2;
    border-radius: 16px;
    outline: none;
    background: var(--tetris-well);
    box-shadow: inset 0 0 0 2px rgba(150, 180, 255, .1), inset 0 0 42px rgba(0, 0, 0, .28);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.tetris-board:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .38), inset 0 0 0 2px rgba(150, 180, 255, .1);
}

.tetris-message {
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 9px auto 0;
    color: var(--tetris-muted);
    font-size: .77rem;
    font-weight: 700;
    text-align: center;
}

.tetris-message.is-good { color: #0f9f69; }
.tetris-message.is-warning { color: #b77900; }

.tetris-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.tetris-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--tetris-line);
    border-radius: 17px;
    background: rgba(248, 250, 255, .9);
    box-shadow: 0 8px 20px rgba(44, 69, 134, .07);
}

.tetris-card-label {
    color: var(--tetris-muted);
    font-size: .64rem;
    font-weight: 900;
    letter-spacing: .11em;
}

.tetris-card-label span { color: var(--tetris-accent); }

.tetris-preview {
    width: 100px;
    height: 100px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 3px;
    margin: 10px auto;
}

.tetris-preview-cell {
    min-width: 0;
    min-height: 0;
    border-radius: 4px;
    background: transparent;
}

.tetris-preview-cell.is-filled {
    background: var(--preview-color);
    box-shadow: inset 0 2px 1px rgba(255,255,255,.45), inset 0 -2px 2px rgba(0,0,0,.15), 0 2px 4px rgba(34, 52, 99, .16);
}

.tetris-next-queue {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 7px;
}

.tetris-next-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(233, 238, 252, .75);
}

.tetris-next-item .tetris-preview {
    width: 72px;
    height: 42px;
    margin: 0;
}

.tetris-next-item .tetris-preview-cell { border-radius: 3px; }

.tetris-small-button {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(99, 102, 241, .2);
    border-radius: 11px;
    background: rgba(233, 235, 255, .9);
    color: #4f46e5;
    font: inherit;
    font-size: .72rem;
    font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
}

.tetris-small-button:hover { background: #e1e3ff; }

.tetris-big-number {
    display: block;
    margin-top: 4px;
    color: var(--tetris-ink);
    font-size: 2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.tetris-progress {
    height: 7px;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(105, 122, 180, .15);
}

.tetris-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #42a5ff, #7568f8);
    transition: width .25s ease;
}

.tetris-card small {
    display: block;
    margin-top: 7px;
    color: var(--tetris-muted);
    font-size: .65rem;
    line-height: 1.35;
}

.tetris-streak-value {
    min-height: 32px;
    margin-top: 4px;
    color: #ee7a25;
    font-size: 1.35rem;
    font-weight: 900;
}

.tetris-mobile-controls {
    display: none;
    margin: 12px auto 0;
    max-width: 360px;
}

.tetris-control-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.tetris-control-button {
    min-width: 52px;
    min-height: 48px;
    padding: 7px 9px;
    border: 1px solid rgba(95, 112, 176, .2);
    border-radius: 13px;
    background: linear-gradient(145deg, #fff, #e9efff);
    color: #263561;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 5px 11px rgba(49, 74, 139, .11);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tetris-control-button span {
    display: block;
    margin-top: 4px;
    color: #6d7693;
    font-size: .48rem;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.tetris-control-button:active { transform: translateY(1px) scale(.97); }
.tetris-control-drop { color: #4f46e5; }
.tetris-control-hold { color: #b7680b; }
.tetris-control-pause { color: #c73f66; }

.tetris-help {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 15px;
    margin-top: 18px;
    color: var(--tetris-muted);
    font-size: .66rem;
    font-weight: 700;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    min-height: 19px;
    margin-right: 2px;
    padding: 2px 5px;
    border: 1px solid rgba(80, 98, 160, .2);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(235, 239, 251, .9);
    color: #4f5b89;
    font-size: .58rem;
    font-weight: 900;
}

.tetris-overlay {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 26, 60, .54);
    backdrop-filter: blur(8px);
}

.tetris-overlay[hidden] { display: none; }

.tetris-modal {
    width: min(100%, 430px);
    padding: 26px 22px 22px;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 25px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 25px 70px rgba(11, 21, 57, .34);
    text-align: center;
}

.tetris-modal-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    margin: 0 auto 10px;
    border-radius: 17px;
    background: #e9e9ff;
    color: #5550d5;
    font-size: 1.8rem;
    font-weight: 900;
}

.tetris-modal h2 {
    margin: 0;
    color: #20294a;
    font-size: 1.6rem;
}

.tetris-modal p {
    margin: 8px auto 16px;
    color: #6d7693;
    line-height: 1.45;
}

.tetris-record-badge {
    display: inline-block;
    margin-bottom: 9px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #fff0c8;
    color: #9a5b00;
    font-size: .65rem;
    font-weight: 900;
    letter-spacing: .09em;
}

.tetris-final-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.tetris-final-stats > div {
    padding: 10px 5px;
    border-radius: 13px;
    background: #f2f4fc;
}

.tetris-final-stats strong {
    display: block;
    margin-top: 3px;
    color: #263561;
    font-size: 1.22rem;
    font-variant-numeric: tabular-nums;
}

.tetris-modal .game-actions { gap: 8px; }
.tetris-modal .game-button { min-height: 42px; padding: 10px 13px; font-size: .78rem; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.dark-mode .tetris-page {
    --tetris-ink: #f2f4ff;
    --tetris-muted: #aab3d2;
    --tetris-panel: rgba(23, 28, 55, .94);
    --tetris-line: rgba(172, 187, 239, .17);
    background:
        radial-gradient(circle at 12% 2%, rgba(99, 102, 241, .2), transparent 330px),
        radial-gradient(circle at 92% 26%, rgba(45, 185, 255, .12), transparent 360px),
        linear-gradient(145deg, #101631 0%, #151d3d 100%);
}

body.dark-mode .tetris-status { color: #b5c3f1; }
body.dark-mode .tetris-stat,
body.dark-mode .tetris-card { background: rgba(32, 40, 76, .82); }
body.dark-mode .tetris-stat strong,
body.dark-mode .tetris-big-number { color: #f4f6ff; }
body.dark-mode .tetris-card small { color: #aab3d2; }
body.dark-mode .tetris-next-item { background: rgba(16, 23, 52, .7); }
body.dark-mode .tetris-small-button { background: #2f3470; color: #dcdcff; }
body.dark-mode .tetris-control-button { background: linear-gradient(145deg, #303864, #22294e); color: #f4f6ff; }
body.dark-mode .tetris-control-button span,
body.dark-mode .tetris-help { color: #aab3d2; }
body.dark-mode kbd { background: #2b335e; color: #d2d9ff; }
body.dark-mode .tetris-modal { background: #1d2444; }
body.dark-mode .tetris-modal h2 { color: #f4f6ff; }
body.dark-mode .tetris-modal p { color: #aab3d2; }
body.dark-mode .tetris-final-stats > div { background: #2a335d; }
body.dark-mode .tetris-final-stats strong { color: #f4f6ff; }

@media (max-width: 820px) {
    .tetris-layout {
        grid-template-columns: minmax(122px, 150px) minmax(245px, 365px) minmax(122px, 150px);
        gap: 12px;
    }

    .tetris-panel { padding: 16px; }
    .tetris-card { padding: 11px; }
    .tetris-preview { width: 84px; height: 84px; }
    .tetris-next-item .tetris-preview { width: 62px; height: 38px; }
}

@media (max-width: 680px) {
    .tetris-page { padding-left: 10px; padding-right: 10px; }
    .tetris-topbar { margin-bottom: 18px; }
    .tetris-header { max-width: 430px; margin-bottom: 16px; }
    .tetris-header p { font-size: .82rem; }
    .tetris-panel { padding: 12px; border-radius: 20px; }
    .tetris-toolbar { align-items: stretch; flex-direction: column; gap: 10px; margin-bottom: 12px; }
    .tetris-score-strip { justify-content: center; }
    .tetris-stat { flex: 1 1 0; min-width: 0; padding: 8px 8px; }
    .tetris-stat strong { font-size: 1.18rem; }
    .tetris-new-button { width: 100%; max-width: none; }
    .tetris-layout { display: flex; flex-direction: column; align-items: stretch; gap: 11px; }
    .tetris-board-column { order: 1; }
    .tetris-sidebar-left { order: 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .tetris-sidebar-right { order: 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
    .tetris-board-shell { width: min(100%, 350px); padding: 6px; border-radius: 18px; }
    .tetris-board { border-radius: 13px; }
    .tetris-mobile-controls { display: block; }
    .tetris-help { display: none; }
    .tetris-card { border-radius: 14px; }
    .tetris-preview { width: 76px; height: 76px; }
    .tetris-next-item .tetris-preview { width: 62px; height: 36px; }
    .tetris-small-button { min-height: 34px; font-size: .65rem; }
    .tetris-big-number { font-size: 1.55rem; }
    .tetris-streak-value { font-size: 1rem; }
    .tetris-card small { font-size: .58rem; }
    .tetris-next-queue { display: grid; grid-template-columns: repeat(3, 1fr); }
    .tetris-next-item { min-height: 48px; }
    .tetris-next-item:nth-child(n + 4) { display: none; }
    .tetris-modal .game-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .tetris-modal .game-actions .game-button:first-child { grid-column: 1 / -1; }
    .tetris-modal .game-actions a { grid-column: 1 / -1; }
}

@media (max-width: 380px) {
    .tetris-header { column-gap: 10px; }
    .tetris-title-mark { width: 54px; height: 54px; grid-template-columns: repeat(4, 10px); grid-template-rows: repeat(4, 10px); }
    .tetris-header h1 { font-size: 1.9rem; }
    .tetris-header p { font-size: .75rem; }
    .tetris-control-button { min-width: 45px; min-height: 45px; padding: 6px; }
    .tetris-control-drop { min-width: 54px; }
}
