html,
body {
    height: 100%;
}

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body {
    overflow-x: hidden;
    overflow-y: scroll;
    background: #000 !important;
}

body.modal-open {
    overflow-y: scroll !important;
    padding-right: 0 !important;
}

.gk-page {
    min-height: 100vh;
    width: min(480px, 100vw);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    background: #fff;
}

/* ── 顶部紧凑区 ── */
.gk-head-compact {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gk-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    line-height: 1.3;
    color: #0f172a;
}

.gk-user-bal a {
    text-decoration: none;
}

.gk-balance-value {
    font-weight: 700;
    color: #0d6efd;
}

.gk-exit-link {
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
}

.gk-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    line-height: 1.3;
}

.gk-subline {
    color: #64748b;
    display: flex;
    gap: 2px;
}

.gk-menu-links {
    display: flex;
    gap: 10px;
}

.gk-menu-links a {
    color: #0d6efd;
    text-decoration: none;
    font-size: 13px;
}

.gk-menu-links a:hover {
    text-decoration: underline;
}

.gk-status {
    min-height: 20px;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.35;
    background: #f1f5f9;
    color: #334155;
}

.gk-status.type-success {
    background: #dcfce7;
    color: #166534;
}

.gk-status.type-warning {
    background: #ffedd5;
    color: #9a3412;
}

.gk-status.type-danger {
    background: #fee2e2;
    color: #991b1b;
}

.gk-status.type-info {
    background: #e0f2fe;
    color: #0c4a6e;
}

/* ── 聊天动态 ── */
.gk-chat-dynamic-widget {
    margin: 0;
}

.gk-chat-dynamic-container {
    display: flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.25;
}

.gk-chat-dynamic-container .activity-time {
    color: #334155;
    margin-right: 4px;
}

