/* 沙子俄罗斯方块 - 样式文件 */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* 基础样式重置 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
}

/* 动态背景星星效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #eee, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #fff, transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: sparkle 20s linear infinite;
    z-index: -1;
}

@keyframes sparkle {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(200px);
    }
}

/* 游戏容器 */
#gameContainer {
    position: relative;
    border: 4px solid #29adff;
    border-radius: 8px;
    background: #000011;
    box-shadow:
        0 0 20px rgba(41, 173, 255, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.8);
    padding: 20px;
}

/* 游戏画布 */
#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #001122 0%, #000011 50%, #110022 100%);
    border: 2px solid #ffffff;
    border-radius: 4px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* UI信息面板 */
#ui {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.8),
        0 0 10px rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

#ui div {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    min-width: 120px;
}

#ui div:last-child {
    margin-bottom: 0;
}

#score,
#time {
    color: #00ff88;
    margin-left: 10px;
}

/* 控制说明 */
#controls {
    position: absolute;
    bottom: -70px;
    left: 0;
    right: 0;
    color: #888;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 菜单通用样式 */
.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.menu h1 {
    font-size: 48px;
    margin-bottom: 40px;
    text-shadow:
        3px 3px 6px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(255, 255, 255, 0.4);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease-in-out infinite;
}

.menu h2 {
    font-size: 36px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    color: #ffffff;
}

/* 按钮样式 */
.menu button {
    background: linear-gradient(145deg, #2c3e50, #34495e);
    color: white;
    border: 2px solid #555;
    padding: 15px 30px;
    margin: 8px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    min-width: 180px;
}

.menu button:hover {
    background: linear-gradient(145deg, #34495e, #3c5a78);
    border-color: #777;
    transform: translateY(-2px);
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.menu button:active {
    transform: translateY(0);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 游戏说明文本 */
.menu div {
    text-align: left;
    max-width: 500px;
    line-height: 1.8;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.menu div p {
    margin: 10px 0;
    color: #e0e0e0;
}

.menu div p::before {
    content: "🎮 ";
    margin-right: 8px;
}

/* 分数显示 */
#finalScore {
    color: #ffeb3b;
    font-size: 24px;
    font-weight: bold;
    margin: 15px 0;
    text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 动画效果 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #gameContainer {
        transform: scale(0.8);
        transform-origin: center;
    }

    .menu h1 {
        font-size: 36px;
    }

    .menu h2 {
        font-size: 28px;
    }

    .menu button {
        font-size: 16px;
        padding: 12px 24px;
        min-width: 150px;
    }

    #ui {
        font-size: 16px;
        top: 10px;
        right: 10px;
        padding: 8px 12px;
    }

    #controls {
        font-size: 12px;
        bottom: -60px;
    }
}

@media (max-width: 480px) {
    #gameContainer {
        transform: scale(0.6);
    }

    .menu h1 {
        font-size: 28px;
        margin-bottom: 30px;
    }

    .menu button {
        font-size: 14px;
        padding: 10px 20px;
        margin: 6px;
        min-width: 130px;
    }

    .menu div {
        max-width: 300px;
        padding: 15px;
        font-size: 14px;
    }
}

/* 特殊效果 */
.menu button:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow:
        0 0 0 3px rgba(78, 205, 196, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.3);
}

/* 游戏画布悬停效果 */
#gameCanvas:hover {
    box-shadow:
        0 0 30px rgba(0, 255, 255, 0.4),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
}

/* 加载动画 */
.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* 成功/错误状态 */
.success {
    color: #4caf50 !important;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.error {
    color: #f44336 !important;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    body {
        background: #000;
    }

    #gameContainer {
        border-color: #fff;
    }

    .menu {
        background: rgba(0, 0, 0, 0.95);
    }

    .menu button {
        border-color: #fff;
        background: #333;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 
游戏信息面板 */
#gameInfo {
    position: absolute;
    top: 20px;
    right: -200px;
    width: 180px;
    color: #ffffff;
    font-size: 8px;
    line-height: 1.6;
}

/* 左侧装饰面板 */
#leftPanel {
    position: absolute;
    top: 20px;
    left: -200px;
    width: 180px;
    color: #ffffff;
    font-size: 8px;
    line-height: 1.6;
}

.decoration-panel {
    background: rgba(0, 0, 17, 0.9);
    border: 2px solid #ff004d;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
    box-shadow: 0 0 10px rgba(255, 0, 77, 0.3);
}

.panel-title {
    color: #ffec27;
    margin-bottom: 8px;
    text-align: center;
    font-size: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    padding: 2px 0;
}

.stat-label {
    color: #29adff;
    font-size: 8px;
}

.stat-value {
    color: #00e436;
    font-size: 8px;
    font-weight: bold;
}

/* 沙子物理效果显示 */
.physics-display {
    text-align: center;
    padding: 10px;
    height: 60px;
    position: relative;
    overflow: hidden;
}

.sand-particle {
    width: 4px;
    height: 4px;
    background: #ffec27;
    border-radius: 50%;
    position: absolute;
    animation: sandFall 2s infinite linear;
}

