* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #121a2c, #2c3e50);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    animation: backgroundGradient 20s ease infinite alternate;
    flex-direction: column;
}

.menu-back-link {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1200;
    color: #ffffff;
    background-color: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(0, 191, 255, 0.45);
    border-radius: 8px;
    padding: 10px 14px;
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.menu-back-link:hover {
    background-color: rgba(0, 191, 255, 0.25);
}

@keyframes backgroundGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.main-container {
    display: flex;
    width: 100%;
    max-width: 800px;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.game-container {
    position: relative;
    width: 540px;
    height: 720px;
    background-color: #000000;
    box-shadow: 0 15px 35px rgba(0, 191, 255, 0.5);
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s;
    flex-shrink: 0;
}

.game-container:hover {
    transform: translateY(-5px);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10;
    border-radius: 15px;
    display: none;
}

.screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #00bfff;
    text-shadow: 0 0 10px rgba(0, 191, 255, 0.7);
}

.screen p {
    font-size: 20px;
    margin: 10px 0;
    color: #ffffff;
}

/* 大魏老師資訊課程按鈕樣式 */
.course-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 15px;
    background-color: rgba(0, 191, 255, 0.3);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 191, 255, 0.5);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    width: 100%;
}

.course-btn:hover {
    background-color: rgba(0, 191, 255, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.4);
}

