/* 通用樣式 - 可以與之前的遊戲相似或重新設計 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e; /* 深邃星空藍 */
    color: #e0e0e0; /* 柔和的淺灰色文字 */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.container {
    background-color: rgba(23, 23, 43, 0.85); /* 半透明深藍紫色背景 */
    border: 1px solid rgba(128, 128, 255, 0.3); /* 淡紫色邊框 */
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 420px;
    text-align: center;
    margin: auto;
}

h1 {
    color: #9fa8da; /* 淡雅的靛藍色 */
    font-weight: 700;
    font-size: 2em;
    text-shadow: 0 0 8px rgba(159, 168, 218, 0.6);
    margin-bottom: 15px;
}
h2 {
    color: #9fa8da;
    font-weight: 600;
    font-size: 1.3em;
    text-shadow: 0 0 5px rgba(159, 168, 218, 0.5);
    margin-top: 20px;
    margin-bottom: 10px;
}

label {
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
    font-weight: 500;
    text-align: left;
    color: #c5cae9; /* 更淺的靛藍 */
    font-size: 0.9em;
}

input[type="text"],
input[type="password"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid rgba(128, 128, 255, 0.4);
    background-color: rgba(30, 30, 50, 0.9); /* 深藍紫輸入框背景 */
    color: #e0e0e0;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: rgba(197, 202, 233, 0.7);
}
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: #9fa8da;
    box-shadow: 0 0 0 0.2rem rgba(159, 168, 218, 0.25);
    outline: none;
}

button {
    background: linear-gradient(45deg, #7e57c2, #512da8); /* 紫色漸層 */
    color: white;
    padding: 10px 18px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    margin: 10px 5px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(126, 87, 194, 0.4);
}
button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(126, 87, 194, 0.5);
}
button:active {
    transform: translateY(0px) scale(1);
    box-shadow: 0 2px 10px rgba(126, 87, 194, 0.3);
}
button:disabled {
    background: #54546e; /* 禁用時的深灰色 */
    color: #a0a0b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-message { color: #ef9a9a; margin-top: 8px; font-size: 0.85em; } /* 淡紅色錯誤訊息 */
.success-message { color: #a5d6a7; margin-top: 8px; font-size: 0.85em; } /* 淡綠色成功訊息 */
.info-message { color: #81d4fa; margin-top: 10px; font-size: 0.9em; min-height: 1.5em; } /* 淡藍色資訊訊息 */

/* CAPTCHA 驗證碼樣式 */
#captcha-container { margin-bottom: 15px; text-align: left; }
.captcha-line { display: flex; align-items: center; }
#captchaInput { width: 80px; padding: 8px; font-size: 0.9em; margin-right: 8px;}
.captcha-display { padding: 8px 12px; font-size: 1.1em; margin-right: 8px; background-color: #303f9f; border-radius: 4px;} /* 深靛藍背景 */
.captcha-refresh-btn { padding: 6px 8px; font-size: 1.1em; background: #5e35b1;} /* 深紫色刷新按鈕 */
.captcha-refresh-btn:hover { background-color: #4527a0; }

/* 遊戲區域特定樣式 */
#game-section, #leaderboard-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(128, 128, 255, 0.2);
}

.game-info {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1em;
    font-weight: 500;
    flex-wrap: wrap;
}
.game-info span {
    background-color: rgba(30, 30, 50, 0.7);
    border: 1px solid rgba(128, 128, 255, 0.2);
    padding: 6px 12px;
    border-radius: 14px;
    color: #e0e0e0;
    margin: 4px;
    min-width: 70px;
}

#gridContainer {
    display: grid;
    /* grid-template-columns will be set by JS */
    gap: 5px; /* 格子之間的間隙 */
    width: 90%;
    max-width: 320px; /* 限制最大寬度 */
    margin: 20px auto;
    padding: 10px;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid rgba(128, 128, 255, 0.1);
    border-radius: 8px;
    aspect-ratio: 1 / 1; /* 保持正方形 */
}

.grid-cell {
    background-color: rgba(79, 83, 138, 0.3); /* 格子預設顏色 */
    border: 1px solid rgba(128, 128, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease-out, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-cell:hover:not(.disabled):not(.path-active):not(.player-input) {
    background-color: rgba(100, 105, 170, 0.5);
}

.grid-cell.path-active { /* 電腦顯示路徑時的樣式 */
    background-color: #80deea; /* 明亮的青色 */
    box-shadow: 0 0 15px #80deea, 0 0 20px #80deea inset;
    transform: scale(1.05);
}
.grid-cell.path-start-indicator { /* 玩家開始輸入時，提示第一個格子的樣式 */
    background-color: #ce93d8; /* 淡紫色提示 */
    box-shadow: 0 0 10px #ce93d8;
}

.grid-cell.player-correct { /* 玩家點擊正確時的樣式 */
    background-color: #a5d6a7; /* 淡綠色 */
    transform: scale(0.95);
}
.grid-cell.player-incorrect { /* 玩家點擊錯誤時的樣式 */
    background-color: #ef9a9a; /* 淡紅色 */
    animation: shake 0.3s;
}
.grid-cell.disabled { /* 遊戲非玩家輸入階段的樣式 */
    cursor: not-allowed;
    opacity: 0.7;
}


@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}


/* 排行榜樣式 */
.leaderboard-filters button { background: #5e35b1; margin-bottom: 10px; } /* 深紫色篩選按鈕 */
.leaderboard-filters button:hover { background-color: #4527a0; }
#leaderboardTable { width: 100%; border-collapse: collapse; margin-top: 10px; background-color: rgba(30, 30, 50,0.5); font-size: 0.85em; }
#leaderboardTable th, #leaderboardTable td { border: 1px solid rgba(128, 128, 255,0.2); padding: 6px; text-align: left; }
#leaderboardTable th { background-color: #5e35b1; color: white; text-align: center; font-weight: 600; }
#leaderboardTable tbody tr:nth-child(even) { background-color: rgba(40, 40, 60,0.7); }


/* Media Queries for smaller screens */
@media (max-width: 380px) {
    .container { padding: 15px; }
    h1 { font-size: 1.6em; }
    h2 { font-size: 1.1em; }
    button { padding: 8px 15px; font-size: 0.9em; }
    .game-info { font-size: 0.9em; }
    .game-info span { padding: 5px 10px; }
    #gridContainer { width: 95%; gap: 3px; padding: 5px;}
    #leaderboardTable { font-size: 0.75em; }
    #leaderboardTable th, #leaderboardTable td { padding: 4px; }
}