/* =========================
   武侠主题全局样式（保留原布局，仅优化视觉）
   ========================= */

:root {
    --bg-dark: #0f1115;
    --bg-mid: #171a21;
    --panel: rgba(32, 26, 22, 0.74);
    --panel-light: rgba(255, 248, 232, 0.08);
    --gold: #d6b36a;
    --gold-strong: #f0d38a;
    --ink: #d9d0c0;
    --muted: #b7ab97;
    --danger: #b54a3a;
    --success: #5f8f63;
    --border: rgba(214, 179, 106, 0.22);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    color: var(--ink);
    line-height: 1.6;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif SC", serif;
    background:
        radial-gradient(circle at top, rgba(122, 88, 44, 0.18), transparent 35%),
        linear-gradient(180deg, rgba(0,0,0,0.28), rgba(0,0,0,0.42)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900' viewBox='0 0 900 900'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='2'%3E%3Cpath d='M98 148c64 34 112 54 170 40 58-15 80-73 140-73 70 0 87 60 150 70 53 8 109-18 180-67'/%3E%3Cpath d='M73 314c49 31 102 48 164 39 59-9 101-63 153-63 70 0 102 53 156 66 49 11 102-9 174-55'/%3E%3Cpath d='M111 512c45 28 95 38 151 26 55-12 95-58 149-58 67 0 98 47 153 56 49 8 97-11 166-48'/%3E%3Cpath d='M128 702c47 20 86 29 132 20 63-12 108-49 174-49 63 0 92 39 152 49 49 8 99-2 180-42'/%3E%3C/g%3E%3C/svg%3E"),
        linear-gradient(135deg, #121418 0%, #1a1d24 32%, #121316 100%);
    background-attachment: fixed;
    padding-bottom: env(safe-area-inset-bottom, 0);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

a {
    color: var(--gold-strong);
}

a:hover {
    color: #fff1c2;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding:
        max(24px, env(safe-area-inset-top, 0))
        max(20px, env(safe-area-inset-right, 0))
        calc(40px + env(safe-area-inset-bottom, 0))
        max(20px, env(safe-area-inset-left, 0));
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 18px 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
        var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

header h1 {
    margin: 0;
    color: var(--gold-strong);
    font-size: 30px;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

header h2, h2, h3 {
    color: var(--gold-strong);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--ink);
    font-size: 15px;
}

button, .btn, .menu-item, .actions a {
    transition: all 0.25s ease;
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(214, 179, 106, 0.28);
    background: linear-gradient(180deg, #6f5230, #4e3821);
    color: #f6ead2;
    border-radius: 10px;
    min-height: 46px;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    text-decoration: none;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #86613a, #5c4228);
    box-shadow: 0 12px 24px rgba(0,0,0,0.32);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

input, select, textarea {
    background: rgba(246, 238, 225, 0.92);
    color: #2b241b;
    border: 1px solid rgba(86, 63, 39, 0.25);
    border-radius: 10px;
    outline: none;
    min-height: 46px;
    padding: 12px 14px;
    font-size: 16px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

input:focus, select:focus, textarea:focus {
    border-color: rgba(214, 179, 106, 0.7);
    box-shadow: 0 0 0 3px rgba(214, 179, 106, 0.16);
}

.main-menu, .panel, .practice-section, .health-display, .card, .match-info,
.action-section, .waiting-section, .battle-log, .health-bar, .move-card {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
        var(--panel) !important;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.menu-item {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)),
        rgba(37, 29, 24, 0.84) !important;
    border: 1px solid var(--border) !important;
    position: relative;
    overflow: hidden;
}

.menu-item::before,
.move-card::before,
.card::before,
.panel::before,
.match-info::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(214,179,106,0.06), transparent 38%, transparent 62%, rgba(214,179,106,0.03));
}

.menu-item:hover {
    transform: translateY(-5px);
    border-color: rgba(240, 211, 138, 0.55) !important;
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.35);
}

.menu-item h3, .move-name, .title {
    color: var(--gold-strong) !important;
}

.menu-item p, .meta, .property-name, .cooldown-info, .status-info, .log-entry {
    color: var(--muted) !important;
}

.health-container {
    background: rgba(16, 14, 12, 0.8) !important;
    border: 1px solid rgba(214, 179, 106, 0.14);
}

.health-fill {
    background: linear-gradient(90deg, #8c2f21, #c77d3a, #678a52) !important;
}

.health-text {
    color: #fff3da !important;
}

.countdown {
    color: #f0c56f !important;
    text-shadow: 0 0 20px rgba(214,179,106,0.16), 0 2px 10px rgba(0,0,0,0.45) !important;
}

.waiting-message, .status.open, .status.done, .status.locked {
    color: var(--gold-strong) !important;
}

.log-content {
    background: rgba(10, 10, 10, 0.35) !important;
    border: 1px solid rgba(214, 179, 106, 0.08);
}

.log-entry {
    border-bottom: 1px dashed rgba(214, 179, 106, 0.12) !important;
}

.modal {
    background: rgba(7, 6, 6, 0.78) !important;
}

.modal-content {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
        rgba(30, 24, 20, 0.96) !important;
    border: 1px solid rgba(214, 179, 106, 0.32) !important;
    box-shadow: 0 30px 70px rgba(0,0,0,0.5) !important;
}

.badge-main, .count, #staminaInfo {
    color: var(--gold-strong) !important;
}

.badge-main {
    background: rgba(214, 179, 106, 0.18) !important;
    border: 1px solid rgba(214, 179, 106, 0.3);
}

.prop-pill.main {
    background: linear-gradient(180deg, #d9b56d, #b18a47) !important;
    color: #22190d !important;
}

.prop-pill {
    border: 1px solid rgba(214, 179, 106, 0.12);
}

.empty, .empty-state {
    background: rgba(255,255,255,0.03) !important;
    border: 1px dashed rgba(214,179,106,0.18);
    color: var(--muted) !important;
}

.topbar, .top {
    align-items: center;
}

.page-intro {
    margin: 0 0 18px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(214, 179, 106, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
}

.page-intro strong {
    color: var(--gold-strong);
}

.section-heading {
    margin: 0 0 12px;
}

.floating-home-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 14px);
    left: 14px;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(17, 24, 39, 0.86);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.22);
    color: #fff;
    text-decoration: none;
}

.floating-home-btn:hover {
    color: #fff7de;
    border-color: rgba(240, 211, 138, 0.45);
    box-shadow: 0 14px 28px rgba(0,0,0,0.26);
}

body.has-floating-home .container,
body.has-floating-home .wrap {
    padding-top: max(96px, calc(env(safe-area-inset-top, 0px) + 72px)) !important;
}

/* =========================
   保留原战斗相关样式兼容
   ========================= */
.battle-interface {
    max-width: 800px;
    margin: 0 auto;
}

.health-bars {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 20px 0;
}

.health-bar {
    flex: 1;
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.health-label {
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.health-container {
    position: relative;
    height: 30px;
    border-radius: 15px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.countdown-container {
    text-align: center;
    margin: 30px 0;
}

.countdown {
    font-size: 3em;
    font-weight: bold;
}

.countdown-label {
    font-size: 1.2em;
}

.input-section, .waiting-section {
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
}

.move-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.move-input input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
}

.selected-move {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(214, 179, 106, 0.25);
    background: rgba(214, 179, 106, 0.08);
}

.waiting-message {
    text-align: center;
    font-size: 1.2em;
    margin-bottom: 10px;
}

.opponent-status {
    text-align: center;
    font-style: italic;
}

.battle-log {
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.log-content {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border-radius: 5px;
}

.log-entry {
    padding: 5px 0;
    font-size: 0.9em;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    min-width: 400px;
}

.result-details {
    margin: 20px 0;
}

.result-item {
    margin: 10px 0;
    font-size: 1.1em;
}

.result-item.damage {
    color: #f0c56f;
    font-size: 1.3em;
}

.battle-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.battle-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(214, 179, 106, 0.35);
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.03);
}

#globalLoadingOverlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 18px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease;
    pointer-events: none;
    z-index: 3000;
}

#globalLoadingOverlay.show {
    opacity: 1;
    visibility: visible;
}

.global-loading-shell {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(22, 18, 16, 0.88);
    border: 1px solid rgba(214, 179, 106, 0.22);
    box-shadow: 0 10px 24px rgba(0,0,0,0.28);
    color: #f5e7c6;
    backdrop-filter: blur(8px);
}

.global-loading-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(240, 211, 138, 0.25);
    border-top-color: #f0d38a;
    animation: wordswar-spin 0.8s linear infinite;
}

