:root {
    --bg: #07140f;
    --bg-2: #0f2b1c;
    --panel: rgba(0, 0, 0, 0.36);
    --panel-strong: rgba(7, 16, 11, 0.86);
    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.22);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.62);
    --soft: rgba(255, 255, 255, 0.10);
    --green: #77ff7c;
    --green-2: #15a65d;
    --green-3: #07391f;
    --amber: #ffd66b;
    --amber-2: #ff9f2e;
    --red: #ff5151;
    --red-2: #8d1010;
    --wood: #8a4f27;
    --wood-dark: #32180c;
    --radius-xl: 30px;
    --radius-lg: 22px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 8%, rgba(80, 255, 151, 0.22), transparent 34%),
        radial-gradient(circle at 8% 82%, rgba(255, 195, 92, 0.13), transparent 30%),
        linear-gradient(180deg, #07140f 0%, #0f2b1c 52%, #06100b 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans", sans-serif;
    touch-action: manipulation;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(255, 214, 107, 0.65);
    outline-offset: 3px;
}

button:disabled,
input:disabled {
    cursor: not-allowed;
}

img {
    display: block;
    max-width: 100%;
}

.splash-screen {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 16px;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 35%, rgba(128, 255, 120, 0.18), transparent 28%),
        linear-gradient(180deg, #092216, #030806 78%);
    transition: opacity 0.45s ease, visibility 0.45s ease, transform 0.45s ease;
}

.splash-screen.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(1.02);
}

.splash-screen h1 {
    margin: 0;
    font-size: clamp(34px, 7vw, 76px);
    font-weight: 1000;
    line-height: 0.95;
    letter-spacing: -0.06em;
    text-align: center;
}

.splash-screen p {
    margin: -4px 0 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 14px;
    font-weight: 750;
    text-align: center;
}

.splash-orbit {
    position: relative;
    width: 146px;
    height: 146px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 80px rgba(121, 255, 122, 0.18);
}

.splash-logo {
    position: relative;
    z-index: 2;
    width: 92px;
    height: 92px;
    animation: splashLogo 1.6s cubic-bezier(.2, .8, .2, 1) infinite;
}

.splash-orbit span {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 214, 107, 0.28);
    border-radius: 999px;
    animation: orbitPulse 1.9s ease-in-out infinite;
}

.splash-orbit span:nth-child(3) { animation-delay: 0.18s; transform: scale(1.18); }
.splash-orbit span:nth-child(4) { animation-delay: 0.36s; transform: scale(1.36); }

.splash-progress {
    width: min(320px, 70vw);
    height: 9px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.splash-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #d9ff70, #2df089, #ffd66b);
    box-shadow: 0 0 20px rgba(119, 255, 124, 0.45);
    transition: width 0.18s ease;
}

@keyframes splashLogo {
    0%, 100% { transform: translateY(0) scale(1) rotate(-5deg); }
    50% { transform: translateY(-8px) scale(1.06) rotate(4deg); }
}

@keyframes orbitPulse {
    0%, 100% { opacity: 0.28; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.18); }
}

.background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.glow {
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 999px;
    filter: blur(72px);
    opacity: 0.32;
}

.glow-a {
    top: 2rem;
    left: 6vw;
    background: #53ff9b;
}

.glow-b {
    right: 3vw;
    bottom: 4vh;
    background: #ffd86b;
}

.floating-asset {
    position: absolute;
    width: 58px;
    height: 58px;
    opacity: 0.92;
    filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.28));
    animation: floatApple 5s ease-in-out infinite;
}

.apple-a { left: 2vw; top: 14vh; }
.apple-b { right: 2vw; top: 36vh; width: 68px; height: 68px; animation-delay: -1.4s; }
.apple-c { left: 34vw; bottom: 4vh; width: 48px; height: 48px; animation-delay: -2.3s; }

@keyframes floatApple {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(-7deg); }
    50% { transform: translate3d(0, -18px, 0) rotate(8deg); }
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(100% - 32px, 1480px);
    min-height: 100vh;
    margin: 0 auto;
    padding: calc(20px + var(--safe-top)) var(--safe-right) calc(20px + var(--safe-bottom)) var(--safe-left);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.glass-card {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    border-radius: var(--radius-xl);
}

.brand-block {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 16px;
}

.brand-mark {
    flex: 0 0 auto;
    width: 66px;
    height: 66px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    border: 1px solid rgba(255, 214, 107, 0.36);
    background: linear-gradient(135deg, rgba(237, 49, 49, 0.95), rgba(255, 191, 74, 0.92));
    box-shadow: 0 18px 40px rgba(255, 130, 28, 0.18);
    animation: brandPulse 2.3s ease-in-out infinite;
}