/* ── 游戏主体 ── */
.gk-game-shell {
    display: flex;
    flex-direction: column;
    border: 1px solid #cdd8c5;
    border-radius: 14px;
    padding: 6px 8px;
    background: radial-gradient(circle at 10% 10%, #8dd07f 0%, #76be6a 45%, #65ab5a 100%);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
    transition: background 0.6s ease, box-shadow 0.6s ease, border-color 0.6s ease;
}

.gk-game-shell.is-fs-mode {
    border-color: #f4b300;
    background: radial-gradient(circle at 15% 10%, #a8ecff 0%, #65d8f2 40%, #2cb7dc 100%);
    box-shadow: 0 6px 18px rgba(12, 119, 156, 0.35), 0 0 0 2px rgba(255, 208, 64, 0.35) inset;
}

/* ── FS横幅 ── */
.gk-fs-banner {
    margin-bottom: 2px;
    padding: 0 10px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(90deg, #fff3b0 0%, #ffe37a 50%, #ffd24d 100%);
    color: #663c00;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2px;
    text-align: center;
    transform: translateY(-4px) scale(0.98);
    transition: max-height 0.45s ease, opacity 0.45s ease, transform 0.45s ease, padding 0.45s ease;
}

.gk-fs-banner.show {
    max-height: 32px;
    opacity: 1;
    padding: 5px 10px;
    border-color: rgba(120, 80, 0, 0.2);
    transform: translateY(0) scale(1);
}

.gk-fs-banner.flash {
    animation: gkFsBannerFlash 1.5s ease-out;
}

.gk-game-shell.is-fs-mode .gk-board-grid {
    filter: drop-shadow(0 0 8px rgba(255, 221, 102, 0.35));
}

.gk-game-shell.is-fs-mode .gk-cell {
    background: linear-gradient(140deg, #2f9ec6 0%, #1c7fa7 100%);
    border-color: rgba(255, 219, 111, 0.35);
}

/* ── 棋盘区域 ── */
.gk-board-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0;
}

.gk-board-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

.gk-cell {
    background: linear-gradient(140deg, #3f9650 0%, #2b7d3e 100%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

.gk-icon {
    display: inline-block;
    font-size: clamp(30px, 5.5vw, 52px);
    line-height: 1;
    transform-origin: center center;
    transition: transform 0.32s ease, opacity 0.32s ease, filter 0.32s ease;
}

.gk-icon-img {
    display: block;
    width: 78%;
    height: 78%;
    object-fit: contain;
    object-position: center;
    transform-origin: center center;
    transition: transform 0.32s ease, opacity 0.32s ease, filter 0.32s ease;
    user-select: none;
    pointer-events: none;
}

.gk-icon-fallback {
    font-size: clamp(30px, 5.5vw, 52px);
}

/* 特殊符号（市场系数 / FS）默认更醒目 */
.gk-cell[data-code="market"],
.gk-cell[data-code="fs"] {
    border-width: 1.5px;
}

.gk-cell[data-code="market"] {
    border-color: rgba(255, 187, 42, 0.92);
    background:
        radial-gradient(circle at 30% 22%, rgba(255, 232, 126, 0.46) 0%, rgba(255, 232, 126, 0) 60%),
        linear-gradient(140deg, #4b9848 0%, #39863d 62%, #2f7534 100%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 235, 150, 0.42),
        0 0 10px rgba(243, 170, 23, 0.28);
}

.gk-cell[data-code="fs"] {
    border-color: rgba(102, 189, 255, 0.88);
    background:
        radial-gradient(circle at 30% 22%, rgba(147, 224, 255, 0.38) 0%, rgba(147, 224, 255, 0) 58%),
        linear-gradient(140deg, #3f9456 0%, #327f45 62%, #2b733c 100%);
    box-shadow:
        inset 0 0 0 1px rgba(173, 229, 255, 0.32),
        0 0 9px rgba(84, 186, 255, 0.22);
}

.gk-cell[data-code="market"]::before,
.gk-cell[data-code="fs"]::before {
    content: '';
    position: absolute;
    inset: 17%;
    border-radius: 999px;
    pointer-events: none;
    z-index: 0;
    animation: gkSpecialHaloPulse 1.45s ease-in-out infinite;
}

.gk-cell[data-code="market"]::before {
    background: radial-gradient(circle, rgba(255, 206, 88, 0.34) 0%, rgba(255, 206, 88, 0) 72%);
}

.gk-cell[data-code="fs"]::before {
    background: radial-gradient(circle, rgba(124, 219, 255, 0.28) 0%, rgba(124, 219, 255, 0) 74%);
}

.gk-cell[data-code="market"] .gk-icon-img,
.gk-cell[data-code="market"] .gk-icon-fallback,
.gk-cell[data-code="fs"] .gk-icon-img,
.gk-cell[data-code="fs"] .gk-icon-fallback {
    position: relative;
    z-index: 1;
}

.gk-cell[data-code="market"] .gk-icon-img,
.gk-cell[data-code="market"] .gk-icon-fallback {
    transform: scale(1.1);
    filter: drop-shadow(0 2px 4px rgba(95, 52, 0, 0.45));
    animation: gkMarketIconPulse 1.2s ease-in-out infinite;
}

.gk-cell[data-code="fs"] .gk-icon-img,
.gk-cell[data-code="fs"] .gk-icon-fallback {
    transform: scale(1.05);
    filter: drop-shadow(0 1px 3px rgba(0, 38, 71, 0.42));
}

.gk-cell[data-code="market"] .gk-icon-img {
    width: 95%;
    height: 95%;
}

.gk-cell[data-code="fs"] .gk-icon-img {
    width: 92%;
    height: 92%;
}

.gk-cell[data-code="market"] .gk-icon-fallback,
.gk-cell[data-code="fs"] .gk-icon-fallback {
    font-size: clamp(34px, 6.2vw, 58px);
}

.gk-cell.is-empty {
    background: linear-gradient(140deg, #4aa35a 0%, #3a8d4a 100%);
    opacity: 0.9;
}

.gk-board-grid.is-clearing .gk-icon {
    animation: gkIconDrop 0.52s ease-in forwards;
    animation-delay: calc(var(--i, 0) * 0.006s);
}

.gk-board-grid.is-clearing .gk-icon-img {
    animation: gkIconDrop 0.52s ease-in forwards;
    animation-delay: calc(var(--i, 0) * 0.006s);
}

.gk-cell.is-win .gk-icon {
    animation: gkWinPop 0.78s ease-out forwards;
}

.gk-cell.is-win .gk-icon-img {
    animation: gkWinPop 0.78s ease-out forwards;
}

.gk-overlay-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    max-width: calc(100% - 16px);
    white-space: nowrap;
    line-height: 1.05;
    text-align: center;
    font-size: clamp(22px, 6.2vw, 36px);
    font-weight: 900;
    color: #ffe56a;
    text-shadow: 0 2px 0 #835500, 0 0 12px rgba(255, 213, 0, 0.7);
    opacity: 0;
}

.gk-overlay-text.show {
    animation: gkRewardFloat 2.1s ease-out forwards;
}

/* ── 底部操作栏 - 合并为一行 ── */
.gk-bottom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    justify-content: space-between;
}

.gk-bet-wrap {
    flex-shrink: 0;
}

.gk-action-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.gk-bet-select {
    height: 34px;
    padding: 0 24px 0 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    appearance: auto;
}

.gk-auto-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 5px 6px;
    height: 34px;
    width: 66px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
    user-select: none;
    flex-shrink: 0;
}

.gk-auto-toggle .form-check-input {
    margin: 0;
    float: none;
    cursor: pointer;
}

.gk-start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 34px;
    width: 96px;
    min-width: 96px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    border-radius: 6px;
    touch-action: none;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── 玩家动态 ── */
.gk-dynamics-section {
    margin-top: 8px;
    padding: 0 2px;
}

.gk-dynamics-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.gk-dynamics-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0;
    flex-shrink: 0;
}

.gk-dynamics-head .gk-status {
    margin-left: auto;
    max-width: 74%;
    min-height: 0;
    padding: 1px 8px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gk-dynamics-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 8px;
    padding: 2px 8px;
}

.gk-dynamic-empty {
    padding: 7px 0;
    color: #94a3b8;
    font-size: 13px;
}

.gk-dynamic-item {
    font-size: 13px;
    color: #0f172a;
    line-height: 1.45;
    padding: 6px 0;
    border-bottom: 1px dashed #dbe3ea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gk-dynamic-item:last-child {
    border-bottom: none;
}

.gk-dynamic-time {
    color: #64748b;
    margin-right: 4px;
    font-variant-numeric: tabular-nums;
}

.gk-dynamic-name {
    color: #e11d48;
    font-weight: 700;
}

.gk-dynamic-action {
    color: #1f2937;
}

.gk-dynamic-amount {
    color: #0d6efd;
    font-weight: 700;
}

/* ── 弹窗内容 ── */
#historyModal .modal-dialog,
#statsModal .modal-dialog,
#soundModal .modal-dialog {
    max-width: min(440px, calc(100vw - 18px));
    margin: 10px auto;
}

#historyModal .modal-dialog.modal-dialog-scrollable {
    height: min(72vh, 560px);
}

#statsModal .modal-dialog.modal-dialog-scrollable {
    height: min(62vh, 500px);
}

#historyModal .modal-content,
#statsModal .modal-content,
#soundModal .modal-content {
    border: 1px solid #d6e3d0;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.24);
    overflow: hidden;
}

