/* 除法籃球 — 球場主題 */

:root {
    --court: #c2784a;
    --court-dark: #8b5330;
    --line: #fff8f0;
    --hoop-board: #2d3748;
    --hoop-rim: #ed8936;
    --accent: #e53e3e;
    --card-bg: rgba(255, 255, 255, 0.97);
    --success: #38a169;
    --error: #e53e3e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    min-height: 100vh;
    background: linear-gradient(180deg, #1a365d 0%, #2c5282 45%, var(--court) 45%);
    overflow-x: hidden;
}

.stars-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    opacity: 0.5;
    animation: twinkle 2.5s ease-in-out infinite;
}

.star-1 { top: 8%; left: 15%; }
.star-2 { top: 22%; right: 20%; animation-delay: 0.6s; }
.star-3 { top: 35%; left: 40%; animation-delay: 1.2s; }
.star-4 { top: 12%; right: 8%; animation-delay: 0.3s; }
.star-5 { top: 28%; left: 70%; animation-delay: 1s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.game-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 24px;
}

.screen {
    display: none;
    width: 100%;
    max-width: 520px;
    animation: fadeSlide 0.45s ease-out;
}

.screen.active {
    display: block;
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 登入 */
.login-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.title-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 8px;
}

.game-title {
    font-size: 26px;
    font-weight: 700;
    color: #2d3748;
}

.game-subtitle {
    color: #718096;
    margin-top: 8px;
    font-size: 15px;
}

.mascot-section {
    margin-bottom: 20px;
}

.mascot-preview {
    text-align: center;
    font-size: 48px;
    margin-bottom: 8px;
}

.section-label {
    text-align: center;
    font-size: 14px;
    color: #718096;
    margin-bottom: 12px;
}

.mascot-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.mascot-btn {
    font-size: 24px;
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s, border-color 0.15s;
}

.mascot-btn:hover {
    transform: scale(1.06);
}

.mascot-btn.selected {
    border-color: var(--accent);
    background: #fff5f5;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-size: 13px;
    color: #718096;
    margin-bottom: 6px;
}

.form-field select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
}

.start-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #e53e3e, #dd6b20);
    color: white;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}

.start-btn:active {
    transform: scale(0.98);
}

.login-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.link-item {
    color: #4299e1;
    font-size: 14px;
    font-weight: 600;
}

/* 遊戲 */
.game-panel {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #2d3748;
}

.player-mascot {
    font-size: 28px;
}

.round-badge, .score-badge {
    background: #edf2f7;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
}

.question-box {
    text-align: center;
    padding: 20px 16px;
    background: linear-gradient(135deg, #2b6cb0, #2c5282);
    border-radius: 16px;
    margin-bottom: 12px;
}

.question-text {
    font-size: clamp(26px, 6vw, 34px);
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.question-hint {
    margin-top: 10px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
}

.court-wrap {
    position: relative;
    background: linear-gradient(180deg, var(--court) 0%, #a06030 100%);
    border-radius: 16px;
    border: 4px solid var(--line);
    min-height: 320px;
    overflow: hidden;
    touch-action: none;
}

.court-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.35;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 48px,
        rgba(255, 248, 240, 0.4) 48px,
        rgba(255, 248, 240, 0.4) 52px
    );
}

.hoops-row {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 16px 8px 8px;
    gap: 8px;
}

.hoop-zone {
    flex: 1;
    text-align: center;
    max-width: 110px;
}

.backboard {
    background: var(--hoop-board);
    color: #fff;
    font-size: clamp(22px, 5vw, 30px);
    font-weight: 700;
    padding: 12px 8px;
    border-radius: 8px 8px 0 0;
    border: 3px solid #4a5568;
    box-shadow: 0 4px 0 #1a202c;
}

.rim {
    width: 56%;
    margin: 0 auto;
    height: 8px;
    background: var(--hoop-rim);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 0 #9c4221;
}

.hoop-zone.correct-flash .backboard {
    background: var(--success);
}

.hoop-zone.wrong-flash .backboard {
    background: var(--error);
}

.player-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 20px;
}

.player {
    font-size: 52px;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    user-select: none;
}

.swipe-hint {
    margin-top: 10px;
    font-size: 13px;
    color: var(--line);
    text-align: center;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.ball {
    position: fixed;
    width: 36px;
    height: 36px;
    background: radial-gradient(circle at 30% 30%, #fefcbf, #d69e2e 40%, #744210);
    border-radius: 50%;
    border: 2px solid #975a16;
    box-shadow: inset -4px -4px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.1s;
}

.ball.flying {
    opacity: 1;
    transition: transform 0.55s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.1s;
}

.feedback-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.feedback-overlay.show {
    display: flex;
}

.feedback-modal {
    background: #fff;
    padding: 32px 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.feedback-modal.correct .feedback-icon { color: var(--success); }
.feedback-modal.incorrect .feedback-icon { color: var(--error); }

.feedback-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.feedback-text {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

/* 結果 */
.result-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 28px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.result-header {
    text-align: center;
    margin-bottom: 20px;
}

.result-header h2 {
    font-size: 24px;
    color: #2d3748;
}

.trophy-icon {
    font-size: 56px;
}

.result-player {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.stats-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-box {
    background: #edf2f7;
    border-radius: 16px;
    padding: 16px 24px;
    text-align: center;
}

.stat-val {
    font-size: 28px;
    font-weight: 700;
    color: #2b6cb0;
}

.stat-label {
    font-size: 13px;
    color: #718096;
}

.result-msg {
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
    color: #4a5568;
}

.ranking-box {
    background: #f7fafc;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
}

.ranking-box h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #2d3748;
}

.ranking-list {
    max-height: 220px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 14px;
}

.ranking-item.current-user {
    outline: 2px solid #4299e1;
}

.ranking-loading {
    text-align: center;
    color: #718096;
    padding: 16px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-btn {
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.result-btn.primary {
    background: linear-gradient(135deg, #e53e3e, #dd6b20);
    color: #fff;
}

.result-btn.secondary {
    background: #edf2f7;
    color: #2d3748;
}

.result-btn.tertiary {
    background: transparent;
    color: #4299e1;
}

@media (max-width: 400px) {
    .mascot-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
