/*
 * 视觉样式模块：按全局变量、登录/主界面、对局棋盘、浮层和动画分段组织。
 * 棋盘尺寸由 game.js 写入 --board-cols、--board-rows 与 --board-width 后自适应计算。
 */
:root {
    --bg: #10151f;
    --panel: #f7f0df;
    --panel-dark: #d8bd82;
    --ink: #292319;
    --muted: #74644e;
    --accent: #2b7a78;
    --danger: #c2410c;
    --cell-gap: clamp(2px, 0.5vw, 4px);
    --board-width: min(calc(100vw - 4px), calc((100dvh - 148px) / var(--board-ratio)), 760px);
    --board-cols: 10;
    --board-rows: 13;
    --board-ratio: 1.3;
}

@font-face {
    font-family: "Brick LXGW WenKai Title";
    src: url("fonts/lxgw-wenkai-title.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Brick Smiley Sans Title";
    src: url("fonts/smiley-sans-title.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Brick ZCOOL KuaiLe Title";
    src: url("fonts/zcool-kuaile-ui.ttf") format("truetype");
    font-display: swap;
}

/* 猫咪咖啡屋主题：完整资源覆盖，忍者版可通过 ?theme=ninja-style2 保留。 */
html[data-theme="cat-cafe"] {
    --bg: #f6c9a8;
    --panel: #fff7df;
    --panel-dark: #efc99f;
    --ink: #633828;
    --muted: #8f684f;
    --accent: #ee9aa6;
    --danger: #d86b62;
}

html[data-theme="cat-cafe"],
html[data-theme="cat-cafe"] body,
html[data-theme="cat-cafe"] #game-shell {
    background: url("assets/themes/cat-cafe/home/background.jpg") center / cover no-repeat;
}

html[data-theme="cat-cafe"] .auth-overlay,
html[data-theme="cat-cafe"] .leaderboard-panel,
html[data-theme="cat-cafe"] .legion-panel,
html[data-theme="cat-cafe"] .shop-panel {
    background-color: rgba(80, 54, 48, 0.58);
}

html[data-theme="cat-cafe"] .auth-panel {
    background: rgba(255, 247, 223, 0.96);
    border-color: #efb27e;
}

html[data-theme="cat-cafe"] .home-screen {
    background: url("assets/themes/cat-cafe/home/background.jpg") center / cover no-repeat;
    color: #633828;
}

html[data-theme="cat-cafe"] .home-scene {
    display: none;
}

html[data-theme="cat-cafe"] .home-kicker {
    color: #8d5c42;
    text-shadow: none;
    top: clamp(108px, 13dvh, 142px);
}

html[data-theme="cat-cafe"] .home-menu h1 {
    background-image: url("assets/themes/cat-cafe/home/logo.png");
    color: #633828;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: clamp(38px, 11vw, 64px);
    text-shadow: none;
    top: clamp(142px, 17dvh, 188px);
    transform: translateX(-50%);
}

html[data-theme="cat-cafe"] .home-subtitle {
    color: #774a38;
    text-shadow: none;
    top: clamp(350px, 39dvh, 430px);
}

html[data-theme="cat-cafe"] .home-action {
    background-image: url("assets/themes/cat-cafe/home/nav-button.png");
    color: #fff9e9;
    text-shadow: 0 2px 2px rgba(124, 71, 42, 0.34);
}

html[data-theme="cat-cafe"] .home-action.primary {
    background-image: url("assets/themes/cat-cafe/home/primary-button.png");
    color: #633828;
    text-shadow: none;
}

html[data-theme="cat-cafe"] .home-action.collection {
    background-image: url("assets/themes/cat-cafe/home/nav-button.png");
    color: #633828;
    text-shadow: none;
}

html[data-theme="cat-cafe"] #home-leaderboard-btn::before {
    background-image: url("assets/themes/cat-cafe/home/rank-icon.png");
}

html[data-theme="cat-cafe"] #home-daily-btn::before {
    background-image: url("assets/themes/cat-cafe/home/daily-icon.png");
}

html[data-theme="cat-cafe"] #home-legion-btn::before {
    background-image: url("assets/themes/cat-cafe/home/legion-icon.png");
}

html[data-theme="cat-cafe"] .home-notice {
    background-image: url("assets/themes/cat-cafe/home/bulletin.png");
}

html[data-theme="cat-cafe"] .home-notice span {
    color: #ffdf64;
}

html[data-theme="cat-cafe"] .home-notice p {
    color: #fff9eb;
}

html[data-theme="cat-cafe"] .top-bar {
    background: url("assets/themes/cat-cafe/game/player-panel.png") center / 100% 100% no-repeat;
    box-shadow: 0 4px 10px rgba(122, 74, 51, 0.14);
}

html[data-theme="cat-cafe"] .board-wrap {
    background: url("assets/themes/cat-cafe/game/board-panel.png") center / 100% 100% no-repeat;
    border-color: rgba(205, 143, 102, 0.32);
    box-shadow: 0 10px 22px rgba(131, 75, 46, 0.16);
}

html[data-theme="cat-cafe"] .cell {
    background: transparent;
    box-shadow: none;
}

html[data-theme="cat-cafe"] #hint-btn {
    background-image: url("assets/themes/cat-cafe/game/hint-button.png");
}

html[data-theme="cat-cafe"] #shuffle-btn {
    background-image: url("assets/themes/cat-cafe/game/shuffle-button.png");
}

html[data-theme="cat-cafe"] .return-home-btn {
    background-image: url("assets/themes/cat-cafe/game/back-button.png");
}

html[data-theme="cat-cafe"] .leaderboard-dialog,
html[data-theme="cat-cafe"] .legion-rank-dialog {
    background: url("assets/themes/cat-cafe/leaderboard/panel.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 8px;
    padding: 20px 18px 16px;
}

html[data-theme="cat-cafe"] .leaderboard-header h1,
html[data-theme="cat-cafe"] .legion-header h1,
html[data-theme="cat-cafe"] .shop-header h1 {
    color: #633828;
    text-shadow: 0 1px 0 rgba(255, 247, 223, 0.7);
}

html[data-theme="cat-cafe"] #leaderboard-close-btn,
html[data-theme="cat-cafe"] #legion-close-btn,
html[data-theme="cat-cafe"] #legion-rank-close-btn,
html[data-theme="cat-cafe"] #shop-close-btn {
    background: #f3a15f;
}

html[data-theme="cat-cafe"] .leaderboard-row {
    background: url("assets/themes/cat-cafe/leaderboard/row-normal.png") center / 100% 100% no-repeat;
    border: 0;
    color: #633828;
}

html[data-theme="cat-cafe"] .leaderboard-row:nth-child(1) {
    background-image: url("assets/themes/cat-cafe/leaderboard/row-first.png");
}

html[data-theme="cat-cafe"] .leaderboard-row:nth-child(2) {
    background-image: url("assets/themes/cat-cafe/leaderboard/row-second.png");
}

html[data-theme="cat-cafe"] .leaderboard-row:nth-child(3) {
    background-image: url("assets/themes/cat-cafe/leaderboard/row-third.png");
}

html[data-theme="cat-cafe"] .leaderboard-tab {
    background: url("assets/themes/cat-cafe/leaderboard/tab-inactive.png") center / 100% 100% no-repeat;
    color: #8f684f;
}

html[data-theme="cat-cafe"] .leaderboard-tab.is-active {
    background-image: url("assets/themes/cat-cafe/leaderboard/tab-active.png");
    color: #fffaf0;
}

html[data-theme="cat-cafe"] .legion-dialog {
    background: url("assets/themes/cat-cafe/legion/panel.png") center / 100% 100% no-repeat;
    border: 0;
    padding: 20px 18px;
}

html[data-theme="cat-cafe"] .world-map {
    background-image: url("assets/themes/cat-cafe/legion/map.png");
    border-color: #d9969f;
}