#historyModal .modal-header,
#statsModal .modal-header,
#soundModal .modal-header {
    padding: 10px 14px;
    border-bottom: 1px solid #dbe7d6;
    background: linear-gradient(180deg, #f7fbf5 0%, #eef7ea 100%);
}

#historyModal .modal-title,
#statsModal .modal-title,
#soundModal .modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

#historyModal .btn-close,
#statsModal .btn-close,
#soundModal .btn-close {
    transform: scale(0.92);
    opacity: 0.72;
}

#historyModal .modal-body,
#statsModal .modal-body,
#soundModal .modal-body {
    padding: 10px 12px;
    background: #f4f9f1;
}

#historyModal .modal-body {
    overflow-y: auto;
}

.gk-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.gk-stats-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 7px 9px;
    background: #fff;
}

.gk-stats-item .k {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.gk-stats-item .v {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.gk-history-head,
.gk-history-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    align-items: center;
    gap: 8px;
}

.gk-history-head {
    position: sticky;
    top: -1px;
    z-index: 1;
    padding: 6px 7px;
    margin-bottom: 6px;
    border: 1px solid #d8e4ef;
    border-radius: 8px;
    background: linear-gradient(180deg, #f8fbff 0%, #f2f7fd 100%);
    color: #5c6f84;
    font-size: 12px;
    font-weight: 700;
}

.gk-history-row {
    padding: 6px 7px;
    border: 1px solid #dfe8de;
    border-radius: 8px;
    background: #fdfefe;
    margin-bottom: 6px;
    font-size: 12px;
    color: #0f172a;
}

.gk-history-time {
    color: #334155;
}

.gk-history-cost {
    color: #0f172a;
    font-weight: 600;
}

.gk-history-win {
    color: #166534;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.gk-history-win-meta {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
}

.gk-history-win-meta.is-fs {
    color: #dc2626;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.gk-rank-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 6px;
    background: #fff;
}

.gk-rank-left {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #334155;
}

.gk-rank-right {
    color: #0f172a;
    font-weight: 600;
}

.gk-my-rank {
    font-size: 13px;
    color: #334155;
    border-top: 1px dashed #cbd5e1;
    padding-top: 8px;
}

.gk-sound-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #dbe7d6;
    border-radius: 8px;
    background: #fff;
}

.gk-sound-item + .gk-sound-item {
    margin-top: 8px;
}

.gk-sound-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.gk-sound-item .form-check-input {
    margin: 0;
    float: none;
    cursor: pointer;
}

.gk-sound-item.is-disabled {
    opacity: 0.58;
}

.gk-sound-tip {
    margin-top: 9px;
    font-size: 12px;
    line-height: 1.35;
    color: #64748b;
}

/* ── 动画 ── */
@keyframes gkIconDrop {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(24px);
        opacity: 0;
    }
}

