/* 全球港口拼词游戏 - 响应式样式（含错题本内联重拼 + 地图链接） */
:root {
    --bg: #0a1628;
    --bg-card: #12243a;
    --bg-input: #0f1d30;        /* 输入框比卡片更深，避免“浮起来” */
    --primary: #2f9bff;         /* 主色：偏蓝，按钮更醒目 */
    --primary-dark: #1b7ae0;
    --accent: #ffb020;          /* 强调：琥珀，用于地图/等级/错题提示 */
    --success: #35d07f;
    --danger: #ff6b5e;          /* 珊瑚红，比纯红柔和 */
    --warning: #ffb020;
    --text: #eaf2fb;
    --text-muted: #8fa6bd;
    --border: #1e3a5f;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --radius: 16px;
    --font: 'Noto Sans SC', system-ui, sans-serif;
    --font-display: 'Orbitron', sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    background:
        radial-gradient(ellipse at 20% 0%, rgba(47, 155, 255, 0.16) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(255, 176, 32, 0.08) 0%, transparent 40%),
        var(--bg);
    min-height: 100vh;
}

.app {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px 16px 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.6rem; }
.logo h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px; }

.stats { display: flex; gap: 8px; flex-wrap: wrap; }

.stat-item {
    text-align: center;
    background: var(--bg-card);
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    min-width: 52px;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
}

.wrong-book-btn {
    cursor: pointer;
    transition: all 0.2s;
    border-color: rgba(255, 107, 94, 0.4) !important;
}

.wrong-book-btn:hover {
    background: rgba(255, 107, 94, 0.15);
    border-color: var(--danger) !important;
}

.wrong-book-btn .stat-value { color: var(--danger); }

/* Level Progress */
.level-progress {
    position: relative;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Screens */
.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.screen.active { display: flex; }

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

/* Start Screen */
.hero { text-align: center; padding: 24px 0 32px; }
.ship-icon { font-size: 4rem; margin-bottom: 12px; animation: float 3s ease-in-out infinite; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero h2 { font-size: 1.5rem; margin-bottom: 8px; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 6px; }
.tip { font-size: 0.8rem; color: var(--primary); opacity: 0.85; }

.difficulty-select { margin-bottom: 28px; text-align: center; }
.difficulty-select label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.diff-btns { display: flex; gap: 10px; justify-content: center; }

.diff-btn {
    flex: 1;
    max-width: 100px;
    padding: 10px 0;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover { border-color: var(--primary); }

.diff-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(47, 155, 255, 0.35);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 16px rgba(47, 155, 255, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(47, 155, 255, 0.45);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    margin-top: 12px;
}

.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover { border-color: var(--warning); color: var(--warning); }

.btn-lg {
    padding: 14px 36px;
    font-size: 1.1rem;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: 8px; }

#startBtn, #resetBtn, #practiceWrongBtn {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Play Screen */
.question-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mode-tag {
    align-self: flex-start;
    background: rgba(255, 176, 32, 0.18);
    color: var(--warning);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 10px;
}

/* 国别 + 地图链接 */
.country-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.country-badge {
    display: inline-block;
    background: rgba(47, 155, 255, 0.15);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.map-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid rgba(255, 176, 32, 0.4);
    border-radius: 14px;
    padding: 3px 10px;
    transition: all 0.2s;
}

.map-link:hover {
    background: rgba(255, 176, 32, 0.12);
    border-color: var(--accent);
}

.hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    min-height: 1.4em;
}

.blanks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 28px;
    min-height: 52px;
}

.letter-slot {
    width: 36px;
    height: 44px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    transition: all 0.2s;
}

.letter-slot.filled {
    border-color: var(--primary);
    background: rgba(47, 155, 255, 0.1);
    color: var(--primary);
}

.letter-slot.space { width: 16px; background: transparent; border: none; }

.letter-slot.correct {
    border-color: var(--success);
    background: rgba(53, 208, 127, 0.15);
    color: var(--success);
}

.letter-slot.wrong {
    border-color: var(--danger);
    background: rgba(255, 107, 94, 0.15);
    color: var(--danger);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.input-area { display: flex; gap: 10px; margin-bottom: 16px; }

#answerInput {
    flex: 1;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#answerInput:focus { border-color: var(--primary); }

#answerInput::placeholder { color: var(--text-muted); opacity: 0.6; }

.feedback {
    min-height: 28px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.feedback.correct { color: var(--success); }
.feedback.wrong { color: var(--danger); }

.actions { display: flex; gap: 12px; justify-content: center; margin-top: auto; }
.actions .btn { flex: 1; max-width: 160px; }

/* Timer */
.timer-bar {
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    margin-top: 16px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: var(--primary);
    transition: width 0.1s linear;
}

.timer-fill.warning { background: var(--warning); }
.timer-fill.danger { background: var(--danger); }

/* Wrong Book Screen */
.wrong-book-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}

.wb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wb-header h2 { font-size: 1.3rem; }

.wb-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }

.wb-stats {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.wb-stats strong { color: var(--accent); }

.wb-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 错题本条目：直接显示答案 + 地图 + 内联输入 */
.wb-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    transition: all 0.2s;
}

.wb-item.mastered { opacity: 0.6; background: rgba(53, 208, 127, 0.06); }

.wb-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wb-answer {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--accent);
}