html[data-theme="cat-cafe"] .continent-tab,
html[data-theme="cat-cafe"] .country-option {
    background: url("assets/themes/cat-cafe/legion/continent-inactive.png") center / 100% 100% no-repeat;
    border: 0;
    color: #8c603f;
}

html[data-theme="cat-cafe"] .continent-tab.is-active,
html[data-theme="cat-cafe"] .country-option.is-selected {
    background-image: url("assets/themes/cat-cafe/legion/continent-active.png");
    color: #fffaf0;
}

html[data-theme="cat-cafe"] #legion-rank-btn {
    background: url("assets/themes/cat-cafe/legion/rank-button.png") center / 100% 100% no-repeat;
}

html[data-theme="cat-cafe"] #legion-shop-btn {
    background: url("assets/themes/cat-cafe/legion/shop-button.png") center / 100% 100% no-repeat;
}

html[data-theme="cat-cafe"] .shop-dialog {
    background: url("assets/themes/cat-cafe/shop/panel.png") center / 100% 100% no-repeat;
    border: 0;
    padding: 20px 18px;
}

html[data-theme="cat-cafe"] .shop-slot {
    background: url("assets/themes/cat-cafe/shop/empty-slot.png") center / 100% 100% no-repeat;
    border: 0;
}

html[data-theme="cat-cafe"] .shop-slot.item {
    background-image: url("assets/themes/cat-cafe/shop/item-slot.png");
}

html[data-theme="cat-cafe"] .shop-icon {
    height: 38px;
    object-fit: contain;
    width: 38px;
}

html[data-theme="cat-cafe"] .shop-wallet,
html[data-theme="cat-cafe"] .legion-status-card {
    background: rgba(250, 209, 149, 0.78);
    border-color: rgba(196, 130, 80, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    min-height: 100%;
    overscroll-behavior: none;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(34, 22, 13, 0.05), rgba(34, 22, 13, 0.16)),
        url("assets/bg/底景色.png") center / cover no-repeat,
        var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    touch-action: none;
    user-select: none;
}

button {
    border: 0;
    border-radius: 8px;
    background: #2b7a78;
    color: #fffaf0;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    min-height: 38px;
    padding: 0 14px;
    box-shadow: inset 0 -3px rgba(0, 0, 0, 0.18);
}

button:active {
    transform: translateY(1px);
    box-shadow: inset 0 -1px rgba(0, 0, 0, 0.18);
}

#home-screen[hidden],
#game-shell[hidden] {
    display: none;
}

.auth-overlay {
    align-items: center;
    background: rgba(16, 21, 31, 0.82);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 40;
}

.auth-overlay[hidden] {
    display: none;
}

.auth-panel {
    background: #f7f0df;
    border: 2px solid #d8bd82;
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
    color: var(--ink);
    display: grid;
    gap: 10px;
    max-width: 330px;
    padding: 18px;
    width: 100%;
}

.auth-panel h1 {
    font-size: 22px;
    line-height: 1.1;
    margin: 0;
}

.auth-panel input {
    border: 2px solid rgba(116, 100, 78, 0.32);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    min-height: 40px;
    padding: 0 10px;
    width: 100%;
}

.auth-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
}

.auth-message {
    color: var(--danger);
    font-size: 13px;
    font-weight: 800;
    min-height: 18px;
}

.auth-badge {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 12px;
    font-weight: 900;
    gap: 6px;
    min-width: 0;
}

.auth-badge > span {
    color: var(--ink);
    line-height: 1.18;
    overflow-wrap: anywhere;
}

/* 主界面：背景、卷轴发动效果、公告和四个入口。 */
.home-screen {
    background:
        linear-gradient(180deg, rgba(40, 18, 8, 0.12), rgba(12, 5, 3, 0.28)),
        url("assets/main-menu/背景.png") center / cover no-repeat,
        #2d160d;
    color: #f8ead0;
    display: grid;
    height: 100dvh;
    overflow: hidden;
    place-items: center;
    position: relative;
    width: 100vw;
}

.home-scene {
    display: none;
}

.home-scene::before {
    content: none;
}

