/* ============================================================
   main.css  —  最终覆盖 / 全局微调
   最后加载，优先级最高
   用于修正上面各文件之间的冲突，或加临时补丁
   ============================================================ */

/* 防止加载期间闪烁 */
html {
    visibility: hidden;
}

html.js-loaded {
    visibility: visible;
}

body.game-started .container {
    display: block;
}

body.game-started #start-screen {
    display: none;
}

/* 起始选择弹窗：复用 .dialog 外观，只补充宽度与内部排版 */
.start-dialog .dialog-content,
.start-card {
    max-width: 460px;
}

.start-card .dialog-header h3 {
    font-size: 1.25rem;
}

.start-body {
    padding: 18px 22px 22px;
    text-align: center;
    color: var(--c-text);
    overflow-y: auto;
    min-height: 0;
}

.start-subtitle {
    font-size: 1rem;
    color: var(--c-text-muted);
    margin-bottom: 6px;
}

.publisher-credit {
    font-size: 0.85rem;
    color: var(--c-text-light);
    margin-bottom: 14px;
}

.start-cache-hint {
    background-color: var(--c-primary-bg-light);
    border: 1px solid var(--c-border-primary);
    border-radius: var(--radius-md);
    color: var(--c-primary-darker);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.start-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.start-actions .btn {
    width: 100%;
    justify-content: center;
}

.start-meta-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--c-border-light);
}

#start-screen.hidden {
    display: none;
}


/* 版本号（右下角小字，方便反馈） */
.version-tag {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 0.75rem;
    color: var(--c-text-light);
    opacity: 0.6;
    z-index: 9998;
    pointer-events: none;
    font-family: var(--font-mono);
}

/* 加载遮罩（JS 加载后自动消失） */
#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--c-bg-gradient);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30000;
    transition: opacity 0.4s ease;
    color: var(--c-primary-darker);
    font-size: 1.5rem;
    font-weight: bold;
    gap: 20px;
}

#loading-screen.hide {
    opacity: 0;
    pointer-events: none;
}

#loading-screen .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--c-primary-lighter);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 切换语言过渡遮罩：默认隐藏，setLanguage 后显示，刷新即消失 */
#lang-switch-overlay {
    position: fixed;
    inset: 0;
    background: var(--c-bg-gradient);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30001;
    color: var(--c-primary-darker);
    font-size: 1.4rem;
    font-weight: bold;
    gap: 20px;
}

#lang-switch-overlay.show {
    display: flex;
}

#lang-switch-overlay .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--c-primary-lighter);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* ============================================================
   Start-screen meta actions (rules / privacy / terms)
   ============================================================ */

.btn-link {
    background: transparent;
    border: none;
    color: var(--c-primary-lighter);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}
.btn-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--c-text-on-dark);
}

/* ============================================================
   Button right-click tip popup
   ============================================================ */
.btn-tip-popup {
    position: fixed;
    z-index: 40000;
    max-width: 320px;
    min-width: 100px;
    padding: 8px 12px;
    background: rgba(20, 30, 22, 0.96);
    color: #f1f8e9;
    border: 1px solid rgba(150, 230, 156, 0.45);
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.4;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s, transform 0.15s;
    white-space: normal;
    word-wrap: break-word;
}
.btn-tip-popup.show {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Stat-clickable (gold click to currency dialog)
   ============================================================ */
.stat.stat-clickable {
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
    padding: 4px 10px;
    border-radius: 8px;
}
.stat.stat-clickable:hover {
    background: rgba(76, 175, 80, 0.12);
    transform: translateY(-1px);
}

/* ============================================================
   Currency dialog layout
   ============================================================ */
.currency-help-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.currency-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.currency-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}
.currency-row-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.currency-icon {
    font-size: 1.4rem;
}
.currency-name {
    font-weight: 600;
}
.currency-level-tag {
    font-size: 0.75rem;
    padding: 2px 6px;
    background: rgba(150, 230, 156, 0.18);
    color: #a8e6cf;
    border-radius: 6px;
}
.currency-row-balance {
    font-family: var(--font-mono, monospace);
    font-weight: 600;
    color: #ffe082;
}
.currency-row-actions {
    display: flex;
    gap: 4px;
}
.currency-row-actions .btn {
    padding: 4px 8px;
    min-width: 32px;
}

.currency-summary {
    padding: 10px 12px;
    background: rgba(150, 230, 156, 0.08);
    border-radius: 8px;
    margin-bottom: 12px;
}

.currency-rate-note {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 16px;
}

.currency-history h4 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
}
.currency-history-list {
    max-height: 180px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    padding: 6px 10px;
}
.currency-history-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
}
.currency-history-row:last-child {
    border-bottom: none;
}
.currency-history-empty {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    padding: 8px 0;
}

.currency-help-panel {
    margin-top: 16px;
    padding: 12px;
    background: rgba(33, 150, 243, 0.08);
    border: 1px solid rgba(33, 150, 243, 0.25);
    border-radius: 8px;
}
.currency-help-panel.hidden {
    display: none;
}
.currency-help-panel pre {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 8px 0;
    line-height: 1.6;
}

.icon-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: inherit;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}
.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* 日志区被定位时的提示闪烁 */
.events-log.flash {
    animation: logFlash 1.4s ease-out;
}

@keyframes logFlash {
    0%   { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.55); }
    60%  { box-shadow: 0 0 0 12px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* ============================================================
   加载进度页（manifest 驱动）
   ============================================================ */
.loading-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--c-primary-darker);
    margin-bottom: 4px;
}

.loading-status {
    font-size: 0.95rem;
    color: var(--c-primary-dark);
    min-height: 1.4em;
    text-align: center;
    padding: 0 20px;
}

.loading-progress-bar {
    width: min(420px, 78vw);
    height: 14px;
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--c-primary-lighter);
    border-radius: var(--radius-round);
    overflow: hidden;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.08);
}

.loading-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--c-primary-light), var(--c-primary));
    border-radius: var(--radius-round);
    transition: width 0.25s ease-out;
}

.loading-percent {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--c-primary-darker);
    font-variant-numeric: tabular-nums;
}

.loading-version {
    font-size: 0.75rem;
    color: var(--c-primary-dark);
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

/* 静音状态的声音按钮 */
#sound-btn.muted {
    opacity: 0.55;
}