.course-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* 遊戲說明區域 */
.game-info-corner {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.game-info-content {
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    padding: 20px;
    color: white;
    max-width: 350px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* 添加切換按鈕樣式 */
.toggle-info-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #3a7bfd;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transition: all 0.3s ease;
}

.toggle-info-btn:hover {
    background-color: #2563eb;
}

/* 收起狀態的樣式 */
.game-info-corner.collapsed .game-info-content {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    pointer-events: none;
}

.game-info-corner.collapsed .toggle-info-btn {
    transform: rotate(0deg);
}

/* 展開狀態的樣式 */
.game-info-corner.expanded .toggle-info-btn {
    transform: rotate(45deg);
}

.game-info-content h3 {
    color: #4CA6B0;
    margin-bottom: 8px;
    font-size: 16px;
    text-align: center;
    text-shadow: 0 0 5px rgba(76, 166, 176, 0.5);
    border-bottom: 1px solid rgba(76, 166, 176, 0.3);
    padding-bottom: 6px;
}

.game-info-content p {
    margin: 3px 0;
    font-size: 12px;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.player-controls {
    margin: 8px 0;
    padding: 6px;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.3);
}

.player-controls h4 {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: #00bfff;
    display: flex;
    align-items: center;
}

.player-controls h4::before {
    content: "▶";
    margin-right: 5px;
    font-size: 10px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
}

.control-key {
    background-color: rgba(0, 191, 255, 0.15);
    border: 1px solid rgba(0, 191, 255, 0.3);
    padding: 1px 5px;
    border-radius: 4px;
    margin-right: 5px;
    font-family: monospace;
    font-weight: bold;
    font-size: 11px;
    color: #fff;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

.control-action {
    flex: 1;
    color: #cccccc;
    font-size: 11px;
}

.game-start {
    margin: 8px 0 10px 0;
    text-align: center;
    font-weight: bold;
    color: #ffcc00;
}

.game-info-content .course-btn {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.teacher-icon {
    margin-right: 4px;
    font-size: 14px;
    animation: floatEffect 2s ease-in-out infinite alternate;
    display: inline-block;
}

.teacher-text {
    display: inline-block;
    vertical-align: middle;
    font-size: 12px;
}

/* 媒體查詢 - 平板 */
@media (max-width: 1100px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-info-corner {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: auto;
        max-width: 250px;
    }
}

/* 媒體查詢 - 手機 */
@media (max-width: 850px) {
    .game-container {
        width: 100%;
        height: 600px;
        border-radius: 10px;
    }
    
    .game-info-corner {
        max-width: 200px;
        padding: 15px;
    }
    
    .game-info-content h3 {
        font-size: 18px;
    }
    
    .game-info-content p {
        font-size: 14px;
    }
    
    .game-info-corner {
        max-width: 200px;
        padding: 15px;
    }
    
    .game-info-content h3 {
        font-size: 18px;
    }
    
    .game-info-content p {
        font-size: 14px;
    }
    
    #hudOverlay {
        font-size: 18px;
        top: 15px;
        left: 15px;
    }
    
    .audio-control {
        top: 15px;
        right: 15px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* 音效控制按鈕位置調整 */
.audio-control {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 15;
}

.control-btn {
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 191, 255, 0.5);
    border-radius: 50%;
    color: #00bfff;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:hover {
    background-color: rgba(0, 191, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes floatEffect {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

/* 雙人模式樣式 */
.dual-mode {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    max-width: 1400px;
    margin: 0 auto;
}

.player-container {
    width: 48%;
    text-align: center;
    margin: 10px;
}

.player-container h2 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 1.5rem;
    text-shadow: 0 0 5px #00f, 0 0 10px #00f;
}

.winner-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 30px 50px;
    border-radius: 20px;
    text-align: center;
    z-index: 1000;
    display: none;
    animation: winnerAppear 3s ease-in-out;
    border: 2px solid #00bfff;
    box-shadow: 0 0 30px #00f, inset 0 0 15px rgba(0, 191, 255, 0.3);
    min-width: 300px;
    opacity: 0;
}

.winner-display h1 {
    font-size: 32px;
    margin-bottom: 15px;
    color: white;
    text-shadow: 0 0 10px #00bfff, 0 0 20px #00bfff, 0 0 30px #00bfff;
    letter-spacing: 1px;
}

.winner-display #winnerName {
    font-size: 38px;
    font-weight: bold;
    display: inline-block;
    padding: 5px 15px;
    margin: 0 5px;
    background-color: rgba(0, 191, 255, 0.1);
    border-radius: 10px;
    animation: winnerNamePulse 1s infinite alternate;
}

@keyframes winnerAppear {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

@keyframes winnerNamePulse {
    0% { text-shadow: 0 0 10px #00bfff, 0 0 20px #00bfff; }
    100% { text-shadow: 0 0 15px #00bfff, 0 0 25px #00bfff, 0 0 35px #00bfff; }
}

.match-info {
    width: 90%;
    max-width: 400px;
    text-align: center;
    color: #fff;
    margin: 20px auto;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.3), inset 0 0 10px rgba(0, 191, 255, 0.1);
    border: 1px solid rgba(0, 191, 255, 0.3);
    animation: glowPulse 3s infinite alternate;
    transition: all 0.3s ease;
}

.match-info:hover {
    box-shadow: 0 0 25px rgba(0, 191, 255, 0.6), inset 0 0 15px rgba(0, 191, 255, 0.2);
    transform: translateY(-3px);
}

.match-info h2 {
    font-size: 22px;
    margin-bottom: 15px;
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.7);
    color: #00bfff;
}

.match-score {
    font-size: 38px;
    margin: 10px 0;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.match-score::before,
.match-score::after {
    content: "•";
    font-size: 16px;
    color: rgba(255, 255, 255, 0.4);
}

#player1Wins, #player2Wins {
    min-width: 30px;
    padding: 5px 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

#player1Wins {
    color: #ff9900;
    background-color: rgba(255, 153, 0, 0.1);
    box-shadow: 0 0 10px rgba(255, 153, 0, 0.3);
    border: 1px solid rgba(255, 153, 0, 0.3);
}

#player2Wins {
    color: #00ffff;
    background-color: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.match-score span[id$="Wins"] {
    position: relative;
}

.match-score span[id$="Wins"]::after {
    content: "勝";
    position: absolute;
    font-size: 12px;
    top: -5px;
    right: -5px;
    color: rgba(255, 255, 255, 0.7);
}

#matchStatus {
    font-size: 18px;
    font-weight: 500;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 15px rgba(0, 191, 255, 0.3), inset 0 0 5px rgba(0, 191, 255, 0.1); }
    100% { box-shadow: 0 0 25px rgba(0, 191, 255, 0.5), inset 0 0 10px rgba(0, 191, 255, 0.3); }
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* 適配小屏幕設備的雙人模式 */
@media (max-width: 1200px) {
    .player-container {
        width: 90%;
        max-width: 540px;
        margin: 20px auto;
    }

    .dual-mode {
        flex-direction: column;
        align-items: center;
    }

    .player-container .game-container {
        height: 600px;
    }

    .match-info {
        margin-bottom: 20px;
    }
}

@media (max-width: 600px) {
    .player-container .game-container {
        height: 500px;
    }
    
    .game-info-corner {
        max-width: 160px;
        font-size: 10px;
        padding: 8px;
        bottom: 10px;
        right: 10px;
    }
    
    .game-info-content h3 {
        font-size: 14px;
        margin-bottom: 6px;
        padding-bottom: 4px;
    }
    
    .player-controls {
        margin: 6px 0;
        padding: 4px;
    }
    
    .player-controls h4 {
        font-size: 12px;
    }
    
    .control-key {
        font-size: 10px;
        padding: 0 3px;
        min-width: 12px;
    }
    
    .control-action {
        font-size: 10px;
    }
    
    .game-start {
        margin: 6px 0 8px 0;
        font-size: 11px;
    }
    
    .game-info-content .course-btn {
        margin-top: 6px;
        padding: 6px 8px;
        font-size: 10px;
    }
    
    .hudOverlay {
        font-size: 14px;
    }
}

/* 修改遊戲畫布尺寸以適應雙人模式 */
.player-container .game-container {
    width: 100%;
    height: 650px;
    min-width: 350px;
}

.player-container .game-canvas {
    max-width: 100%;
    max-height: 100%;
}

/* 調整HUD位置 */
.hudOverlay {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 16px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hudOverlay div {
    margin-bottom: 3px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 6px 15px;
    border-radius: 20px;
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.3), inset 0 0 5px rgba(0, 191, 255, 0.1);
    border: 1px solid rgba(0, 191, 255, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    min-width: 130px;
}

.hudOverlay div:hover {
    transform: translateX(5px);
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.5), inset 0 0 8px rgba(0, 191, 255, 0.2);
    background-color: rgba(0, 0, 0, 0.7);
}

/* 分數顯示樣式 */
#score1, #score2 {
    color: #ff9900;
    font-weight: bold;
}

/* 速度顯示樣式 */
#level1, #level2 {
    color: #00ffff;
    font-weight: bold;
}

/* 消除行數顯示樣式 */
#lines1, #lines2 {
    color: #ff66cc;
    font-weight: bold;
}