.sand-particle:nth-child(1) {
    left: 20%;
    animation-delay: 0s;
    background: #ff004d;
}

.sand-particle:nth-child(2) {
    left: 50%;
    animation-delay: 0.7s;
    background: #29adff;
}

.sand-particle:nth-child(3) {
    left: 80%;
    animation-delay: 1.4s;
    background: #00e436;
}

.sand-flow {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    color: #29adff;
    font-size: 12px;
    animation: flow 1.5s ease-in-out infinite;
}

@keyframes sandFall {
    0% {
        top: -5px;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 50px;
        opacity: 0;
    }
}

@keyframes flow {

    0%,
    100% {
        transform: translateX(-50%) scaleX(1);
        opacity: 0.6;
    }

    50% {
        transform: translateX(-50%) scaleX(1.2);
        opacity: 1;
    }
}

/* 底部状态栏 */
#statusBar {
    position: absolute;
    bottom: -120px;
    left: 0;
    right: 0;
    height: 30px;
    background: rgba(0, 0, 17, 0.9);
    border: 2px solid #00e436;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 0 10px rgba(0, 228, 54, 0.3);
}

.status-section {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-icon {
    font-size: 12px;
}

.status-text {
    color: #ffffff;
    font-size: 8px;
}

.info-panel {
    background: rgba(0, 0, 17, 0.9);
    border: 2px solid #29adff;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
    box-shadow: 0 0 10px rgba(41, 173, 255, 0.3);
}

.info-title {
    color: #ffec27;
    margin-bottom: 8px;
    text-align: center;
    font-size: 10px;
}

.score-display {
    color: #ff004d;
    font-size: 12px;
    text-align: center;
}

.time-display {
    color: #00e436;
    font-size: 10px;
    text-align: center;
}

/* 控制说明重新定义 */
#controls {
    position: absolute;
    bottom: -80px;
    left: 0;
    right: 0;
    color: #29adff;
    text-align: center;
    font-size: 6px;
    line-height: 1.4;
    background: rgba(0, 0, 17, 0.8);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #29adff;
}

.controls-row {
    margin: 4px 0;
}

.key {
    background: #29adff;
    color: #000011;
    padding: 2px 4px;
    border-radius: 2px;
    margin: 0 2px;
    font-size: 6px;
}

/* 菜单样式重新定义 */
.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 17, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
    border-radius: 8px;
}

.menu h1 {
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow:
        2px 2px 0px #ff004d,
        4px 4px 0px #29adff,
        6px 6px 0px #ffec27;
    color: #ffffff;
    text-align: center;
    line-height: 1.2;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow:
            2px 2px 0px #ff004d,
            4px 4px 0px #29adff,
            6px 6px 0px #ffec27,
            0 0 10px rgba(255, 255, 255, 0.5);
    }

    to {
        text-shadow:
            2px 2px 0px #ff004d,
            4px 4px 0px #29adff,
            6px 6px 0px #ffec27,
            0 0 20px rgba(255, 255, 255, 0.8);
    }
}

.menu h2 {
    font-size: 16px;
    margin-bottom: 20px;
    color: #ffec27;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.menu button {
    background: linear-gradient(45deg, #29adff, #0066cc);
    color: white;
    border: 2px solid #ffffff;
    padding: 12px 24px;
    margin: 8px;
    font-size: 10px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow:
        0 4px 0 #0066cc,
        0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    top: 0;
}

.menu button:hover {
    background: linear-gradient(45deg, #ffec27, #ff9900);
    border-color: #ff004d;
    box-shadow:
        0 4px 0 #cc7700,
        0 4px 12px rgba(255, 236, 39, 0.4);
    transform: translateY(-2px);
}

.menu button:active {
    top: 2px;
    box-shadow:
        0 2px 0 #0066cc,
        0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 游戏说明样式 */
.instructions {
    max-width: 400px;
    text-align: left;
    line-height: 1.8;
    font-size: 8px;
    color: #29adff;
    background: rgba(0, 0, 17, 0.8);
    padding: 20px;
    border: 2px solid #29adff;
    border-radius: 4px;
    margin: 20px;
}

.instructions h3 {
    color: #ffec27;
    font-size: 10px;
    margin-bottom: 10px;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    margin: 8px 0;
    padding-left: 16px;
    position: relative;
}

.instructions li::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: #ff004d;
}

/* 最终分数显示 */
.final-score {
    font-size: 16px;
    color: #ffec27;
    margin: 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* 响应式设计更新 */
@media (max-width: 1200px) {
    #gameInfo {
        position: static;
        width: 100%;
        margin-top: 20px;
        display: flex;
        justify-content: space-around;
    }

    .info-panel {
        flex: 1;
        margin: 0 5px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #gameContainer {
        padding: 10px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .menu h1 {
        font-size: 16px;
    }

    .menu button {
        font-size: 8px;
        padding: 10px 20px;
    }

    #controls {
        font-size: 5px;
    }
}