/* ==========================================================================
   Tetris — oyun ekranı
   Koyu cam yüzeyler, mor/cyan neon vurgular. Yalnızca bu ekrana özgü stiller.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sayfa iskeleti
   -------------------------------------------------------------------------- */
.tetris-game-page {
    min-height: 100vh;
    padding: calc(var(--nav-height) + 20px) 0 40px;
    overflow-x: hidden;
    background-color: var(--color-bg);
    background-image:
        radial-gradient(1000px 580px at 50% -10%, rgba(124, 92, 252, 0.18), transparent 64%),
        radial-gradient(760px 440px at 92% 4%, rgba(34, 211, 238, 0.09), transparent 62%),
        radial-gradient(640px 520px at 4% 82%, rgba(124, 92, 252, 0.07), transparent 66%),
        linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
    background-size: auto, auto, auto, 46px 46px, 46px 46px;
    background-position: center top, center top, center, center top, center top;
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
}

.tetris-shell {
    width: min(1180px, calc(100% - 40px));
    margin-inline: auto;
}

.tetris-shell:focus {
    outline: none;
}

/* --------------------------------------------------------------------------
   Üst çubuk
   -------------------------------------------------------------------------- */
.tetris-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 18px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background:
        linear-gradient(150deg, rgba(28, 38, 59, 0.78), rgba(11, 16, 32, 0.72));
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    box-shadow:
        0 18px 40px -32px rgba(2, 6, 23, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tetris-topbar-left,
.tetris-topbar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.tetris-topbar-right {
    justify-content: flex-end;
}

/* Ortak .game-back görünümü — bu sayfa home.css yüklemeden de çalışsın */
.game-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    margin: 0;
    padding: 6px 11px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    color: var(--color-text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition:
        color 0.18s ease,
        border-color 0.18s ease,
        background 0.18s ease;
}

.game-back::before {
    content: '\2190';
    font-size: 0.9rem;
    line-height: 1;
}

.game-back:hover {
    color: var(--color-text);
    border-color: var(--color-border-strong);
    background: rgba(148, 163, 184, 0.07);
}

.tetris-mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: 1px solid rgba(124, 92, 252, 0.3);
    border-radius: 999px;
    background: rgba(124, 92, 252, 0.13);
    color: #c4b5fd;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    line-height: 1.5;
    text-transform: uppercase;
    white-space: nowrap;
}

.tetris-best-inline {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.tetris-best-inline strong {
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.86rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.connection-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.65);
    color: var(--color-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.connection-pill i {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: var(--color-accent-2);
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.85);
    animation: tetrisPulse 2.4s ease-in-out infinite;
}

@keyframes tetrisPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.82); }
}

/* --------------------------------------------------------------------------
   Yerleşim
   -------------------------------------------------------------------------- */
.tetris-layout {
    display: grid;
    grid-template-columns: minmax(190px, 230px) minmax(300px, 420px) minmax(190px, 230px);
    grid-template-areas: 'left board right';
    align-items: start;
    justify-content: center;
    gap: 20px;
}

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

.tetris-side-left {
    grid-area: left;
}

.tetris-side-right {
    grid-area: right;
}

.tetris-board-wrap {
    grid-area: board;
    width: 100%;
    max-width: clamp(240px, calc((100vh - 300px) / 2), 380px);
    margin-inline: auto;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Paneller
   -------------------------------------------------------------------------- */
.tetris-panel {
    position: relative;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(155deg, rgba(28, 38, 59, 0.74), rgba(13, 19, 34, 0.68));
    -webkit-backdrop-filter: blur(12px) saturate(135%);
    backdrop-filter: blur(12px) saturate(135%);
    box-shadow:
        0 20px 44px -34px rgba(2, 6, 23, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

/* "Kontroller" paneli butonla açılıp kapanır; masaüstünde açık başlar. */
.keys-panel {
    display: none;
}

.keys-panel.is-open {
    display: block;
    animation: keys-panel-in 0.22s var(--ease);
}

@keyframes keys-panel-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    color: var(--color-text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    line-height: 1.4;
    text-transform: uppercase;
}

.panel-title::before {
    content: '';
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 2px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    box-shadow: 0 0 9px rgba(124, 92, 252, 0.65);
}

.panel-hint {
    margin-top: 8px;
    padding: 4px 8px;
    border: 1px dashed rgba(148, 163, 184, 0.22);
    border-radius: 6px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    text-align: center;
}

/* Sakla / sıradaki canvas yuvaları */
.canvas-slot {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-md);
    background-color: rgba(2, 6, 23, 0.58);
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
    background-size: 18px 18px, 18px 18px;
    background-position: center;
    box-shadow:
        inset 0 2px 12px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.canvas-slot canvas {
    display: block;
    max-width: 100%;
}

.canvas-slot-hold {
    width: min(100%, 170px);
    margin-inline: auto;
    aspect-ratio: 1 / 1;
}

.canvas-slot-hold canvas {
    width: 100%;
    height: 100%;
}

.canvas-slot-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 200px);
    height: clamp(200px, 30vh, 300px);
    margin-inline: auto;
}

.canvas-slot-next canvas {
    width: auto;
    height: 100%;
}

/* İstatistikler */
.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 7px 2px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.09);
}