.home-moon {
    background:
        radial-gradient(circle at 36% 28%, #fffbe9 0 18%, #ffe8a3 19% 58%, rgba(252, 211, 77, 0.14) 59% 100%);
    border-radius: 50%;
    box-shadow: 0 0 56px rgba(252, 211, 77, 0.38);
    height: min(24vw, 128px);
    position: absolute;
    right: min(8vw, 58px);
    top: max(26px, 7dvh);
    width: min(24vw, 128px);
}

.home-mist {
    animation: mistDrift 9s ease-in-out infinite alternate;
    background: linear-gradient(90deg, transparent, rgba(224, 242, 254, 0.18), transparent);
    height: 18%;
    left: -20%;
    position: absolute;
    right: -20%;
    transform: skewY(-7deg);
}

.mist-a {
    top: 18%;
}

.mist-b {
    animation-delay: -4s;
    bottom: 12%;
    opacity: 0.72;
}

.scroll-stage {
    animation: scrollFloat 3.8s ease-in-out infinite alternate;
    height: min(58vw, 360px);
    left: 50%;
    position: absolute;
    top: 43%;
    transform: translate3d(-50%, -50%, 0) rotateX(12deg) rotateZ(-2deg);
    transform-style: preserve-3d;
    width: min(92vw, 620px);
}

.scroll-sheet {
    animation: scrollPulse 2.6s ease-in-out infinite alternate;
    background:
        linear-gradient(90deg, rgba(130, 79, 34, 0.2), transparent 12% 88%, rgba(130, 79, 34, 0.22)),
        linear-gradient(180deg, #fff3c4, #e5b15c);
    border: 4px solid rgba(86, 45, 24, 0.72);
    border-radius: 18px;
    box-shadow: inset 0 -16px rgba(112, 64, 27, 0.18), 0 28px 44px rgba(0, 0, 0, 0.36);
    height: 42%;
    left: 14%;
    position: absolute;
    top: 30%;
    width: 72%;
}

.scroll-roll {
    background:
        linear-gradient(90deg, #5b2e19, #c98336 34%, #f7c66f 54%, #5b2e19);
    border: 4px solid rgba(48, 26, 17, 0.86);
    border-radius: 18px;
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
    height: 54%;
    position: absolute;
    top: 24%;
    width: 10%;
    z-index: 2;
}

.scroll-roll-left {
    left: 8%;
}

.scroll-roll-right {
    right: 8%;
}

.scroll-mark {
    background: rgba(90, 44, 22, 0.74);
    border-radius: 999px;
    position: absolute;
}

.mark-one {
    height: 11%;
    left: 22%;
    top: 26%;
    width: 42%;
}

.mark-two {
    height: 11%;
    left: 34%;
    top: 47%;
    width: 36%;
}

.mark-three {
    height: 11%;
    left: 18%;
    top: 68%;
    width: 48%;
}

.skill-ring {
    animation: ringCast 1.8s ease-out infinite;
    border: 4px solid rgba(125, 211, 252, 0.72);
    border-radius: 50%;
    box-shadow: 0 0 24px rgba(125, 211, 252, 0.28);
    height: 30%;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.42);
    width: 22%;
}

.ring-two {
    animation-delay: 0.72s;
    border-color: rgba(253, 224, 71, 0.72);
}

.skill-spark {
    animation: sparkTravel 1.6s ease-in-out infinite alternate;
    background: #fef3c7;
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(253, 224, 71, 0.8);
    height: 9px;
    position: absolute;
    width: 9px;
}

.spark-one {
    left: 38%;
    top: 24%;
}

.spark-two {
    animation-delay: -0.45s;
    left: 64%;
    top: 62%;
}

.spark-three {
    animation-delay: -0.9s;
    left: 47%;
    top: 78%;
}

.casting-ninja {
    animation: castBreath 1.8s ease-in-out infinite alternate;
    bottom: max(86px, 13dvh);
    height: 132px;
    left: 50%;
    position: absolute;
    transform: translateX(-50%);
    width: 132px;
    z-index: 3;
}

.casting-ninja span {
    display: block;
    position: absolute;
}

.casting-head {
    background: #111827;
    border: 4px solid #fff0c5;
    border-radius: 50%;
    height: 36px;
    left: 48px;
    top: 8px;
    width: 36px;
}

.casting-head::after {
    background: #38bdf8;
    border-radius: 999px;
    content: "";
    height: 8px;
    left: 7px;
    position: absolute;
    top: 13px;
    width: 18px;
}

.casting-scarf {
    animation: scarfFlutter 420ms ease-in-out infinite alternate;
    background: #ef4444;
    border-radius: 999px 0 0 999px;
    height: 12px;
    left: 23px;
    top: 27px;
    transform-origin: right center;
    width: 32px;
}

.casting-body {
    background: #1f2937;
    border: 4px solid #fff0c5;
    border-radius: 16px 16px 12px 12px;
    height: 48px;
    left: 42px;
    top: 40px;
    width: 48px;
}

.casting-arm {
    background: #111827;
    border: 3px solid #fff0c5;
    border-radius: 999px;
    height: 16px;
    top: 54px;
    width: 48px;
}

.arm-left {
    left: 10px;
    transform: rotate(24deg);
}

.arm-right {
    right: 10px;
    transform: rotate(-24deg);
}

.casting-leg {
    background: #111827;
    border: 3px solid #fff0c5;
    border-radius: 999px;
    height: 17px;
    top: 88px;
    width: 42px;
}

.leg-left {
    left: 31px;
    transform: rotate(-28deg);
}

.leg-right {
    right: 31px;
    transform: rotate(28deg);
}

.home-menu {
    align-self: stretch;
    justify-self: center;
    max-width: 540px;
    min-height: 100dvh;
    padding: max(18px, env(safe-area-inset-top)) clamp(14px, 4vw, 24px) max(16px, env(safe-area-inset-bottom));
    position: relative;
    text-align: center;
    width: 100%;
    z-index: 4;
}

.home-menu::before {
    background: url("assets/main-menu/按钮5.png") center / 100% 100% no-repeat;
    content: "";
    height: clamp(42px, 7dvh, 58px);
    left: clamp(14px, 4vw, 24px);
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    width: clamp(68px, 18vw, 96px);
}

.home-kicker {
    color: #f6dfbf;
    font-size: clamp(16px, 4vw, 22px);
    font-weight: 950;
    left: 50%;
    letter-spacing: 0;
    margin: 0;
    position: absolute;
    text-shadow:
        0 2px 0 rgba(32, 15, 8, 0.92),
        0 4px 10px rgba(0, 0, 0, 0.56);
    top: clamp(118px, 15dvh, 164px);
    transform: translateX(-50%);
    white-space: nowrap;
}

.home-menu h1 {
    align-items: center;
    aspect-ratio: 988 / 468;
    background: url("assets/main-menu/LOGO底板.png") center / contain no-repeat;
    color: #080604;
    display: flex;
    font-family: "Hiragino Mincho ProN", "Songti SC", "STSong", serif;
    font-size: clamp(42px, 13vw, 72px);
    font-weight: 950;
    justify-content: center;
    left: 50%;
    line-height: 0.95;
    margin: 0;
    padding: 7% 12% 3%;
    position: absolute;
    text-shadow:
        0 2px 0 #f3d88a,
        0 5px 4px rgba(0, 0, 0, 0.38);
    top: clamp(154px, 19dvh, 214px);
    transform: translateX(-50%) rotate(-1deg);
    width: min(96vw, 500px);
}

.home-subtitle {
    color: rgba(255, 241, 214, 0.96);
    font-size: clamp(15px, 4vw, 20px);
    font-weight: 900;
    left: 50%;
    line-height: 1.28;
    margin: 0;
    max-width: min(86vw, 420px);
    position: absolute;
    text-shadow:
        0 2px 0 rgba(28, 12, 7, 0.9),
        0 5px 12px rgba(0, 0, 0, 0.62);
    top: clamp(390px, 42dvh, 470px);
    transform: translateX(-50%);
    width: max-content;
}

.home-notice {
    align-items: center;
    background: url("assets/main-menu/战报.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 0;
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
    box-shadow: none;
    display: grid;
    grid-template-columns: 24% 1fr;
    left: clamp(10px, 3vw, 18px);
    min-height: clamp(54px, 7dvh, 68px);
    padding: 8px 14px 8px 18px;
    position: absolute;
    right: clamp(10px, 3vw, 18px);
}

.home-notice span {
    color: #facc15;
    display: block;
    font-size: clamp(14px, 3.8vw, 20px);
    font-weight: 950;
    line-height: 1;
    margin: 0;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.72);
}

.home-notice p {
    color: #fff2d8;
    font-size: clamp(12px, 3.2vw, 16px);
    font-weight: 850;
    line-height: 1.2;
    margin: 0;
    min-height: 0;
    overflow: hidden;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.62);
    text-align: left;
}

.home-actions {
    align-content: space-between;
    bottom: max(88px, calc(env(safe-area-inset-bottom) + 86px));
    display: grid;
    gap: clamp(10px, 2.2dvh, 18px) 8px;
    grid-template-areas:
        "primary primary collection"
        "legion daily leaderboard";
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: clamp(72px, 10dvh, 92px) clamp(48px, 7dvh, 62px);
    left: clamp(14px, 4vw, 24px);
    pointer-events: none;
    position: absolute;
    right: clamp(14px, 4vw, 24px);
}

.home-action {
    align-items: center;
    background: url("assets/main-menu/按钮6.png") center / 100% 100% no-repeat;
    border: 0;
    box-shadow: none;
    color: #5a2e1c;
    display: flex;
    font-size: clamp(15px, 4vw, 20px);
    font-weight: 950;
    gap: 4px;
    justify-content: center;
    min-height: 0;
    padding: 2px 8px 4px;
    pointer-events: auto;
    text-shadow: 0 1px 0 rgba(255, 241, 196, 0.76);
}

.home-action.primary {
    background: url("assets/main-menu/按钮4.png") center / 100% 100% no-repeat;
    color: #5b2b1a;
    font-size: clamp(30px, 9vw, 48px);
    grid-area: primary;
    height: clamp(70px, 9dvh, 88px);
    justify-self: center;
    margin-top: -14px;
    padding-bottom: 8px;
    text-shadow: 0 2px 0 rgba(255, 236, 166, 0.72);
    width: min(72vw, 330px);
}

.home-action.collection {
    grid-area: collection;
}

#home-leaderboard-btn {
    grid-area: leaderboard;
}

#home-daily-btn {
    grid-area: daily;
}

#home-legion-btn {
    grid-area: legion;
}

#home-leaderboard-btn::before,
#home-daily-btn::before,
#home-legion-btn::before {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    content: "";
    flex: 0 0 clamp(20px, 5vw, 28px);
    height: clamp(20px, 5vw, 28px);
}

#home-leaderboard-btn::before {
    background-image: url("assets/main-menu/图标3.png");
}

#home-daily-btn::before {
    background-image: url("assets/main-menu/图标2.png");
}

#home-legion-btn::before {
    background-image: url("assets/main-menu/图标1.png");
}

.home-action.daily,
.home-action.legion {
    color: #5a2e1c;
    flex-direction: row;
}

.home-action.daily span,
.home-action.legion span {
    line-height: 1;
}

.home-action.daily small {
    color: #ffe7b0;
    display: block;
    font-size: clamp(13px, 3.4vw, 17px);
    font-weight: 950;
    left: 50%;
    line-height: 1;
    margin: 0;
    position: absolute;
    text-shadow:
        0 2px 0 rgba(24, 10, 5, 0.92),
        0 5px 8px rgba(0, 0, 0, 0.56);
    top: -21px;
    transform: translateX(-50%);
    white-space: nowrap;
}