/* 數字部分樣式 */
.hudOverlay div::after {
    content: attr(data-value);
    margin-left: auto;
    font-weight: bold;
    font-size: 18px;
    background-color: rgba(0, 0, 0, 0.4);
    padding: 2px 10px;
    border-radius: 10px;
    min-width: 40px;
    text-align: center;
}

/* 姓名輸入區域樣式 */
.name-input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(10, 20, 40, 0.85);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 191, 255, 0.4), inset 0 0 15px rgba(0, 191, 255, 0.1);
    border: 1px solid rgba(0, 191, 255, 0.4);
    margin-bottom: 30px;
    width: 90%;
    max-width: 500px;
}

.name-input-section h2 {
    color: #00bfff;
    margin-bottom: 25px;
    font-size: 28px;
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.7);
}

.input-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.input-group label {
    color: #d0f0ff;
    font-size: 16px;
    margin-right: 10px;
    width: 60px;
    text-align: right;
}

.input-group input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(0, 191, 255, 0.3);
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group input[type="text"]:focus {
    border-color: #00bfff;
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.5);
}

.start-game-btn {
    padding: 12px 30px;
    margin-top: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(145deg, #007bff, #00bfff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.start-game-btn:hover {
    background: linear-gradient(145deg, #0056b3, #008fcc);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.6);
    transform: translateY(-2px);
}

.start-game-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.4);
}

/* 方塊預覽區域容器 (包含 Next 和 Hold) */
.preview-area {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 5;
}

/* 通用預覽框樣式 */
.preview-box {
    width: 120px;
    height: 120px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 191, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-box h3 {
    text-align: center;
    margin-bottom: 5px;
    color: #00bfff;
    font-size: 16px;
    text-shadow: 1px 1px 2px #000000;
    width: 100%;
    display: flex; 
    justify-content: center;
    align-items: baseline;
}

.preview-box canvas {
    width: 100px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

/* Hold Piece 預覽框特定樣式 */
.hold-piece-preview {
    border-color: rgba(255, 153, 0, 0.4); /* 橙色邊框 */
}

.hold-piece-preview h3 {
    color: #ff9900; /* 橙色標題 */
}

.hold-key-shortcut {
    font-size: 11px;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 5px;
    font-family: monospace;
} 
