* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Microsoft YaHei",
        sans-serif;
    background: #0f172a;
    color: white;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    color: inherit;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}


/* =========================================================
   游戏大厅
   ========================================================= */

#homeScreen {
    background:
        radial-gradient(circle at 20% 10%, rgba(59, 130, 246, 0.25), transparent 30%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.2), transparent 30%),
        linear-gradient(135deg, #0f172a, #111827 50%, #172554);
}

.home-container {
    width: min(720px, 92%);
    margin: 0 auto;
    padding: 70px 0 30px;
}

.logo {
    text-align: center;
    margin-bottom: 45px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 10px;
    animation: floating 3s ease-in-out infinite;
}

.logo h1 {
    margin: 0;
    font-size: 38px;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo p {
    margin-top: 12px;
    color: #94a3b8;
    font-size: 16px;
}

.game-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-card {
    width: 100%;
    min-height: 145px;
    display: flex;
    align-items: center;
    text-align: left;
    padding: 25px;
    border-radius: 24px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    transition:
        transform 0.2s,
        border-color 0.2s,
        background 0.2s;
}

.game-card:hover {
    transform: translateY(-4px);
    background: rgba(51, 65, 85, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
}

.game-card:active {
    transform: scale(0.98);
}

.game-icon {
    width: 90px;
    height: 90px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
}

.game-info {
    margin-left: 22px;
    flex: 1;
}

.game-info h2 {
    margin: 0 0 8px;
    font-size: 23px;
}

.game-info p {
    margin: 0;
    color: #94a3b8;
    line-height: 1.5;
}

.play-arrow {
    font-size: 42px;
    color: #64748b;
    margin-left: 10px;
}

.footer-text {
    text-align: center;
    color: #64748b;
    margin-top: 35px;
    font-size: 13px;
}

@keyframes floating {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}


/* =========================================================
   游戏页面
   ========================================================= */

.game-screen {
    position: relative;
    background:
        radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.15), transparent 35%),
        #0f172a;
    min-height: 100vh;
}

.game-wrapper {
    width: min(600px, 94%);
    margin: 0 auto;
    padding: 25px 0 35px;
}

.game-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.game-header h2 {
    margin: 0 0 8px;
    font-size: 25px;
}

.score {
    font-size: 17px;
    color: #cbd5e1;
}

.score span {
    color: white;
    font-weight: 800;
}

.level {
    margin-top: 4px;
    font-size: 14px;
    color: #94a3b8;
}

.close-button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    font-size: 32px;
    line-height: 1;
    color: #cbd5e1;
    transition: 0.2s;
}

.close-button:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}

.close-button:active {
    transform: scale(0.9);
}


/* =========================================================
   贪吃蛇
   ========================================================= */

.snake-board-container {
    width: min(500px, 100%);
    aspect-ratio: 1;
    margin: 0 auto;
    background: #020617;
    border: 3px solid #334155;
    border-radius: 15px;
    padding: 5px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#snakeCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 9px;
}

.control-tip {
    text-align: center;
    margin: 17px 0;
    color: #64748b;
    font-size: 13px;
}

.mobile-controls {
    user-select: none;
    touch-action: manipulation;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-button {
    width: 70px;
    height: 60px;
    border-radius: 16px;
    background: #1e293b;
    border: 1px solid #334155;
    font-size: 30px;
    font-weight: bold;
    box-shadow: 0 6px 0 #0f172a;
    transition: transform 0.08s, box-shadow 0.08s;
}

.control-button:active {
    transform: translateY(5px);
    box-shadow: 0 1px 0 #0f172a;
    background: #334155;
}


/* =========================================================
   俄罗斯方块
   ========================================================= */

.tetris-wrapper {
    width: min(650px, 95%);
}

.tetris-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
}

.tetris-board-container {
    width: min(300px, 68vw);
    aspect-ratio: 1 / 2;
    background: #020617;
    border: 3px solid #334155;
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#tetrisCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.next-piece {
    width: 115px;
    min-height: 130px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #334155;
    border-radius: 15px;
    padding: 10px;
    text-align: center;
}

.next-title {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 8px;
}

#nextCanvas {
    width: 95px;
    height: 95px;
}

.rotate-button {
    font-size: 34px;
}

.drop-button {
    min-width: 210px;
    height: 52px;
    padding: 0 25px;
    border-radius: 15px;
    background: #1e293b;
    border: 1px solid #334155;
    font-size: 17px;
    font-weight: bold;
    box-shadow: 0 5px 0 #0f172a;
}

.drop-button:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #0f172a;
}


/* =========================================================
   游戏结束
   ========================================================= */

.game-over-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(8px);
}

.game-over-overlay.show {
    display: flex;
}

.game-over-box {
    position: relative;
    width: min(390px, 100%);
    padding: 38px 30px 30px;
    text-align: center;
    border-radius: 28px;
    background: #1e293b;
    border: 1px solid #475569;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    animation: popup 0.2s ease-out;
}

.result-close {
    position: absolute;
    top: 14px;
    right: 14px;
}

.result-icon {
    font-size: 58px;
    margin-bottom: 8px;
}

.game-over-box h2 {
    margin: 5px 0 8px;
    font-size: 28px;
}

.game-over-box p {
    margin: 0;
    color: #94a3b8;
}

.final-score {
    margin: 10px 0 25px;
    font-size: 55px;
    font-weight: 900;
}

.restart-button,
.back-button {
    display: block;
    width: 100%;
    height: 52px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: bold;
    margin-top: 10px;
}

.restart-button {
    background: #2563eb;
}

.restart-button:hover {
    background: #3b82f6;
}

.back-button {
    background: #334155;
}

.back-button:hover {
    background: #475569;
}

@keyframes popup {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* =========================================================
   手机适配
   ========================================================= */

@media (max-width: 600px) {

    .home-container {
        padding-top: 45px;
    }

    .logo {
        margin-bottom: 30px;
    }

    .logo-icon {
        font-size: 52px;
    }

    .logo h1 {
        font-size: 30px;
    }

    .game-card {
        min-height: 125px;
        padding: 18px;
        border-radius: 20px;
    }

    .game-icon {
        width: 70px;
        height: 70px;
        font-size: 38px;
        border-radius: 18px;
    }

    .game-info {
        margin-left: 15px;
    }

    .game-info h2 {
        font-size: 19px;
    }

    .game-info p {
        font-size: 13px;
    }

    .play-arrow {
        font-size: 34px;
    }

    .game-wrapper {
        padding-top: 15px;
    }

    .game-header h2 {
        font-size: 22px;
    }

    .close-button {
        width: 42px;
        height: 42px;
        font-size: 29px;
    }

    .control-button {
        width: 64px;
        height: 56px;
    }

    .tetris-area {
        gap: 10px;
    }

    .next-piece {
        width: 90px;
        min-height: 110px;
    }

    #nextCanvas {
        width: 75px;
        height: 75px;
    }

}


/* 非常小的手机 */

@media (max-width: 380px) {

    .game-card {
        padding: 14px;
    }

    .game-icon {
        width: 58px;
        height: 58px;
        font-size: 30px;
    }

    .game-info {
        margin-left: 10px;
    }

    .game-info h2 {
        font-size: 17px;
    }

    .game-info p {
        font-size: 12px;
    }

    .control-button {
        width: 58px;
        height: 52px;
    }

    .tetris-board-container {
        width: 63vw;
    }

    .next-piece {
        width: 78px;
    }

  }