.brand-mark img {
    width: 50px;
    height: 50px;
}

@keyframes brandPulse {
    0%, 100% { transform: rotate(-5deg) scale(1); }
    50% { transform: rotate(3deg) scale(1.04); }
}

.eyebrow {
    margin: 0 0 4px;
    color: rgba(255, 214, 107, 0.86);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 0.96;
    letter-spacing: -0.04em;
}

h1 {
    font-size: clamp(32px, 4vw, 58px);
    font-weight: 950;
}

h2 {
    font-size: 24px;
    font-weight: 930;
}

.brand-subtitle,
.muted {
    color: var(--muted);
}

.brand-subtitle {
    max-width: 720px;
    margin: 7px 0 0;
    font-size: 14px;
    line-height: 1.45;
}

.wallet-grid {
    display: grid;
    grid-template-columns: minmax(136px, 1fr) minmax(150px, 1fr) 56px 56px;
    gap: 10px;
    align-items: stretch;
}

.stat-card,
.summary-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--soft);
    padding: 12px 14px;
}

.balance-card.balance-flash {
    animation: balanceFlash 0.5s ease;
}

@keyframes balanceFlash {
    0% { transform: scale(1); box-shadow: none; }
    45% { transform: scale(1.025); box-shadow: 0 0 0 4px rgba(119, 255, 124, 0.16); }
    100% { transform: scale(1); box-shadow: none; }
}

.stat-card span,
.summary-card span {
    display: block;
    margin-bottom: 4px;
    color: rgba(236, 255, 241, 0.6);
    font-size: 12px;
}

.stat-card strong,
.summary-card strong {
    display: block;
    color: var(--text);
    font-size: 21px;
    font-weight: 950;
    white-space: nowrap;
}

#currentWinText,
#nextWinText {
    color: var(--amber);
}

#lastWinText {
    color: #c8ff8b;
}

.icon-button {
    min-width: 52px;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--text);
    background: var(--soft);
    cursor: pointer;
    font-size: 23px;
    font-weight: 950;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.16);
}

.game-layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(292px, 360px) minmax(0, 1fr) minmax(150px, 190px);
    gap: 18px;
    align-items: stretch;
}

.control-panel,
.board-panel,
.ladder-panel {
    border-radius: var(--radius-xl);
    padding: 16px;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-heading,
.board-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.compact-status {
    border: 1px solid rgba(255, 214, 107, 0.18);
    border-radius: 999px;
    background: rgba(255, 214, 107, 0.09);
    padding: 8px 12px;
    color: #ffedbd;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.ghost-button,
.small-button {
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: var(--soft);
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
}

.ghost-button {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 850;
}

.small-button {
    padding: 0 12px;
    font-weight: 950;
}

.ghost-button:hover,
.small-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.16);
}

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

.preset-button {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 17px;
    color: var(--text);
    background: var(--soft);
    cursor: pointer;
    font-size: 15px;
    font-weight: 950;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.preset-button:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.16);
}

.preset-button.active {
    border-color: rgba(255, 214, 107, 0.92);
    color: #171006;
    background: linear-gradient(135deg, var(--amber), var(--amber-2));
    box-shadow: 0 12px 26px rgba(255, 170, 44, 0.18);
}

.field-label {
    color: rgba(236, 255, 241, 0.72);
    font-size: 13px;
    font-weight: 750;
}

.bet-input-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
}

.bet-input {
    width: 100%;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.38);
    padding: 0 16px;
    font-size: 18px;
    font-weight: 950;
    outline: none;
}

.bet-input:focus {
    border-color: rgba(255, 214, 107, 0.76);
    box-shadow: 0 0 0 4px rgba(255, 214, 107, 0.12);
}

.fairness-card {
    border: 1px solid rgba(119, 255, 124, 0.22);
    border-radius: 20px;
    background: rgba(119, 255, 124, 0.09);
    padding: 14px;
}

.fairness-title {
    color: #d7ffe0;
    font-size: 14px;
    font-weight: 950;
}

.fairness-card p {
    margin: 8px 0 10px;
    color: rgba(236, 255, 241, 0.66);
    font-size: 12px;
    line-height: 1.55;
}

.fairness-card code {
    display: block;
    overflow: hidden;
    color: rgba(225, 255, 232, 0.78);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
}

.primary-button,
.cashout-button,
.topup-button {
    width: 100%;
    min-height: 56px;
    border: 0;
    border-radius: 18px;
    cursor: pointer;
    color: #11170b;
    font-size: 17px;
    font-weight: 950;
    letter-spacing: -0.01em;
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.2);
    transition: transform 0.16s ease, filter 0.16s ease, opacity 0.16s ease;
}