.global-loading-text {
    font-size: 13px;
    white-space: nowrap;
}

@keyframes wordswar-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }

    .container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding:
            max(16px, env(safe-area-inset-top, 0))
            max(14px, env(safe-area-inset-right, 0))
            calc(28px + env(safe-area-inset-bottom, 0))
            max(14px, env(safe-area-inset-left, 0));
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
        gap: 14px;
        border-radius: 16px;
    }

    header h1 {
        font-size: 24px;
        letter-spacing: 1px;
        line-height: 1.35;
        word-break: break-word;
    }

    .user-info,
    .top,
    .topbar,
    .battle-info,
    .actions,
    .move-input,
    .practice-input,
    .result-actions,
    .battle-buttons,
    .selected-move,
    .skill-actions,
    .top > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
        box-sizing: border-box;
    }

    .menu-options,
    .moves-grid,
    .skills-grid,
    .grid,
    .health-bars,
    .skill-properties {
        grid-template-columns: 1fr !important;
        display: grid !important;
        gap: 12px;
        width: 100%;
    }

    .health-bars {
        display: grid !important;
    }

    .health-bar,
    .card,
    .panel,
    .move-card,
    .menu-item,
    .skill-card,
    .practice-section,
    .health-display,
    .battle-log,
    .action-section,
    .waiting-section,
    .match-info,
    .input-section,
    .modal-content {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    input, select, textarea,
    .move-input input,
    .move-input select,
    .practice-input input {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px;
    }

    button, .btn, .actions a {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .menu-item,
    .move-option-card,
    .skill-card,
    .report-box {
        border-radius: 14px !important;
    }

    .topbar .actions a {
        margin-left: 0 !important;
    }

    .modal-content {
        width: 92vw !important;
        min-width: auto !important;
        padding: 18px !important;
        max-height: 86vh;
        overflow-y: auto;
    }

    .floating-home-btn {
        left: 12px;
        right: auto;
        min-height: 40px;
        padding: 9px 14px;
    }

    .countdown {
        font-size: 2.3em !important;
    }

    .health-container {
        height: 36px !important;
    }

    .battle-log {
        max-height: none !important;
    }

    .wrap,
    .battle-container,
    .internal-skills-container {
        max-width: 100% !important;
    }

    .health-text,
    .meta,
    .relations,
    .result-details,
    #battleReport,
    .log-entry,
    .property-item,
    .skill-name,
    .move-name,
    h2, h3, p, div, span {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    #battleReport ol,
    .steps {
        display: block !important;
        text-align: left !important;
        margin-left: 16px !important;
        padding-left: 16px !important;
    }
}