.wb-cn { font-size: 0.78rem; color: var(--text-muted); }

.wb-tag {
    font-size: 0.7rem;
    background: rgba(53, 208, 127, 0.18);
    color: var(--success);
    border-radius: 8px;
    padding: 1px 8px;
    margin-left: auto;
}

.wb-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 6px 0 8px;
    flex-wrap: wrap;
}

.wb-country { color: var(--text-muted); }
.wb-wrong-count { margin-left: auto; color: var(--danger); }

.wb-item-input { display: flex; gap: 8px; }

.wb-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 1px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.wb-input:focus { border-color: var(--primary); }

.wb-input:disabled {
    background: rgba(53, 208, 127, 0.08);
    color: var(--success);
    border-color: rgba(53, 208, 127, 0.3);
}

.wb-input::placeholder { color: var(--text-muted); opacity: 0.55; letter-spacing: 2px; }

.wb-item-feedback {
    font-size: 0.78rem;
    margin-top: 6px;
    min-height: 16px;
}

.wb-item-feedback.ok { color: var(--success); }
.wb-item-feedback.err { color: var(--danger); }

.wb-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.wb-item-actions button {
    padding: 5px 10px;
    font-size: 0.72rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.wb-item-actions .btn-master:hover { border-color: var(--success); color: var(--success); }
.wb-item-actions .btn-remove:hover { border-color: var(--danger); color: var(--danger); }

.wb-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; }

.wb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wb-actions .btn { flex: 1; min-width: 120px; }

/* Result Screen */
.result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin: auto 0;
}

.result-icon { font-size: 3.5rem; margin-bottom: 16px; }
.result-card h2 { font-size: 1.6rem; margin-bottom: 8px; }
#resultMsg { color: var(--text-muted); margin-bottom: 28px; }

.result-stats { display: flex; justify-content: center; gap: 40px; margin-bottom: 32px; }
.result-stats div { text-align: center; }

.result-stats span {
    display: block;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

.result-stats small { font-size: 0.8rem; color: var(--text-muted); }

/* Footer */
.footer {
    text-align: center;
    padding: 16px 0 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Responsive */
@media (min-width: 640px) {
    .app { padding: 24px 20px 32px; }
    .logo h1 { font-size: 1.4rem; }
    .hero h2 { font-size: 1.8rem; }
    .ship-icon { font-size: 5rem; }
    .letter-slot { width: 42px; height: 50px; font-size: 1.4rem; }
    .question-card { padding: 32px 28px; }
}

@media (max-width: 400px) {
    .stats { gap: 4px; }
    .stat-item { padding: 4px 6px; min-width: 44px; }
    .stat-value { font-size: 0.9rem; }
    .letter-slot { width: 30px; height: 38px; font-size: 1.1rem; }
    .diff-btns { gap: 6px; }
    .wb-item-input { flex-direction: column; }
    .wb-item-input .btn { width: 100%; }
    .wb-item-actions { justify-content: space-between; }
}

@media (hover: none) {
    .btn:hover { transform: none; }
}
/* 地区多选 */
.region-select { margin-bottom: 28px; text-align: center; }
.region-select label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.region-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.region-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.region-btn:hover { border-color: var(--primary); color: var(--text); }

.region-btn.active {
    background: rgba(47, 155, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(47, 155, 255, 0.2);
}

@media (max-width: 400px) {
    .region-btns { gap: 6px; }
    .region-btn { padding: 6px 12px; font-size: 0.78rem; }
}