.primary-button {
    background: linear-gradient(135deg, #d9ff70, #2df089);
}

.cashout-button {
    background: linear-gradient(135deg, #ffe071, #ff9632);
}

.topup-button {
    color: var(--text);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.08));
    border: 1px solid var(--line);
}

.primary-button:hover,
.cashout-button:hover,
.topup-button:hover {
    transform: translateY(-1px) scale(1.005);
    filter: brightness(1.03);
}

.primary-button:disabled,
.cashout-button:disabled,
.topup-button:disabled,
.preset-button:disabled,
.ghost-button:disabled,
.small-button:disabled {
    opacity: 0.48;
    transform: none;
    cursor: not-allowed;
}

.button-loading {
    position: relative;
    pointer-events: none;
}

.button-loading::after {
    content: "";
    position: absolute;
    right: 15px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

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

.message-box {
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--soft);
    padding: 14px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    font-weight: 760;
    line-height: 1.45;
}

.message-box[data-type="safe"],
.message-box[data-type="max_win"] {
    border-color: rgba(119, 255, 124, 0.35);
    background: rgba(119, 255, 124, 0.14);
    color: #d8ffdf;
}

.message-box[data-type="lost"],
.message-box[data-type="error"] {
    border-color: rgba(255, 81, 81, 0.35);
    background: rgba(255, 81, 81, 0.14);
    color: #ffd4d4;
}

.message-box[data-type="cashed"],
.message-box[data-type="topup"] {
    border-color: rgba(255, 214, 107, 0.35);
    background: rgba(255, 214, 107, 0.14);
    color: #ffedbd;
}

.board-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(23, 16, 8, 0.76);
}

.board-frame {
    position: relative;
    flex: 1;
    min-height: 0;
    border: 1px solid rgba(255, 214, 107, 0.18);
    border-radius: 30px;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.08), transparent 19%),
        linear-gradient(180deg, #4b2b16, #1c120b);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -28px 70px rgba(0, 0, 0, 0.26);
    padding: 12px;
    overflow: hidden;
}

.board-frame::before,
.board-frame::after {
    content: "";
    position: absolute;
    z-index: 0;
    width: 52px;
    height: 52px;
    background: url('../img/apple.svg') center / contain no-repeat;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.36));
}

.board-frame::before {
    left: -6px;
    top: -4px;
}

.board-frame::after {
    right: -9px;
    bottom: 20%;
}

.board {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 7px;
    height: 100%;
    min-height: 550px;
    border: 1px solid rgba(0, 0, 0, 0.36);
    border-radius: 22px;
    background: rgba(0, 0, 0, 0.18);
    padding: 8px;
}

.board-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(80px, 9vw, 122px);
    gap: 8px;
    min-height: 0;
}

.cell-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    min-width: 0;
}

.game-cell {
    position: relative;
    min-width: 0;
    min-height: 42px;
    overflow: hidden;
    border: 1px solid #5d3218;
    border-radius: 16px;
    color: #f4ffe9;
    background: linear-gradient(135deg, #9b5b2b, #5b2f17);
    cursor: default;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13), inset 0 -16px 24px rgba(0, 0, 0, 0.17);
    transform-style: preserve-3d;
    transition: transform 0.16s ease, filter 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
    user-select: none;
}

.game-cell:not(:disabled) {
    cursor: pointer;
}

.game-cell:not(:disabled):active {
    transform: scale(0.94);
}