.home-action.daily.is-empty {
    color: rgba(90, 46, 28, 0.72);
    cursor: not-allowed;
    filter: grayscale(0.65);
    opacity: 0.78;
}

.home-action.daily.is-empty small {
    color: rgba(255, 231, 176, 0.76);
}

.home-action.legion small {
    display: none;
}

.home-action.locked {
    color: rgba(90, 46, 28, 0.72);
    cursor: not-allowed;
    filter: grayscale(0.65);
    opacity: 0.78;
}

.home-action.locked small {
    color: rgba(253, 230, 138, 0.82);
    font-size: 10px;
    font-weight: 950;
    line-height: 1;
}

/* 对局界面：顶部玩家信息、固定比例棋盘与局内道具栏。 */
#game-shell {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100dvh;
    justify-content: flex-start;
    margin: 0 auto;
    max-width: none;
    overflow: hidden;
    overscroll-behavior: none;
    padding: max(10px, env(safe-area-inset-top)) 2px max(8px, env(safe-area-inset-bottom));
    position: relative;
    width: 100vw;
}

#game-shell > * {
    position: relative;
    z-index: 1;
}

.top-bar,
.tool-bar {
    width: var(--board-width);
}

.top-bar {
    align-items: center;
    background:
        linear-gradient(90deg, rgba(255, 247, 225, 0.16), rgba(255, 247, 225, 0.02)),
        url("assets/ui-elements/底板1.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(78, 38, 18, 0.14);
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto 48px;
    min-height: clamp(48px, 7dvh, 58px);
    padding: 7px 12px;
}

.auth-badge {
    cursor: pointer;
    min-height: 42px;
    touch-action: manipulation;
    user-select: none;
}

.timer-panel {
    align-items: baseline;
    cursor: pointer;
    display: flex;
    gap: 6px;
    touch-action: manipulation;
    user-select: none;
}

.label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.top-bar strong {
    color: var(--ink);
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.tutorial-panel {
    background: rgba(232, 244, 222, 0.95);
    border: 2px solid rgba(122, 157, 92, 0.78);
    border-radius: 8px;
    color: #24361f;
    display: grid;
    gap: 4px;
    padding: 8px 10px;
    width: var(--board-width);
}

.tutorial-panel[hidden] {
    display: none;
}

.tutorial-panel strong {
    font-size: 14px;
    line-height: 1.1;
}

.tutorial-panel p {
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    margin: 0;
}

.sr-only {
    height: 1px;
    left: -10000px;
    overflow: hidden;
    position: absolute;
    top: auto;
    width: 1px;
}

.board-wrap {
    aspect-ratio: var(--board-cols) / var(--board-rows);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 24%),
        rgba(87, 53, 24, 0.08);
    border: 2px solid rgba(107, 70, 38, 0.2);
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(72, 40, 18, 0.18), inset 0 0 0 1px rgba(255, 246, 214, 0.18);
    height: calc(var(--board-width) * var(--board-ratio));
    margin-top: 0;
    position: relative;
    width: var(--board-width);
}

#board {
    cursor: pointer;
    display: block;
    height: 100%;
    position: relative;
    touch-action: none;
    -webkit-touch-callout: none;
    width: 100%;
}

.cell {
    background: rgba(99, 65, 34, 0.08);
    border-radius: 5px;
    box-shadow: inset 0 0 0 1px rgba(255, 242, 206, 0.08);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.cell.drag-cell {
    overflow: visible;
    z-index: 6;
}

.cell.cross-preview {
    background: rgba(255, 232, 107, 0.32);
    box-shadow: inset 0 0 0 2px rgba(255, 232, 107, 0.78), 0 0 10px rgba(104, 211, 145, 0.34);
}

.cell.cross-preview::after {
    animation: crossPreviewPulse 780ms ease-in-out infinite;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(104, 211, 145, 0.18));
    border-radius: 4px;
    content: "";
    inset: 18%;
    pointer-events: none;
    position: absolute;
}

.tile {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 9px;
    box-shadow: none;
    color: #fffdf5;
    display: flex;
    height: 100%;
    justify-content: center;
    letter-spacing: 0;
    line-height: 1;
    min-height: 0;
    overflow: visible;
    padding: 0;
    position: relative;
    width: 100%;
}

.tile::before {
    content: "";
    position: absolute;
}

.tile::before {
    display: none;
}

.tile-icon {
    display: block;
    filter: drop-shadow(0 2px 2px rgba(55, 29, 10, 0.28));
    height: 108%;
    object-fit: contain;
    position: relative;
    user-select: none;
    width: 108%;
    z-index: 1;
}

.tile.selected {
    outline: 3px solid #fff3a3;
    outline-offset: -3px;
}

.tile.hint {
    animation: hintPulse 560ms ease-in-out 3;
    outline: 3px solid #00d9ff;
    outline-offset: -3px;
}

.tile.tutorial-target {
    animation: suggestShake 420ms ease-in-out infinite;
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.75);
    outline: 3px solid #00d9ff;
    outline-offset: -3px;
    z-index: 5;
}

.tile.suggesting {
    animation: suggestShake 360ms ease-in-out infinite;
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.75);
    outline: 3px solid #00d9ff;
    outline-offset: -3px;
    z-index: 5;
}

.tile.choice-source {
    animation: suggestShake 420ms ease-in-out infinite;
    box-shadow: none;
    outline: 3px solid #2563eb;
    outline-offset: -3px;
    z-index: 4;
}

.tile.choice-target {
    animation: suggestShake 420ms ease-in-out infinite;
    box-shadow: 0 0 12px rgba(255, 45, 149, 0.72);
    outline: 3px solid #ff2d95;
    outline-offset: -3px;
    z-index: 5;
}

.tile.choice-pulse {
    animation: choiceTargetPulse 220ms ease-in-out 3;
}

.tile.removing {
    animation: removePop 260ms ease-out forwards;
    pointer-events: none;
}

.tile.impact-ghost {
    margin: 0;
    pointer-events: none;
    position: absolute;
    z-index: 8;
}

.tile.impact-fly {
    animation: impactFly 450ms cubic-bezier(0.2, 0.72, 0.2, 1) forwards;
    pointer-events: none;
    z-index: 9;
}

.tile.impact-fly::after {
    animation: impactTrail 450ms ease-out forwards;
    background: linear-gradient(90deg, rgba(255, 241, 155, 0), rgba(255, 241, 155, 0.72), rgba(125, 211, 252, 0.42));
    border-radius: 999px;
    box-shadow: 0 0 10px rgba(255, 232, 107, 0.4);
    content: "";
    height: 18%;
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%) rotate(var(--impact-angle, 0deg)) translateX(-42%);
    transform-origin: center;
    width: 152%;
    z-index: 0;
}

.tile.impact-target {
    animation: impactTarget 450ms ease-out forwards;
    pointer-events: none;
    z-index: 7;
}

.impact-burst {
    animation: impactBurst 280ms ease-out forwards;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 18%, transparent 19%),
        conic-gradient(from 20deg, transparent 0 12%, rgba(255, 226, 92, 0.92) 12% 18%, transparent 18% 31%, rgba(125, 211, 252, 0.88) 31% 38%, transparent 38% 54%, rgba(255, 226, 92, 0.9) 54% 62%, transparent 62% 100%);
    border-radius: 999px;
    height: min(54px, calc(var(--board-width) / var(--board-cols) * 1.7));
    pointer-events: none;
    position: absolute;
    transform: translate(-50%, -50%) scale(0.36);
    width: min(54px, calc(var(--board-width) / var(--board-cols) * 1.7));
    z-index: 9;
}

.tile.drag-source {
    filter: brightness(1.15);
    z-index: 4;
}

.tile.dragging-line {
    outline: 2px solid rgba(255, 255, 255, 0.78);
    outline-offset: -2px;
    z-index: 3;
}

.tile.dragging-live {
    pointer-events: none;
    transition: none;
}

.tile.returning {
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.22, 1);
}