@keyframes gkWinPop {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    35% {
        transform: scale(2);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes gkRewardFloat {
    0% {
        opacity: 0;
        transform: translate(-50%, -42%);
    }
    12% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    72% {
        opacity: 1;
        transform: translate(-50%, -66%);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -92%);
    }
}

@keyframes gkFsBannerFlash {
    0% {
        transform: translateY(0) scale(0.96);
        filter: brightness(1);
    }
    35% {
        transform: translateY(0) scale(1.03);
        filter: brightness(1.15);
    }
    100% {
        transform: translateY(0) scale(1);
        filter: brightness(1);
    }
}

@keyframes gkSpecialHaloPulse {
    0% {
        opacity: 0.7;
        transform: scale(0.92);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 0.7;
        transform: scale(0.92);
    }
}

@keyframes gkMarketIconPulse {
    0% {
        transform: scale(1.06);
        filter: drop-shadow(0 1px 3px rgba(95, 52, 0, 0.4)) brightness(1);
    }
    45% {
        transform: scale(1.14);
        filter: drop-shadow(0 2px 5px rgba(95, 52, 0, 0.5)) brightness(1.12);
    }
    100% {
        transform: scale(1.06);
        filter: drop-shadow(0 1px 3px rgba(95, 52, 0, 0.4)) brightness(1);
    }
}

/* ── GK页面专用：桌面端底部导航紧凑化，避免480宽容器下文字被截断 ── */
@media (min-width: 769px) {
    .gk-page #dbNavFooter .db-nav-wrapper {
        padding: 0 10px !important;
    }

    .gk-page #dbNavFooter .db-nav-content {
        gap: 6px !important;
        padding: 8px 0 !important;
    }

    .gk-page #dbNavFooter .db-nav-item {
        padding: 8px 8px !important;
        border-radius: 12px !important;
    }

    .gk-page #dbNavFooter .db-nav-icon {
        font-size: 21px !important;
        margin-bottom: 2px !important;
    }

    .gk-page #dbNavFooter .db-nav-text {
        font-size: 12px !important;
    }
}

/* ── 手机端适配 ── */
@media (max-width: 576px) {
    .gk-page {
        padding-left: 6px !important;
        padding-right: 6px !important;
        gap: 3px;
    }

    .gk-top-row {
        font-size: 14px;
    }

    .gk-info-row {
        font-size: 13px;
    }

    .gk-board-grid {
        gap: 4px;
    }

    .gk-icon,
    .gk-icon-fallback {
        font-size: clamp(24px, 6.8vw, 40px);
    }

    .gk-icon-img {
        width: 74%;
        height: 74%;
    }

    .gk-cell[data-code="market"] .gk-icon-img,
    .gk-cell[data-code="fs"] .gk-icon-img {
        width: 90%;
        height: 90%;
    }

    .gk-cell[data-code="market"] .gk-icon-fallback,
    .gk-cell[data-code="fs"] .gk-icon-fallback {
        font-size: clamp(28px, 7.2vw, 46px);
    }

    .gk-cell[data-code="market"] .gk-icon-img,
    .gk-cell[data-code="market"] .gk-icon-fallback {
        transform: scale(1.08);
    }

    .gk-cell[data-code="fs"] .gk-icon-img,
    .gk-cell[data-code="fs"] .gk-icon-fallback {
        transform: scale(1.03);
    }

    .gk-bet-select {
        font-size: 12px;
        height: 30px;
        padding: 0 20px 0 6px;
    }

    .gk-auto-toggle {
        height: 30px;
        width: 62px;
        font-size: 12px;
    }

    .gk-start-btn {
        min-height: 30px;
        width: 92px;
        min-width: 92px;
        padding: 5px 10px;
        font-size: 12px;
    }

    #historyModal .modal-dialog,
    #statsModal .modal-dialog,
    #soundModal .modal-dialog {
        max-width: calc(100vw - 12px);
        margin: 6px auto;
    }

    #historyModal .modal-dialog.modal-dialog-scrollable {
        height: min(68vh, 520px);
    }

    #statsModal .modal-dialog.modal-dialog-scrollable {
        height: min(58vh, 450px);
    }

    #historyModal .modal-title,
    #statsModal .modal-title,
    #soundModal .modal-title {
        font-size: 16px;
    }

    #historyModal .modal-body,
    #statsModal .modal-body,
    #soundModal .modal-body {
        padding: 8px 9px;
    }
}