.game-cell.active {
    border-color: rgba(218, 255, 138, 0.95);
    background: linear-gradient(135deg, #72f05c, #126d3b);
    box-shadow: 0 12px 26px rgba(36, 255, 120, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.game-cell.active::after {
    content: "";
    position: absolute;
    inset: 2px;
    border: 2px solid rgba(220, 255, 148, 0.85);
    border-radius: 14px;
    animation: pulseRing 1.05s ease-in-out infinite;
}

@keyframes pulseRing {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 1; }
}

.game-cell.passed {
    border-color: rgba(119, 255, 124, 0.18);
    background: linear-gradient(135deg, rgba(15, 118, 64, 0.86), rgba(5, 34, 20, 0.94));
    opacity: 0.74;
}

.game-cell.safe {
    border-color: rgba(219, 255, 138, 0.95);
    background: linear-gradient(135deg, #9bff55, #167242);
}

.game-cell.bad {
    border-color: rgba(255, 147, 147, 0.95);
    background: linear-gradient(135deg, #d72e2e, #4b0707);
}

.game-cell.dimmed {
    opacity: 0.46;
}

.game-cell.revealing {
    animation: cellFlip 0.52s cubic-bezier(.2, .8, .2, 1);
}

.game-cell.safe.revealing {
    animation: cellFlip 0.52s cubic-bezier(.2, .8, .2, 1), safePop 0.55s ease 0.08s;
}

.game-cell.bad.revealing {
    animation: cellFlip 0.52s cubic-bezier(.2, .8, .2, 1), badShake 0.42s ease 0.18s;
}

@keyframes cellFlip {
    0% { transform: rotateX(0deg) scale(1); filter: brightness(1); }
    48% { transform: rotateX(88deg) scale(0.94); filter: brightness(1.35); }
    100% { transform: rotateX(0deg) scale(1); filter: brightness(1); }
}

@keyframes safePop {
    0% { box-shadow: 0 0 0 rgba(119, 255, 124, 0); }
    45% { box-shadow: 0 0 0 7px rgba(119, 255, 124, 0.18), 0 18px 30px rgba(119, 255, 124, 0.13); }
    100% { box-shadow: 0 0 0 rgba(119, 255, 124, 0); }
}

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

.cell-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 45%);
}

.cell-icon {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    font-size: clamp(20px, 3vw, 36px);
    font-weight: 950;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.34);
}

.cell-icon img {
    width: min(72%, 46px);
    height: min(72%, 46px);
    object-fit: contain;
    filter: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.35));
}