.tile.committing {
    transition: transform 120ms ease-out;
}

.tile.shake {
    animation: shake 360ms ease-in-out;
}

.tutorial-drag-hand {
    animation: tutorialHandDown 1.1s ease-in-out infinite;
    color: rgba(255, 247, 230, 0.78);
    filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.34));
    height: min(54px, calc(var(--board-width) / var(--board-cols) * 1.45));
    left: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    transform: translate(-50%, -50%);
    width: min(54px, calc(var(--board-width) / var(--board-cols) * 1.45));
    z-index: 12;
}

.tutorial-drag-hand::before {
    background: currentColor;
    border-radius: 999px 999px 10px 10px;
    content: "";
    height: 64%;
    left: 38%;
    position: absolute;
    top: 10%;
    width: 24%;
}

.tutorial-drag-hand::after {
    background:
        radial-gradient(circle at 50% 20%, currentColor 0 25%, transparent 26%),
        linear-gradient(currentColor, currentColor);
    border-radius: 14px 14px 999px 999px;
    content: "";
    height: 42%;
    left: 25%;
    position: absolute;
    top: 43%;
    width: 50%;
}

.tile.moved {
    animation: settle 210ms ease-out;
}

.tool-bar {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    margin-top: clamp(12px, 1.8dvh, 20px);
    width: min(var(--board-width), calc(100vw - 24px));
}

#hint-btn {
    background: url("assets/ui-elements/按钮2.png") center / 100% 100% no-repeat;
}

.hint-button,
.shuffle-button {
    border: 0;
    box-shadow: none;
    min-height: clamp(44px, 6.2dvh, 56px);
    text-shadow: 0 2px 4px rgba(62, 30, 12, 0.4);
    position: relative;
}

.count-badge {
    align-items: center;
    background: #ef4444;
    border: 2px solid #fff7e6;
    border-radius: 999px;
    bottom: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    color: #fff;
    display: flex;
    font-size: 11px;
    font-weight: 950;
    height: 20px;
    justify-content: center;
    line-height: 1;
    min-width: 20px;
    padding: 0 4px;
    position: absolute;
    right: 3px;
}

.hint-button.is-empty,
.shuffle-button.is-empty {
    filter: grayscale(0.45);
    opacity: 0.72;
}

.count-badge.badge-pulse {
    animation: badgePulse 420ms ease-out;
}

#shuffle-btn {
    background: url("assets/ui-elements/按钮3.png") center / 100% 100% no-repeat;
}

.runner-lane {
    align-items: center;
    cursor: pointer;
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(92px, 0.58fr) minmax(0, 1fr) 42px;
    height: 52px;
    margin-top: 4px;
    touch-action: manipulation;
    user-select: none;
    width: min(var(--board-width), calc(100vw - 36px));
}

.runner-track {
    background: rgba(247, 240, 223, 0.18);
    border: 2px solid rgba(216, 189, 130, 0.52);
    border-radius: 8px;
    box-shadow: inset 0 -3px rgba(0, 0, 0, 0.14);
    height: 42px;
    overflow: hidden;
    position: relative;
}

.runner-track::before {
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 9px, transparent 9px 18px);
    bottom: 6px;
    content: "";
    height: 2px;
    left: 0;
    position: absolute;
    right: 0;
}

.ninja-runner {
    animation: runnerPace 3.2s ease-in-out infinite alternate;
    bottom: 5px;
    height: 30px;
    left: 5px;
    position: absolute;
    width: 42px;
}

.ninja-runner span {
    display: block;
    position: absolute;
}

.ninja-head {
    background: #141820;
    border: 2px solid #fff0c5;
    border-radius: 50%;
    height: 14px;
    left: 12px;
    top: 0;
    width: 14px;
}

.ninja-head::after {
    background: #7dd3fc;
    border-radius: 999px;
    content: "";
    height: 3px;
    left: 3px;
    position: absolute;
    top: 5px;
    width: 8px;
}

.ninja-scarf {
    animation: scarfFlutter 420ms ease-in-out infinite alternate;
    background: #ef4444;
    border-radius: 999px 0 0 999px;
    height: 5px;
    left: 2px;
    top: 9px;
    transform-origin: right center;
    width: 14px;
}

.ninja-body {
    background: #1f2937;
    border: 2px solid #fff0c5;
    border-radius: 8px 8px 6px 6px;
    height: 17px;
    left: 13px;
    top: 12px;
    width: 14px;
}

.ninja-arm,
.ninja-leg {
    background: #111827;
    border-radius: 999px;
    height: 4px;
    width: 16px;
}

.ninja-arm-front {
    animation: limbSwingA 360ms ease-in-out infinite alternate;
    left: 23px;
    top: 16px;
    transform-origin: left center;
}

.ninja-arm-back {
    animation: limbSwingB 360ms ease-in-out infinite alternate;
    left: 4px;
    top: 16px;
    transform-origin: right center;
}

.ninja-leg-front {
    animation: limbSwingB 360ms ease-in-out infinite alternate;
    left: 21px;
    top: 27px;
    transform-origin: left center;
}

.ninja-leg-back {
    animation: limbSwingA 360ms ease-in-out infinite alternate;
    left: 5px;
    top: 27px;
    transform-origin: right center;
}

.runner-speech {
    background: rgba(247, 240, 223, 0.94);
    border: 2px solid rgba(216, 189, 130, 0.9);
    border-radius: 8px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.22;
    margin: 0;
    min-height: 42px;
    padding: 6px 8px;
}

.runner-speech.speech-pop {
    animation: speechPop 360ms ease-out;
}

.return-home-btn {
    align-self: stretch;
    background: url("assets/ui-elements/按钮1.png") center / 100% 100% no-repeat;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    min-height: 42px;
    padding: 0;
    position: relative;
}

.return-home-btn::before {
    content: none;
}

.return-home-btn::after {
    content: none;
}

.return-home-btn:active {
    transform: translateY(1px);
}

.top-return-home-btn {
    align-self: stretch;
    min-height: 42px;
    width: 48px;
}

/* 共享布局模式：位置和尺寸由 js/layout.js 按微信的 ui-layout.js 计算。
 * 旧 CSS 仅保留视觉皮肤与控件内部排版，不能再参与页面级定位。 */
html[data-layout-source="shared"] #game-shell {
    display: block;
    padding: 0;
}

html[data-layout-source="shared"] #game-shell .top-bar,
html[data-layout-source="shared"] #game-shell .board-wrap,
html[data-layout-source="shared"] #game-shell .tutorial-panel,
html[data-layout-source="shared"] #game-shell .game-message-panel,
html[data-layout-source="shared"] #game-shell #hint-btn,
html[data-layout-source="shared"] #game-shell #shuffle-btn {
    box-sizing: border-box;
}

html[data-layout-source="shared"] #game-shell .top-bar {
    min-height: 0;
}

html[data-layout-source="shared"] #game-shell .board-wrap {
    aspect-ratio: auto;
}

html[data-layout-source="shared"] #game-shell .tool-bar {
    display: contents;
}

html[data-layout-source="shared"] #game-shell #hint-btn,
html[data-layout-source="shared"] #game-shell #shuffle-btn {
    min-height: 0;
}

.game-message-panel {
    align-items: center;
    background: rgba(255, 247, 223, 0.92);
    border: 2px solid rgba(205, 143, 102, 0.62);
    border-radius: 8px;
    box-sizing: border-box;
    color: #633828;
    display: flex;
    font-size: 12px;
    font-weight: 850;
    justify-content: center;
    line-height: 1.2;
    padding: 4px 9px;
    text-align: center;
}

.game-message-panel[hidden] {
    display: none;
}

.tutorial-complete-panel {
    align-items: center;
    background: rgba(255, 246, 211, 0.97);
    border: 2px solid #98713b;
    border-radius: 10px;
    box-sizing: border-box;
    color: #315f4a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 18px;
    text-align: center;
}

.tutorial-complete-panel[hidden] {
    display: none;
}

