/* 畫圓挑戰遊戲 霓虹科幻風樣式表 */
:root {
    --bg-page: #070913;
    --bg-card: rgba(18, 22, 41, 0.8);
    --border-neon: rgba(0, 242, 254, 0.25);
    --text-main: #ffffff;
    --text-muted: #8f9bb3;
    
    --color-neon-blue: #00f2fe;
    --color-neon-green: #00f5a0;
    --color-neon-pink: #ff4757;
    --color-neon-yellow: #ffd32a;

    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* 應用容器 */
.app-container {
    width: 100%;
    max-width: 480px;
    min-height: calc(100vh - 44px);
    min-height: calc(100dvh - 44px);
    margin-top: 44px; /* 頂部導覽列空間 */
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important;
    gap: 16px;
    overflow-y: auto !important; /* 允許手機端超出高度時自由垂直滾動 */
}

/* 頂部資訊區 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 30%, var(--color-neon-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
    line-height: 1.1;
}

.subtitle-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

.best-score-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 14px;
    text-align: center;
    min-width: 85px;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.02);
}

.badge-label {
    display: block;
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--color-neon-blue);
    letter-spacing: 1.5px;
    margin-bottom: 2px;
}

.badge-val {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

/* 遊戲核心區 */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    flex-shrink: 0;
}

.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 20px;
    border: 2px solid var(--border-neon);
    background: radial-gradient(circle at center, rgba(16, 20, 38, 0.6) 0%, rgba(8, 10, 21, 0.9) 100%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 254, 0.08);
    overflow: hidden;
}

#circle-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.95rem;
    font-weight: 600;
    pointer-events: none;
    letter-spacing: 1px;
    text-align: center;
    padding: 8px 16px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: hintPulse 2s infinite ease-in-out;
    transition: opacity 0.4s ease;
}

.canvas-hint.fade-out {
    opacity: 0;
}

/* 儀表與控制區 */
.control-panel {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.score-display {
    display: flex;
    flex-direction: column;
}

.score-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.score-val {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--color-neon-blue);
    line-height: 1.1;
    margin: 2px 0;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.score-rating {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.score-rating.great {
    color: var(--color-neon-green);
    text-shadow: 0 0 8px rgba(0, 245, 160, 0.3);
}

.score-rating.good {
    color: var(--color-neon-yellow);
    text-shadow: 0 0 8px rgba(255, 211, 42, 0.3);
}

.score-rating.bad {
    color: var(--color-neon-pink);
    text-shadow: 0 0 8px rgba(255, 71, 87, 0.3);
}

/* 按鈕樣式 */
.primary-btn {
    background: linear-gradient(135deg, var(--color-neon-blue) 0%, #0056b3 100%);
    color: #000000;
    font-weight: 800;
    border: none;
    border-radius: 12px;
    padding: 12px 22px;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.25);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 242, 254, 0.4);
}

.primary-btn:active {
    transform: translateY(0) scale(0.97);
}

.reset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: none;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

/* 排行榜 */
.leaderboard-section {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 16px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.leaderboard-header h3 {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 12px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff 40%, var(--color-neon-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 8px 10px;
    text-align: center;
}

.leaderboard-table th {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

.leaderboard-table tr:last-child td {
    border-bottom: none;
}

/* 前三名高亮 */
.leaderboard-rank-1 { color: var(--color-neon-yellow); font-weight: 800; }
.leaderboard-rank-2 { color: #dcdde1; font-weight: 800; }
.leaderboard-rank-3 { color: #e58e26; font-weight: 800; }

.leaderboard-rank-1 td { background: rgba(255, 211, 42, 0.02); }

.game-instruction {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
    margin-top: 4px;
    flex-shrink: 0;
}

/* Modal 覆蓋與彈窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    animation: fadeIn 0.25s ease-out;
}

.modal-card {
    background: #0f1224;
    border: 2px solid var(--color-neon-blue);
    padding: 28px 24px;
    border-radius: 24px;
    width: 90%;
    max-width: 340px;
    box-shadow: 0 20px 50px rgba(0, 242, 254, 0.15), inset 0 0 15px rgba(255, 255, 255, 0.01);
    text-align: center;
    animation: pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.modal-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 18px;
}

.highlight-text {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-neon-green);
    text-shadow: 0 0 10px rgba(0, 245, 160, 0.3);
}

#player-name-input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.03);
    text-align: center;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 20px;
}

#player-name-input:focus {
    border-color: var(--color-neon-blue);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.85rem;
}

.secondary-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

/* 動畫與效果 */
@keyframes hintPulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}

@keyframes pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* 行動裝置極小螢幕適配 */
@media (max-width: 360px) {
    .app-container {
        padding: 12px 16px;
    }
    .logo-text {
        font-size: 1.5rem;
    }
    .score-val {
        font-size: 1.8rem;
    }
    .primary-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

/* ==========================================
   AdSense 廣告容器樣式與實測版型 (防誤觸與桌機/手機雙適配)
   ========================================== */
.ad-container-drawcircle {
    display: flex; /* 預設顯示，讓 AdSense SDK 可以測量可用寬高以正確加載廣告 */
    margin: 20px auto 4px auto; /* 與 Canvas 區域保持 20px 以上安全外距，防誤觸 */
    width: 100%;
    max-width: 320px; /* 手機端寬度 */
    min-height: 90px; /* CLS 預留高度 */
    height: 90px;
    background: transparent; /* 改為透明背景 */
    border-radius: 18px;
    justify-content: center;
    align-items: center;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
}

/* 如果是您的真實廣告，且 AdSense 明確回傳無廣告填充 (unfilled) 時，自動隱藏容器以釋放空間 */
.ad-container-drawcircle:has(ins[data-ad-status="unfilled"]),
.ad-container-drawcircle:has(ins[style*="display: none"]) {
    display: none !important;
    margin: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
}

/* 當螢幕寬度大於 520px (桌機或平板) 時，自動放大廣告區塊以適配桌機版面 */
@media (min-width: 520px) {
    .ad-container-drawcircle {
        max-width: 440px; /* 放寬桌機端的廣告最大寬度 */
        min-height: 100px; /* 提高桌機端的廣告高度，可容納 468x60 橫幅 */
        height: 100px;
    }
}

.ad-placeholder-text {
    position: absolute;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 1;
    text-align: center;
    padding: 0 10px;
}

.ad-container-drawcircle ins {
    position: relative;
    z-index: 2;
    background: transparent;
}