.stat-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.stat-value {
    min-width: 0;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.94rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.stat-row-hero {
    align-items: center;
    margin-bottom: 4px;
    padding: 9px 11px;
    border: 1px solid rgba(124, 92, 252, 0.26);
    border-radius: var(--radius-md);
    background:
        radial-gradient(140px 70px at 100% 0%, rgba(34, 211, 238, 0.14), transparent 72%),
        linear-gradient(135deg, rgba(124, 92, 252, 0.16), rgba(34, 211, 238, 0.05));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-row-hero .stat-label {
    color: #c4b5fd;
    letter-spacing: 0.09em;
}

.stat-row-hero .stat-value {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(1.5rem, 2.1vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    text-overflow: ellipsis;
    background: linear-gradient(120deg, #67e8f9 8%, #c4b5fd 58%, #a78bfa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.18));
}

/* Kontrol listesi */
.keys-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
}

.keys-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 1px;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.1);
}

.keys-list > div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.keys-list dt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.keys-list dd {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.71rem;
    text-align: right;
}

.keys-list kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    border: 1px solid var(--color-border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: rgba(2, 6, 23, 0.58);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Seviye paneli */
.level-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.level-panel .panel-title {
    margin-bottom: 2px;
}

.level-meter {
    position: relative;
    height: 9px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.72);
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
}

#level-fill {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-2));
    box-shadow:
        0 0 12px rgba(34, 211, 238, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transition: width 0.3s var(--ease);
}

.level-hint {
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.level-note {
    color: var(--color-text-muted);
    font-size: 0.67rem;
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Oyun tahtası
   -------------------------------------------------------------------------- */
.board-frame {
    position: relative;
    padding: 8px;
    border: 1px solid rgba(124, 92, 252, 0.3);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 60% at 50% 0%, rgba(124, 92, 252, 0.12), transparent 60%),
        linear-gradient(180deg, #080d1a, #04070f);
    box-shadow:
        0 34px 80px -44px rgba(2, 6, 23, 0.98),
        0 0 0 1px rgba(124, 92, 252, 0.1),
        0 0 46px -18px rgba(124, 92, 252, 0.55),
        inset 0 0 26px rgba(0, 0, 0, 0.9);
}

canvas#board-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 2;
    border-radius: calc(var(--radius-lg) - 6px);
    background: #05080f;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.board-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border-radius: inherit;
    background:
        radial-gradient(90% 50% at 50% 0%, rgba(124, 92, 252, 0.16), transparent 70%),
        rgba(4, 9, 20, 0.74);
    -webkit-backdrop-filter: blur(6px) saturate(125%);
    backdrop-filter: blur(6px) saturate(125%);
    animation: overlayIn 0.22s var(--ease);
}

.board-overlay.hidden,
.board-overlay[hidden] {
    display: none !important;
}

.board-overlay.is-visible {
    display: flex;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    width: 100%;
    max-width: 310px;
    max-height: 100%;
    overflow-y: auto;
    padding: 22px 20px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(220px 120px at 50% 0%, rgba(124, 92, 252, 0.14), transparent 72%),
        rgba(15, 23, 42, 0.94);
    box-shadow:
        var(--shadow-lg),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    text-align: center;
}

.overlay-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #67e8f9;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.overlay-kicker::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent-2);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.9);
}

.overlay-card h2 {
    color: var(--color-text);
    font-size: clamp(1.35rem, 3vw, 1.7rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.12;
    background: linear-gradient(120deg, #f8fafc 10%, #c4b5fd 62%, #67e8f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.overlay-card p {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    line-height: 1.55;
}

.overlay-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.overlay-actions .ghost-btn {
    width: 100%;
    min-height: 42px;
    justify-content: center;
}

.overlay-hint {
    margin-top: 2px;
    color: var(--color-text-muted) !important;
    font-size: 0.7rem !important;
    line-height: 1.45 !important;
}

.board-status {
    min-height: 20px;
    margin-top: 8px;
    color: var(--color-text-muted);
    font-size: 0.74rem;
    line-height: 1.4;
    text-align: center;
}

.board-status.is-error {
    color: #fca5a5;
}

.board-status.is-success {
    color: #6ee7b7;
}

.board-status.is-info {
    color: #67e8f9;
}

/* --------------------------------------------------------------------------
   Butonlar (theme/home.css global olmayabilir)
   -------------------------------------------------------------------------- */
.game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    border: 0;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #8d72ff, var(--color-accent));
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 14px 28px -16px rgba(124, 92, 252, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transition:
        transform 0.18s var(--ease),
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.game-btn:not(:disabled):hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #9b84ff, var(--color-accent-strong));
    box-shadow:
        0 18px 34px -16px rgba(124, 92, 252, 1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.game-btn:not(:disabled):active {
    transform: translateY(1px);
    box-shadow: 0 8px 16px -12px rgba(124, 92, 252, 0.8);
}

.game-btn:disabled {
    background: #2b354a;
    color: var(--color-text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--color-text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition:
        border-color 0.18s ease,
        color 0.18s ease,
        background 0.18s ease;
}

.ghost-btn:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text);
    background: rgba(148, 163, 184, 0.07);
}

.ghost-btn:active {
    background: rgba(148, 163, 184, 0.13);
}

.ghost-btn.small {
    padding: 5px 10px;
    font-size: 0.71rem;
}

.tetris-game-page :is(a, button, [tabindex]):focus-visible {
    outline: 2px solid var(--color-accent-2);
    outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Dokunmatik kontroller
   -------------------------------------------------------------------------- */
.touch-controls {
    display: none;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(155deg, rgba(28, 38, 59, 0.7), rgba(11, 16, 32, 0.68));
    -webkit-backdrop-filter: blur(14px) saturate(135%);
    backdrop-filter: blur(14px) saturate(135%);
    box-shadow:
        0 20px 44px -34px rgba(2, 6, 23, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.touch-group {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.touch-group:last-child {
    flex: 1 1 100%;
}

.touch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex: none;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: 16px;
    background:
        linear-gradient(150deg, rgba(148, 163, 184, 0.14), rgba(15, 23, 42, 0.55));
    color: var(--color-text);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 22px -18px rgba(2, 6, 23, 0.95);
    transition:
        transform 0.12s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.touch-btn svg {
    width: 22px;
    height: 22px;
    flex: none;
}

.touch-btn:not(:disabled):hover {
    border-color: rgba(34, 211, 238, 0.4);
    background:
        linear-gradient(150deg, rgba(124, 92, 252, 0.2), rgba(15, 23, 42, 0.62));
}

.touch-btn:not(:disabled):active {
    transform: translateY(1px) scale(0.95);
    border-color: rgba(34, 211, 238, 0.55);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}

.touch-btn-accent {
    border-color: rgba(34, 211, 238, 0.5);
    background: linear-gradient(145deg, rgba(124, 92, 252, 0.78), rgba(34, 211, 238, 0.5));
    color: #f8fafc;
    box-shadow:
        0 10px 24px -12px rgba(34, 211, 238, 0.75),
        inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.touch-btn-accent:not(:disabled):hover {
    background: linear-gradient(145deg, rgba(141, 114, 255, 0.88), rgba(34, 211, 238, 0.62));
}

.touch-btn-wide {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    border-color: rgba(124, 92, 252, 0.38);
    background: linear-gradient(135deg, rgba(124, 92, 252, 0.28), rgba(34, 211, 238, 0.12));
    color: #e9e4ff;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.touch-btn-wide:not(:disabled):hover {
    border-color: rgba(124, 92, 252, 0.6);
    background: linear-gradient(135deg, rgba(124, 92, 252, 0.38), rgba(34, 211, 238, 0.18));
}

/* --------------------------------------------------------------------------
   Alt bilgi
   -------------------------------------------------------------------------- */
.footer {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: center;
}

.footer p {
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Duyarlı kırılımlar
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
    .tetris-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            'board board'
            'left right';
        gap: 16px 18px;
    }

    .tetris-side {
        width: 100%;
        max-width: 360px;
    }

    .tetris-side-left {
        justify-self: end;
    }

    .tetris-side-right {
        justify-self: start;
    }
}

@media (hover: none), (pointer: coarse), (max-width: 820px) {
    .touch-controls {
        display: flex;
    }
}

@media (max-width: 820px) {
    .tetris-shell {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        row-gap: 14px;
    }

    .tetris-layout {
        display: contents;
    }

    .tetris-board-wrap,
    .tetris-side-left,
    .tetris-side-right {
        grid-area: auto;
    }

    .tetris-topbar {
        order: 1;
        margin-bottom: 0;
    }

    .tetris-board-wrap {
        order: 2;
        max-width: min(380px, 100%);
    }

    .touch-controls {
        order: 3;
        margin-top: 0;
    }

    .tetris-side-left {
        order: 4;
    }

    .tetris-side-right {
        order: 5;
    }

    .footer {
        order: 6;
        margin-top: 0;
    }

    .tetris-side,
    .tetris-side-left,
    .tetris-side-right {
        width: 100%;
        max-width: none;
        justify-self: stretch;
    }

    .tetris-side {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
        gap: 12px;
    }

    .keys-panel {
        grid-column: 1 / -1;
    }

    .canvas-slot-next {
        height: clamp(200px, 32vh, 280px);
    }
}

@media (max-width: 560px) {
    .tetris-game-page {
        padding: calc(var(--nav-height) + 12px) 0 28px;
    }

    .tetris-shell {
        width: calc(100% - 24px);
    }

    .tetris-topbar {
        gap: 8px;
        margin-bottom: 0;
        padding: 8px 10px;
    }

    .tetris-topbar-left,
    .tetris-topbar-right {
        gap: 6px;
    }

    .tetris-topbar-right {
        justify-content: flex-start;
    }

    .game-back {
        padding: 5px 9px;
        font-size: 0.72rem;
    }

    .tetris-mode-badge {
        padding: 3px 8px;
        font-size: 0.62rem;
    }

    .tetris-best-inline {
        font-size: 0.66rem;
    }

    .tetris-best-inline strong {
        font-size: 0.8rem;
    }

    .connection-pill {
        padding: 4px 8px;
        font-size: 0.66rem;
    }

    .ghost-btn.small {
        padding: 5px 8px;
        font-size: 0.68rem;
    }

    .tetris-panel {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    .panel-title {
        margin-bottom: 8px;
        font-size: 0.64rem;
    }

    .tetris-side {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .keys-panel {
        grid-column: auto;
    }

    .canvas-slot-next {
        height: clamp(180px, 30vh, 240px);
    }

    .stat-row {
        padding: 6px 2px;
    }

    .stat-row-hero {
        padding: 8px 10px;
    }

    .stat-row-hero .stat-value {
        font-size: 1.5rem;
    }

    .overlay-card {
        padding: 16px 14px;
        gap: 7px;
    }

    .overlay-card p {
        font-size: 0.76rem;
    }

    .board-overlay {
        padding: 10px;
    }

    .game-btn {
        min-height: 46px;
        padding: 11px 16px;
        font-size: 0.82rem;
    }

    .touch-controls {
        margin-top: 0;
        padding: 10px;
        gap: 8px;
    }

    .touch-btn {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }

    .touch-btn-wide {
        width: 100%;
        height: 48px;
    }

    .touch-btn svg {
        width: 20px;
        height: 20px;
    }

    .footer {
        margin-top: 0;
        padding-top: 14px;
        font-size: 0.72rem;
    }
}

@media (max-width: 380px) {
    .tetris-topbar-left {
        gap: 5px;
    }

    .tetris-topbar-right {
        gap: 5px;
    }

    .tetris-best-inline {
        display: none;
    }

    .connection-pill span {
        display: none;
    }

    .touch-btn {
        width: 48px;
        height: 48px;
    }

    .touch-btn-wide {
        width: 100%;
        height: 48px;
    }
}

/* --------------------------------------------------------------------------
   Hareket tercihi
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .connection-pill i {
        animation: none;
    }

    .board-overlay {
        animation: none;
    }

    #level-fill {
        transition: none;
    }
}