.tutorial-complete-panel p {
    font-size: 17px;
    font-weight: 850;
    line-height: 1.35;
    margin: 0;
}

.tutorial-complete-panel button {
    background: url("assets/themes/cat-cafe/home/primary-button.png") center / 100% 100% no-repeat;
    border: 0;
    color: #5a2b12;
    font-weight: 900;
    min-height: 0;
    padding: 0;
}

.game-message-panel.success {
    border-color: rgba(91, 145, 78, 0.8);
}

.game-message-panel.warn {
    border-color: rgba(204, 126, 62, 0.88);
}

html[data-layout-source="shared"] .home-menu {
    max-width: none;
    padding: 0;
}

html[data-layout-source="shared"] .home-menu h1 {
    box-sizing: border-box;
    transform: none;
}

html[data-layout-source="shared"] .home-kicker,
html[data-layout-source="shared"] .home-subtitle {
    display: none;
}

html[data-layout-source="shared"] .home-actions {
    display: contents;
}

html[data-layout-source="shared"] .home-action,
html[data-layout-source="shared"] .home-notice {
    box-sizing: border-box;
}

/* 桌面端保留手机舞台的比例，背景只在居中的虚拟手机高度内缩放。 */
html[data-layout-source="shared"][data-layout-desktop="true"] .home-screen,
html[data-layout-source="shared"][data-layout-desktop="true"] #game-shell {
    background-position: center;
    background-size: auto var(--brick-layout-frame-height);
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-screen::after,
html[data-layout-source="shared"][data-layout-desktop="true"] #game-shell::after {
    border: 1px solid rgba(99, 56, 40, 0.16);
    border-radius: 2px;
    box-shadow: 0 12px 36px rgba(76, 41, 29, 0.22);
    content: "";
    height: var(--brick-layout-frame-height);
    left: 50%;
    pointer-events: none;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--brick-layout-frame-width);
    z-index: 0;
}

html[data-layout-source="shared"][data-layout-desktop="true"] #game-shell > *,
html[data-layout-source="shared"][data-layout-desktop="true"] .home-menu {
    z-index: 1;
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-menu::before {
    left: calc(var(--brick-layout-frame-left) + 14px);
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-menu h1 {
    font-size: var(--brick-layout-home-title-size);
    white-space: nowrap;
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-action {
    font-size: var(--brick-layout-home-action-size);
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-notice span {
    font-size: var(--brick-layout-home-notice-title-size);
}

html[data-layout-source="shared"][data-layout-desktop="true"] .home-notice p {
    font-size: var(--brick-layout-home-notice-size);
}

#win-panel {
    align-items: center;
    background: rgba(17, 24, 39, 0.78);
    border-radius: 4px;
    color: #fff7e6;
    display: flex;
    flex-direction: column;
    inset: 0;
    justify-content: center;
    position: absolute;
    text-align: center;
    z-index: 10;
}

#win-panel[hidden] {
    display: none;
}

#win-panel h1 {
    font-size: 44px;
    line-height: 1;
    margin: 0 0 8px;
}

#win-panel p {
    margin: 0 0 18px;
}

#win-panel .reward-text {
    background: rgba(255, 247, 230, 0.16);
    border: 1px solid rgba(254, 240, 138, 0.34);
    border-radius: 8px;
    color: #fef08a;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.25;
    margin: -6px 18px 16px;
    max-width: 260px;
    padding: 7px 9px;
}

#win-panel .reward-text[hidden] {
    display: none;
}

.win-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
    width: min(210px, 78%);
}

#leaderboard-btn {
    background: #25634c;
}

/* 数据浮层：普通/每日排行榜，以及复用其布局的军团排行榜。 */
.leaderboard-panel {
    align-items: center;
    background: rgba(9, 14, 22, 0.74);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 30;
}

.leaderboard-panel[hidden] {
    display: none;
}

.leaderboard-dialog {
    background: rgba(247, 240, 223, 0.97);
    border: 3px solid rgba(216, 189, 130, 0.95);
    border-radius: 8px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
    color: var(--ink);
    display: grid;
    gap: 10px;
    max-height: min(620px, calc(100dvh - 36px));
    overflow: hidden;
    padding: 12px;
    width: min(420px, 100%);
}

.leaderboard-header {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.leaderboard-header h1 {
    font-size: 20px;
    line-height: 1.1;
    margin: 0;
}

#leaderboard-close-btn {
    background: #334155;
    min-height: 34px;
    padding: 0 14px;
}

.leaderboard-tabs {
    background: rgba(53, 95, 67, 0.1);
    border: 1px solid rgba(53, 95, 67, 0.16);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
}

.leaderboard-tab {
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 950;
    min-height: 34px;
    padding: 0 8px;
}

.leaderboard-tab.is-active {
    background: #25634c;
    color: #fff7e6;
}

.leaderboard-tab.is-disabled,
.leaderboard-tab:disabled {
    background: rgba(148, 163, 184, 0.24);
    color: rgba(41, 35, 25, 0.46);
    cursor: not-allowed;
}

.leaderboard-columns,
.leaderboard-row {
    display: grid;
    gap: 8px;
    grid-template-columns: 42px minmax(0, 1fr) 92px;
}

.leaderboard-dialog.is-daily .leaderboard-columns,
.leaderboard-dialog.is-daily .leaderboard-row {
    grid-template-columns: 38px minmax(0, 1fr) 70px 76px;
}

.legion-rank-dialog .leaderboard-columns,
.legion-rank-dialog .leaderboard-row {
    grid-template-columns: 42px minmax(0, 1fr) 92px;
}

.leaderboard-columns {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    padding: 0 8px;
}

.leaderboard-columns span:first-child {
    grid-column: 2;
}

.leaderboard-list {
    display: grid;
    gap: 6px;
    list-style: none;
    margin: 0;
    max-height: min(420px, calc(100dvh - 222px));
    overflow: auto;
    padding: 0;
}

.leaderboard-row {
    align-items: center;
    background: rgba(53, 95, 67, 0.1);
    border: 1px solid rgba(53, 95, 67, 0.16);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 850;
    min-height: 36px;
    padding: 6px 8px;
}

.leaderboard-rank {
    color: #25634c;
    font-variant-numeric: tabular-nums;
}

.leaderboard-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-time {
    font-variant-numeric: tabular-nums;
    justify-self: end;
}

.leaderboard-completed {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    justify-self: end;
}

.leaderboard-status {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
    margin: 2px 0 0;
    text-align: center;
}

.leaderboard-status[hidden] {
    display: none;
}

/* 军团与商店浮层：国家选择、个人贡献和 4 x 4 商品格。 */
.legion-panel {
    align-items: center;
    background: rgba(8, 13, 20, 0.76);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 14px;
    position: fixed;
    z-index: 32;
}

.legion-panel[hidden] {
    display: none;
}

.legion-dialog {
    background: linear-gradient(180deg, rgba(247, 240, 223, 0.98), rgba(222, 205, 157, 0.98));
    border: 3px solid rgba(88, 74, 48, 0.78);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(690px, calc(100dvh - 28px));
    overflow: auto;
    padding: 12px;
    width: min(440px, 100%);
}

.legion-header {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.legion-header p {
    color: #7c4a12;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: 0.08em;
    margin: 0 0 2px;
    text-transform: uppercase;
}

.legion-header h1 {
    font-size: 24px;
    line-height: 1;
    margin: 0;
}

#legion-close-btn {
    background: #334155;
    min-height: 34px;
    padding: 0 14px;
}

.legion-status-card {
    align-items: center;
    background: rgba(53, 95, 67, 0.12);
    border: 1px solid rgba(53, 95, 67, 0.2);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(112px, auto) minmax(82px, auto);
    margin-top: auto;
    order: 20;
    padding: 8px 10px;
}

.legion-status-card span,
.legion-status-card small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}

.legion-status-card strong {
    display: block;
    color: #14532d;
    font-size: 16px;
    line-height: 1.1;
}

