/* 遊戲專屬樣式 */
:root {
    --primary-color: #1abc9c;
    --primary-hover: #16a085;
    --bg-dark: #0f172a;
    --text-light: #f8fafc;
    --tile-gap: 8px;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 遊戲主容器 */
.app-container {
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 頂部標頭與操作區 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 4px 0;
}

.game-header .logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--primary-color);
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #1abc9c, #2ecc71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* 遊戲主體區域 */
.game-layout {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
}

.game-container {
    width: 100%;
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

/* 狀態列 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 700;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #e74c3c;
}

.score-box {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f1c40f;
}

/* 進度條容器 */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #e74c3c, #f1c40f);
    border-radius: 4px;
    transition: width 0.1s linear;
}

/* 色塊遊戲板 */
.game-board {
    display: grid;
    gap: var(--tile-gap);
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 8px;
    box-sizing: border-box;
}

.tile {
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.05s ease, opacity 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.15), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tile:active {
    transform: scale(0.95);
}

/* 各個畫面切換 */
.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 320px;
    text-align: center;
}

.screen.hidden {
    display: none !important;
}

/* 開始畫面 */
.start-screen h2 {
    font-size: 2rem;
    margin: 0 0 10px;
    color: var(--text-light);
}

.start-screen p {
    color: #94a3b8;
    margin: 0 0 24px;
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 340px;
}

/* 按鈕樣式 */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 36px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #2ecc71);
    color: #111827;
    box-shadow: 0 10px 20px rgba(26, 188, 156, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(26, 188, 156, 0.4);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* 遊戲結束畫面 */
.over-screen h2 {
    font-size: 2rem;
    margin: 0 0 8px;
    color: #e74c3c;
}

.result-score {
    font-size: 3.5rem;
    font-weight: 900;
    margin: 10px 0;
    color: #f1c40f;
    line-height: 1;
}

.result-rank {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 24px;
    background: rgba(26, 188, 156, 0.1);
    padding: 8px 16px;
    border-radius: 99px;
    border: 1px solid rgba(26, 188, 156, 0.2);
}

/* 排行榜登錄面板 */
.record-panel {
    width: 100%;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    box-sizing: border-box;
}

.record-panel .glow-text {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fbbf24;
    margin-bottom: 12px;
    animation: pulse 1.5s infinite;
}

.record-panel input {
    width: 100%;
    height: 42px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    padding: 0 12px;
    font-size: 1rem;
    text-align: center;
    box-sizing: border-box;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.record-panel input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.25);
}

.record-panel button {
    width: 100%;
}

.over-screen .actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    justify-content: center;
}

.over-screen .actions button {
    flex: 1;
}

/* 遊戲指南 */
.game-instruction {
    margin-top: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.6;
    text-align: center;
}

.game-instruction strong {
    color: #94a3b8;
}

/* 動畫效果 */
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1); opacity: 0.9; }
}

/* 為了在大螢幕下有更好的展示，開始畫面的排行榜 */
.start-leaderboard-section {
    width: 100%;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.start-leaderboard-section h3 {
    font-size: 1rem;
    color: #94a3b8;
    margin: 0 0 10px;
    font-weight: 700;
}

/* 調整圓角大小以適應不同的格子密度 */
.game-board.lv1 { --tile-gap: 12px; }
.game-board.lv1 .tile { border-radius: 10px; }

.game-board.lv2 { --tile-gap: 10px; }
.game-board.lv2 .tile { border-radius: 8px; }

.game-board.lv3 { --tile-gap: 8px; }
.game-board.lv3 .tile { border-radius: 6px; }

.game-board.lv4 { --tile-gap: 6px; }
.game-board.lv4 .tile { border-radius: 5px; }

.game-board.lv5 { --tile-gap: 5px; }
.game-board.lv5 .tile { border-radius: 4px; }

.game-board.lv6 { --tile-gap: 4px; }
.game-board.lv6 .tile { border-radius: 3px; }

.game-board.lv7 { --tile-gap: 3px; }
.game-board.lv7 .tile { border-radius: 3px; }

@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }
    .game-container {
        padding: 14px;
    }
    .start-screen h2, .over-screen h2 {
        font-size: 1.6rem;
    }
    .result-score {
        font-size: 3rem;
    }
}
