:root {
    --bg-base: #06070a;
    --chassis-bg: #0d1017;
    --screen-bg: #05070d;
    --panel-border: rgba(255, 255, 255, 0.08);
    --neon-cyan: #00f0ff;
    --neon-glow: rgba(0, 240, 255, 0.35);
    --neon-amber: #f59e0b;
    --neon-amber-glow: rgba(245, 158, 11, 0.35);
    --text-pure: #f8fafc;
    --text-muted: #64748b;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-base);
    color: var(--text-pure);
    font-family: var(--font-ui);
    overflow: hidden;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.arcade-chassis {
    width: 100%;
    max-width: 440px;
    height: 100vh;
    height: 100dvh;
    background: var(--chassis-bg);
    display: flex;
    flex-direction: column;
    padding: 6px 12px calc(env(safe-area-inset-bottom, 6px) + 2px) 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
    position: relative;
}

@media (min-width: 640px) {
    .arcade-chassis {
        height: 96vh;
        max-height: 860px;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        padding: 14px 20px;
    }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 30px;
    margin-bottom: 4px;
    flex-shrink: 0;
    z-index: 5;
}

.brand {
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.brand span {
    color: var(--neon-cyan);
    text-shadow: 0 0 8px var(--neon-cyan);
}

.actions {
    display: flex;
    gap: 6px;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    color: var(--text-pure);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chip-btn:active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--neon-cyan);
    transform: scale(0.96);
}

.hud-dashboard {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 4px 8px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.hud-title {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.next-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--panel-border);
    padding-right: 4px;
}

#next-canvas {
    width: 44px;
    height: 44px;
    display: block;
}

.hud-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px var(--neon-glow);
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* 核心视口框架：释放最大空间 */
.screen-frame {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.screen-glass {
    position: relative;
    background: var(--screen-bg);
    border: 1.5px solid rgba(0, 240, 255, 0.35);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.95), 0 0 16px rgba(0, 240, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

#tetris {
    display: block;
    image-rendering: pixelated;
    cursor: grab;
    touch-action: none;
}

#tetris:active {
    cursor: grabbing;
}

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 13, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.overlay-modal {
    text-align: center;
    padding: 16px;
    width: 90%;
}

.overlay-modal h2 {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 4px;
    color: #fff;
    text-shadow: 0 0 12px var(--neon-cyan);
}

.overlay-modal p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.4;
}

.neon-btn {
    background: transparent;
    color: var(--neon-cyan);
    border: 1.5px solid var(--neon-cyan);
    padding: 10px 28px;
    font-size: 0.9rem;
    font-weight: 800;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 0 15px var(--neon-glow);
    transition: all 0.15s ease;
}

.neon-btn.mini {
    padding: 6px 20px;
    font-size: 0.82rem;
}

.neon-btn:active {
    background: var(--neon-cyan);
    color: #000;
    transform: scale(0.95);
}

/* 移动端操作台：右侧双圆形 */
.gamepad-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
    padding: 4px 4px 2px 4px;
    flex-shrink: 0;
}

.dpad-cluster, .action-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pad-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-pure);
    font-size: 1.15rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pad-btn:active {
    transform: translateY(2px) scale(0.95);
}

.btn-nav {
    width: 48px;
    height: 50px;
}

.btn-nav:active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--neon-cyan);
}

/* 双圆形动作按键 */
.round-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
}

/* 琥珀金快速坠落键 */
.btn-slam {
    font-size: 1.35rem;
    color: var(--neon-amber);
    background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, rgba(255, 255, 255, 0.03) 80%);
    border: 1.5px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 12px var(--neon-amber-glow);
}

.btn-slam:active {
    background: rgba(245, 158, 11, 0.35);
    border-color: var(--neon-amber);
}

/* 青色旋转变形键 */
.btn-action {
    font-size: 1.45rem;
    color: var(--neon-cyan);
    background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, rgba(255, 255, 255, 0.03) 80%);
    border: 1.5px solid var(--neon-cyan);
    box-shadow: 0 0 12px var(--neon-glow);
}

.btn-action:active {
    background: rgba(0, 240, 255, 0.35);
    border-color: var(--neon-cyan);
}

/* 底部选择器 */
.bottom-selectors {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 4px 8px;
    flex-shrink: 0;
}

.selector-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sel-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 26px;
}

.pill-group {
    display: flex;
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.pill-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pill-btn.active {
    background: rgba(0, 240, 255, 0.2);
    color: var(--neon-cyan);
    box-shadow: 0 0 8px var(--neon-glow);
}

.modal-layer {
    position: absolute;
    inset: 0;
    background: rgba(4, 6, 10, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 16px;
    transition: opacity 0.2s ease;
}

.modal-layer.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-card {
    background: #0f1422;
    border: 1.5px solid var(--neon-cyan);
    border-radius: 14px;
    padding: 20px 16px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9), 0 0 15px var(--neon-glow);
    text-align: left;
}

.modal-card h3 {
    text-align: center;
    color: var(--neon-cyan);
    font-size: 1.05rem;
    margin-bottom: 14px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px var(--neon-glow);
}

.help-content {
    font-size: 0.78rem;
    line-height: 1.6;
    color: #e2e8f0;
    margin-bottom: 16px;
}

.help-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
}

.help-row span:first-child {
    color: var(--text-muted);
}

.help-row span:last-child {
    font-weight: 600;
}

.modal-card .neon-btn {
    display: block;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .gamepad-area {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