#legion-rank-btn,
#legion-shop-btn {
    background: #7c2d12;
    min-height: 34px;
    padding: 0 10px;
    white-space: nowrap;
}

#legion-rank-btn {
    background: #25634c;
}

.legion-rank-country {
    color: #14532d;
    font-size: 12px;
    font-weight: 950;
    margin: -4px 0 0;
    text-align: center;
}

.legion-rank-tabs {
    grid-template-columns: 1fr 1fr 1fr;
}

.legion-rank-panel {
    z-index: 35;
}

@media (max-width: 390px) {
    .legion-status-card {
        grid-template-columns: minmax(0, 1fr) minmax(92px, auto) minmax(64px, auto);
    }

    #legion-rank-btn,
    #legion-shop-btn {
        font-size: 12px;
        padding: 0 8px;
    }
}

.world-map {
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.5), transparent 12%),
        linear-gradient(180deg, rgba(14, 165, 233, 0.2), rgba(20, 184, 166, 0.18)),
        #a7d8c6;
    border: 2px solid rgba(32, 63, 47, 0.38);
    border-radius: 8px;
    height: 172px;
    overflow: hidden;
    position: relative;
}

.world-map::before {
    background:
        radial-gradient(ellipse at 21% 30%, #356f42 0 13%, transparent 13.5%),
        radial-gradient(ellipse at 33% 62%, #3f7f4c 0 12%, transparent 12.5%),
        radial-gradient(ellipse at 50% 27%, #5a8f43 0 9%, transparent 9.5%),
        radial-gradient(ellipse at 56% 45%, #3e7d48 0 15%, transparent 15.5%),
        radial-gradient(ellipse at 48% 64%, #6c8f3b 0 12%, transparent 12.5%),
        radial-gradient(ellipse at 75% 38%, #3f7f4c 0 18%, transparent 18.5%),
        radial-gradient(ellipse at 82% 73%, #5a8f43 0 8%, transparent 8.5%);
    content: "";
    inset: 0;
    position: absolute;
}

.map-region {
    background: rgba(255, 247, 230, 0.9);
    border: 2px solid rgba(20, 83, 45, 0.62);
    border-radius: 999px;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
    color: #14532d;
    font-size: 11px;
    font-weight: 1000;
    height: 34px;
    min-height: 34px;
    padding: 0;
    position: absolute;
    width: 44px;
    z-index: 1;
}

.map-region.is-active,
.map-region:focus-visible {
    background: #facc15;
    border-color: #7c2d12;
}

.region-north-america {
    left: 15%;
    top: 22%;
}

.region-south-america {
    left: 30%;
    top: 59%;
}

.region-europe {
    left: 47%;
    top: 22%;
}

.region-africa {
    left: 49%;
    top: 54%;
}

.region-asia {
    left: 70%;
    top: 34%;
}

.region-oceania {
    left: 78%;
    top: 70%;
}

.legion-picker {
    display: grid;
    gap: 8px;
}

.continent-tabs,
.country-list {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.continent-tab,
.country-option {
    background: rgba(255, 247, 230, 0.86);
    border: 1px solid rgba(53, 95, 67, 0.22);
    color: var(--ink);
    font-size: 12px;
    font-weight: 900;
    min-height: 38px;
    padding: 5px 7px;
}

.continent-tab.is-active,
.country-option.is-selected {
    background: #25634c;
    color: #fff7e6;
}

.country-option:disabled:not(.is-selected) {
    background: rgba(148, 163, 184, 0.3);
    color: rgba(41, 35, 25, 0.42);
    cursor: not-allowed;
}

.country-option {
    align-items: center;
    display: grid;
    gap: 2px;
    justify-items: center;
}

.country-option small {
    color: inherit;
    font-size: 10px;
    opacity: 0.78;
}

.legion-message {
    color: #14532d;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.25;
    margin: 0;
    min-height: 16px;
    order: 10;
    text-align: center;
}

.shop-panel {
    align-items: center;
    background: rgba(8, 13, 20, 0.76);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 14px;
    position: fixed;
    z-index: 34;
}

.shop-panel[hidden] {
    display: none;
}

.shop-dialog {
    background: linear-gradient(180deg, rgba(247, 240, 223, 0.98), rgba(222, 205, 157, 0.98));
    border: 3px solid rgba(88, 74, 48, 0.78);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
    color: var(--ink);
    display: grid;
    gap: 10px;
    max-height: min(690px, calc(100dvh - 28px));
    overflow: hidden;
    padding: 12px;
    width: min(440px, 100%);
}

.shop-header {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.shop-header p {
    color: #7c4a12;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: 0.08em;
    margin: 0 0 2px;
    text-transform: uppercase;
}

.shop-header h1 {
    font-size: 24px;
    line-height: 1;
    margin: 0;
}

#shop-close-btn {
    background: #334155;
    min-height: 34px;
    padding: 0 14px;
}

#collection-close-btn {
    background: #334155;
    min-height: 34px;
    padding: 0 14px;
}

.collection-empty {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    margin: 0;
    text-align: center;
}

.shop-wallet {
    align-items: baseline;
    background: rgba(53, 95, 67, 0.12);
    border: 1px solid rgba(53, 95, 67, 0.2);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    padding: 8px 10px;
}

.shop-wallet span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.shop-wallet strong {
    color: #14532d;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.shop-grid {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: min(390px, calc(100dvh - 242px));
    overflow-y: auto;
    padding: 1px;
    touch-action: pan-y;
}

.shop-slot {
    align-content: center;
    aspect-ratio: 1;
    background: rgba(255, 247, 230, 0.72);
    border: 1px solid rgba(53, 95, 67, 0.18);
    border-radius: 8px;
    color: rgba(41, 35, 25, 0.34);
    display: grid;
    font-size: 11px;
    font-weight: 900;
    gap: 4px;
    justify-items: center;
    min-height: 70px;
    padding: 6px;
    text-align: center;
}

.shop-slot.item {
    background: rgba(255, 247, 230, 0.94);
    border-color: rgba(124, 45, 18, 0.42);
    color: var(--ink);
    position: relative;
}

.shop-slot.item.is-unavailable,
.shop-slot.item.is-too-expensive,
.shop-slot.item.is-limited {
    color: rgba(41, 35, 25, 0.48);
    filter: grayscale(0.45);
}

.shop-slot.item.is-unavailable {
    cursor: help;
}

.shop-slot.item.is-too-expensive {
    cursor: not-allowed;
}

.shop-icon {
    font-size: 22px;
    line-height: 1;
}

.shop-price {
    color: #7c2d12;
    font-size: 10px;
    font-weight: 950;
}

.shop-limit {
    background: #7c2d12;
    border-radius: 999px;
    color: #fff7e6;
    font-size: 9px;
    font-weight: 1000;
    line-height: 1;
    max-width: calc(100% - 8px);
    overflow: hidden;
    padding: 3px 5px;
    position: absolute;
    right: 4px;
    text-overflow: ellipsis;
    top: 4px;
    white-space: nowrap;
}

.shop-slot.item.is-limited .shop-limit {
    background: #64748b;
}

.shop-confirm {
    background: rgba(17, 24, 39, 0.9);
    border-radius: 8px;
    color: #fff7e6;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.shop-confirm[hidden] {
    display: none;
}

.shop-confirm p {
    font-size: 13px;
    font-weight: 900;
    line-height: 1.3;
    margin: 0;
    text-align: center;
}

.shop-name-field {
    display: grid;
    gap: 5px;
}

.shop-name-field[hidden] {
    display: none;
}

.shop-name-field span {
    color: rgba(255, 247, 230, 0.82);
    font-size: 11px;
    font-weight: 950;
}

.shop-name-field input {
    background: #fff7e6;
    border: 2px solid rgba(253, 224, 71, 0.55);
    border-radius: 7px;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 850;
    min-height: 38px;
    outline: none;
    padding: 0 10px;
}

.shop-name-field input:focus {
    border-color: #facc15;
}

.shop-confirm-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
}

#shop-confirm-cancel-btn {
    background: #475569;
}

#shop-confirm-ok-btn {
    background: #b45309;
}

.shop-message {
    color: #14532d;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.25;
    margin: 0;
    min-height: 16px;
    text-align: center;
}

/* 交互动画：提示、教学手势、拖拽回弹、碰撞消除与主界面氛围。 */
@keyframes hintPulse {
    0%,
    100% {
        transform: rotate(0deg) scale(1);
    }
    35% {
        transform: rotate(-8deg) scale(1.08);
    }
    70% {
        transform: rotate(8deg) scale(1.08);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-4px);
    }
    40% {
        transform: translateX(4px);
    }
    60% {
        transform: translateX(-3px);
    }
    80% {
        transform: translateX(3px);
    }
}

@keyframes tutorialTargetPulse {
    0%,
    100% {
        box-shadow: inset 0 -4px rgba(0, 0, 0, 0.16), 0 0 0 rgba(254, 240, 138, 0);
        transform: scale(1);
    }
    50% {
        box-shadow: inset 0 -4px rgba(0, 0, 0, 0.16), 0 0 18px rgba(254, 240, 138, 0.72);
        transform: scale(1.05);
    }
}

@keyframes tutorialHandDown {
    0% {
        opacity: 0;
        transform: translate(-50%, -62%) scale(0.96);
    }
    18% {
        opacity: 0.82;
    }
    72% {
        opacity: 0.82;
        transform: translate(-50%, 18%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, 28%) scale(1);
    }
}

@keyframes suggestShake {
    0%,
    100% {
        transform: translateX(0) rotate(0deg) scale(1);
    }
    20% {
        transform: translateX(-3px) rotate(-4deg) scale(1.05);
    }
    40% {
        transform: translateX(3px) rotate(4deg) scale(1.05);
    }
    60% {
        transform: translateX(-2px) rotate(-3deg) scale(1.04);
    }
    80% {
        transform: translateX(2px) rotate(3deg) scale(1.04);
    }
}

@keyframes badgePulse {
    0%,
    100% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.32);
    }
}

@keyframes removePop {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    60% {
        opacity: 1;
        transform: scale(1.18) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.28) rotate(-12deg);
    }
}