.cell-arrow {
    display: grid;
    place-items: center;
    width: min(52%, 38px);
    height: min(52%, 38px);
    border-radius: 999px;
    color: #15360f;
    background: rgba(255, 255, 255, 0.72);
    font-size: clamp(17px, 2.7vw, 30px);
    line-height: 1;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

.row-multiplier {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.42);
    color: rgba(255, 255, 255, 0.72);
    font-size: clamp(13px, 1.5vw, 17px);
    font-weight: 950;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.row-multiplier.current,
.ladder-item.current {
    border-color: rgba(255, 214, 107, 0.92);
    background: linear-gradient(135deg, var(--amber), var(--amber-2));
    color: #171006;
    transform: scale(1.015);
}

.row-multiplier.passed,
.ladder-item.passed {
    border-color: rgba(119, 255, 124, 0.3);
    background: rgba(119, 255, 124, 0.14);
    color: #d8ffdf;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.ladder-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ladder {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ladder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--soft);
    padding: 10px 11px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    font-weight: 920;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.ladder-item span {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.mobile-action-bar {
    display: none;
}

.modal-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
    display: none;
}

.rules-modal {
    position: relative;
    width: min(100%, 620px);
    max-height: min(86vh, 720px);
    overflow: auto;
    border-radius: 30px;
    background: rgba(17, 27, 18, 0.94);
    padding: 28px;
}

.rules-modal ol {
    margin: 18px 0;
    padding-left: 22px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.7;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: var(--soft);
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.warning-note {
    border: 1px solid rgba(255, 214, 107, 0.24);
    border-radius: 18px;
    background: rgba(255, 214, 107, 0.1);
    padding: 14px;
    color: #ffedbd;
    line-height: 1.55;
}

.modal-open {
    overflow: hidden;
}

.noscript-box {
    position: fixed;
    z-index: 200;
    inset: auto 16px 16px;
    border: 1px solid rgba(255, 81, 81, 0.3);
    border-radius: 18px;
    background: rgba(80, 0, 0, 0.86);
    padding: 14px;
    color: #fff;
    font-weight: 800;
    text-align: center;
}

@media (max-width: 1180px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .wallet-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) 56px 56px;
    }

    .game-layout {
        grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    }

    .ladder-panel {
        grid-column: 1 / -1;
    }

    .ladder {
        display: grid;
        grid-template-columns: repeat(10, minmax(78px, 1fr));
        overflow-x: auto;
        padding-bottom: 2px;
    }
}

@media (max-width: 900px) {
    .app-shell {
        width: min(100% - 22px, 760px);
        padding-top: calc(12px + var(--safe-top));
        padding-bottom: calc(88px + var(--safe-bottom));
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .board-panel { order: 1; }
    .control-panel { order: 2; }
    .ladder-panel { order: 3; }

    .control-panel,
    .board-panel,
    .ladder-panel,
    .topbar {
        border-radius: 24px;
        padding: 12px;
    }

    .board-frame {
        border-radius: 24px;
        padding: 9px;
    }

    .board {
        min-height: auto;
        gap: 5px;
        padding: 6px;
        border-radius: 18px;
    }

    .board-row {
        grid-template-columns: minmax(0, 1fr) 78px;
        gap: 5px;
    }

    .cell-grid {
        gap: 5px;
    }

    .game-cell {
        aspect-ratio: 1.18 / 1;
        min-height: 36px;
        border-radius: 12px;
    }

    .game-cell.active::after {
        border-radius: 10px;
    }

    .row-multiplier {
        border-radius: 12px;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .mobile-action-bar {
        position: fixed;
        z-index: 10;
        left: max(12px, var(--safe-left));
        right: max(12px, var(--safe-right));
        bottom: max(12px, var(--safe-bottom));
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        border: 1px solid var(--line);
        border-radius: 22px;
        background: rgba(5, 13, 9, 0.76);
        box-shadow: 0 18px 44px rgba(0, 0, 0, 0.44);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        padding: 10px;
    }

    .compact {
        min-height: 50px;
        border-radius: 16px;
        font-size: 15px;
    }
}

@media (max-width: 620px) {
    .app-shell {
        width: min(100% - 14px, 480px);
        gap: 10px;
    }

    .topbar {
        gap: 12px;
    }

    .brand-block {
        gap: 12px;
    }

    .brand-mark {
        width: 54px;
        height: 54px;
        border-radius: 19px;
    }

    .brand-mark img {
        width: 42px;
        height: 42px;
    }

    .brand-subtitle {
        display: none;
    }

    .eyebrow {
        font-size: 10px;
        letter-spacing: 0.22em;
    }

    h1 {
        font-size: clamp(28px, 10vw, 42px);
    }

    h2 {
        font-size: 21px;
    }

    .wallet-grid {
        grid-template-columns: 1fr 1fr;
    }

    .icon-button {
        min-height: 48px;
    }

    .stat-card,
    .summary-card {
        padding: 10px;
        border-radius: 16px;
    }

    .stat-card strong,
    .summary-card strong {
        font-size: 18px;
    }

    .board-toolbar {
        display: none;
    }

    .board-frame::before,
    .board-frame::after,
    .floating-asset {
        display: none;
    }

    .board-row {
        grid-template-columns: minmax(0, 1fr) 64px;
    }

    .game-cell {
        min-height: 30px;
        border-radius: 10px;
    }

    .cell-icon {
        font-size: clamp(18px, 7vw, 28px);
    }

    .cell-icon img {
        width: min(78%, 34px);
        height: min(78%, 34px);
    }

    .cell-arrow {
        width: min(60%, 28px);
        height: min(60%, 28px);
    }

    .row-multiplier {
        font-size: 11px;
    }

    .preset-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .preset-button {
        min-height: 44px;
        border-radius: 14px;
        font-size: 12px;
    }

    .bet-input-wrap {
        grid-template-columns: 1fr 50px 50px;
    }

    .primary-button,
    .cashout-button,
    .topup-button {
        min-height: 52px;
    }

    .fairness-card {
        padding: 12px;
    }
}

@media (max-width: 430px) {
    .wallet-grid {
        gap: 8px;
    }

    .stat-card span,
    .summary-card span {
        font-size: 10px;
    }

    .stat-card strong,
    .summary-card strong {
        font-size: 16px;
    }

    .control-panel,
    .board-panel,
    .ladder-panel,
    .topbar {
        border-radius: 20px;
        padding: 10px;
    }

    .board-frame {
        padding: 6px;
    }

    .board {
        gap: 4px;
        padding: 5px;
    }

    .board-row {
        grid-template-columns: minmax(0, 1fr) 58px;
        gap: 4px;
    }

    .cell-grid {
        gap: 4px;
    }

    .game-cell {
        min-height: 27px;
    }

    .summary-grid {
        gap: 7px;
    }

    .ladder {
        grid-template-columns: repeat(10, minmax(68px, 1fr));
    }

    .ladder-item {
        padding: 8px;
        font-size: 12px;
    }
}

@media (max-height: 760px) and (min-width: 901px) {
    .app-shell {
        gap: 12px;
        padding-top: calc(12px + var(--safe-top));
        padding-bottom: calc(12px + var(--safe-bottom));
    }

    .topbar {
        padding: 12px;
    }

    .brand-subtitle {
        display: none;
    }

    .brand-mark {
        width: 54px;
        height: 54px;
        border-radius: 18px;
    }

    .brand-mark img {
        width: 42px;
        height: 42px;
    }

    .control-panel,
    .board-panel,
    .ladder-panel {
        padding: 12px;
    }

    .board {
        min-height: 460px;
    }

    .preset-button,
    .primary-button,
    .cashout-button,
    .topup-button,
    .bet-input {
        min-height: 44px;
    }

    .message-box {
        min-height: 46px;
        padding: 10px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }
}