@keyframes impactFly {
    0% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    24% {
        opacity: 1;
        transform: translate3d(calc(var(--impact-x) * 0.26), calc(var(--impact-y) * 0.26), 0) scale(1.04);
    }
    58% {
        opacity: 1;
        transform: translate3d(calc(var(--impact-x) * 0.72), calc(var(--impact-y) * 0.72), 0) scale(1.08);
    }
    72% {
        opacity: 1;
        transform: translate3d(var(--impact-x), var(--impact-y), 0) scale(0.98);
    }
    82% {
        opacity: 1;
        transform: translate3d(var(--impact-exit-mid-x), var(--impact-exit-mid-y), 0) scale(0.82) rotate(-4deg);
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--impact-exit-x), var(--impact-exit-y), 0) scale(0.16) rotate(-8deg);
    }
}

@keyframes impactTrail {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--impact-angle, 0deg)) translateX(-42%) scaleX(0.28);
    }
    20% {
        opacity: 0.88;
        transform: translate(-50%, -50%) rotate(var(--impact-angle, 0deg)) translateX(-42%) scaleX(0.78);
    }
    70% {
        opacity: 0.78;
        transform: translate(-50%, -50%) rotate(var(--impact-angle, 0deg)) translateX(-42%) scaleX(1.24);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--impact-angle, 0deg)) translateX(-42%) scaleX(0.18);
    }
}

@keyframes impactTarget {
    0% {
        filter: brightness(1);
        opacity: 1;
        transform: scale(1);
    }
    66% {
        filter: brightness(1.05);
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    72% {
        filter: brightness(1.42);
        opacity: 1;
        transform: translate3d(2px, -1px, 0) scale(1.04);
    }
    82% {
        filter: brightness(1.5);
        opacity: 1;
        transform: translate3d(var(--impact-target-mid-x), var(--impact-target-mid-y), 0) scale(0.86);
    }
    100% {
        filter: brightness(1.1);
        opacity: 0;
        transform: translate3d(var(--impact-out-x), var(--impact-out-y), 0) scale(0.16) rotate(8deg);
    }
}

@keyframes impactBurst {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.28) rotate(0deg);
    }
    32% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(18deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.48) rotate(42deg);
    }
}

@keyframes settle {
    0% {
        transform: scale(0.94);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes crossPreviewPulse {
    0%,
    100% {
        opacity: 0.48;
        transform: scale(0.92);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes choiceTargetPulse {
    0%,
    100% {
        filter: brightness(1);
        transform: scale(1);
    }
    50% {
        filter: brightness(1.18);
        transform: scale(1.06);
    }
}

@keyframes runnerPace {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(calc(var(--board-width) * 0.34));
    }
}

@keyframes scarfFlutter {
    from {
        transform: rotate(-10deg);
    }
    to {
        transform: rotate(14deg);
    }
}

@keyframes limbSwingA {
    from {
        transform: rotate(-28deg);
    }
    to {
        transform: rotate(26deg);
    }
}

@keyframes limbSwingB {
    from {
        transform: rotate(24deg);
    }
    to {
        transform: rotate(-24deg);
    }
}

@keyframes speechPop {
    0% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes mistDrift {
    from {
        transform: translateX(-7%) skewY(-7deg);
    }
    to {
        transform: translateX(7%) skewY(-7deg);
    }
}

@keyframes scrollFloat {
    from {
        transform: translate3d(-50%, -50%, 0) rotateX(14deg) rotateZ(-2.5deg) translateY(-4px);
    }
    to {
        transform: translate3d(-50%, -50%, 0) rotateX(9deg) rotateZ(2deg) translateY(5px);
    }
}

@keyframes scrollPulse {
    from {
        filter: brightness(1);
    }
    to {
        filter: brightness(1.12);
    }
}

@keyframes ringCast {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.32) rotate(0deg);
    }
    22% {
        opacity: 0.92;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5) rotate(50deg);
    }
}

@keyframes sparkTravel {
    from {
        transform: translate3d(-8px, 7px, 0) scale(0.78);
    }
    to {
        transform: translate3d(10px, -8px, 0) scale(1.2);
    }
}

@keyframes castBreath {
    from {
        transform: translateX(-50%) translateY(0) scale(1);
    }
    to {
        transform: translateX(-50%) translateY(-4px) scale(1.02);
    }
}

@media (max-height: 760px) {
    .home-menu h1 {
        top: clamp(120px, 17dvh, 156px);
        width: min(88vw, 430px);
    }

    .home-subtitle {
        font-size: clamp(13px, 3.4vw, 16px);
        top: clamp(310px, 39dvh, 350px);
    }

    .home-notice {
        bottom: max(10px, calc(env(safe-area-inset-bottom) + 6px));
        min-height: 52px;
        padding: 7px 12px 7px 15px;
    }

    .home-notice p {
        font-size: 11px;
    }

    .home-actions {
        bottom: max(70px, calc(env(safe-area-inset-bottom) + 64px));
        grid-template-rows: 64px 46px;
    }

    .home-action.primary {
        height: 64px;
        width: min(66vw, 286px);
    }

    #game-shell {
        gap: 5px;
        justify-content: flex-start;
    }

    :root {
        --board-width: min(calc(100vw - 4px), calc((100dvh - 136px) / var(--board-ratio)), 760px);
    }

    .top-bar {
        padding: 6px;
    }

    .runner-lane {
        grid-template-columns: minmax(82px, 0.52fr) minmax(0, 1fr) 39px;
        height: 48px;
    }

    .runner-track,
    .runner-speech,
    .return-home-btn {
        min-height: 39px;
    }

    .runner-speech {
        font-size: 11px;
        padding: 5px 7px;
    }
}
