﻿.shanghai-wrap {
    max-width: 1160px;
    margin: 0 auto;
    padding: 24px 16px 56px;
    color: #111827;
}

.shanghai-rb-module {
    position: relative;
    z-index: 30;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto 18px;
    overflow: visible !important;
}

.shanghai-rb-module:not(:empty)::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -18px;
    bottom: -18px;
    z-index: -1;
    pointer-events: auto;
}

.shanghai-rb-module > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
}

.shanghai-rb-module .rb_section,
.shanghai-rb-module .rb_module,
.shanghai-rb-module .rb_widget,
.shanghai-rb-module .rb_box,
.shanghai-rb-module .rb_inner,
.shanghai-rb-module .rb_module_inner,
.shanghai-rb-module .rb_widget_inner {
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
}

.shanghai-rb-top,
.shanghai-rb-top > *,
.shanghai-rb-top .rb_layout_box,
.shanghai-rb-top .content_box,
.shanghai-rb-top .flex_box_inner,
.shanghai-rb-top .add_module_wrap,
.shanghai-rb-top .rb_section,
.shanghai-rb-top .rb_module,
.shanghai-rb-top .rb_widget,
.shanghai-rb-top .rb_box,
.shanghai-rb-top .rb_inner,
.shanghai-rb-top .rb_module_inner,
.shanghai-rb-top .rb_widget_inner,
.shanghai-rb-bottom,
.shanghai-rb-bottom > *,
.shanghai-rb-bottom .rb_layout_box,
.shanghai-rb-bottom .content_box,
.shanghai-rb-bottom .flex_box_inner,
.shanghai-rb-bottom .add_module_wrap,
.shanghai-rb-bottom .rb_section,
.shanghai-rb-bottom .rb_module,
.shanghai-rb-bottom .rb_widget,
.shanghai-rb-bottom .rb_box,
.shanghai-rb-bottom .rb_inner,
.shanghai-rb-bottom .rb_module_inner,
.shanghai-rb-bottom .rb_widget_inner {
    padding: 0 !important;
    box-sizing: border-box;
}

section.co_gap_pc_20 .shanghai-rb-module,
.co_gap_pc_20 .shanghai-rb-module,
.co_gap_pc_20 .shanghai-rb-module.flex_box {
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
}

section.co_gap_pc_20 .shanghai-rb-module .content_box,
.co_gap_pc_20 .shanghai-rb-module .content_box,
.co_gap_pc_20 .shanghai-rb-module .add_module_wrap {
    padding: 0 !important;
}

.shanghai-rb-module:empty {
    display: none;
}

.shanghai-rb-module + .shanghai-hero,
.shanghai-rb-module + .shanghai-card,
.shanghai-rb-module + .shanghai-game-shell {
    margin-top: 0;
}

.shanghai-hero,
.shanghai-card,
.shanghai-game-shell {
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.06);
}

.shanghai-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 32px;
    background: linear-gradient(120deg, #f8fbff 0%, #fffdf7 100%);
}

.shanghai-eyebrow {
    margin: 0 0 6px;
    color: #2563a8;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
}

.shanghai-hero h1,
.shanghai-game-head h1,
.shanghai-card h1,
.shanghai-card h2 {
    margin: 0 0 10px;
    line-height: 1.25;
}

.shanghai-hero p {
    margin: 0;
    color: #475467;
    line-height: 1.7;
}

.shanghai-hero-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    min-width: 180px;
}

.shanghai-hero-stats span {
    display: block;
    padding: 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    text-align: center;
}

.shanghai-card {
    margin-top: 18px;
    padding: 24px;
}

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

.shanghai-mode {
    display: grid;
    gap: 6px;
    padding: 18px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    background: #f8fafc;
}

.shanghai-mode:hover {
    border-color: #2f67b1;
    background: #f3f7ff;
}

.shanghai-mode span {
    font-weight: 800;
    font-size: 16px;
}

.shanghai-mode strong {
    font-size: 22px;
    line-height: 1.25;
}

.shanghai-mode em {
    color: #64748b;
    font-size: 13px;
    font-style: normal;
}

.shanghai-mode b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: start;
    min-width: 86px;
    min-height: 36px;
    margin-top: 8px;
    padding: 0 16px;
    border-radius: 8px;
    background: #2f67b1;
    color: #fff;
    font-size: 14px;
    font-weight: 900;
}

.shanghai-mode:hover b {
    background: #1f4f8d;
}

.shanghai-continue {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
}

.shanghai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.shanghai-btn:hover {
    border-color: #2563a8;
}

.shanghai-btn-primary {
    border-color: #2f67b1;
    background: #2f67b1;
    color: #fff;
}

.shanghai-btn-danger {
    border-color: #e07a7a;
    color: #b42318;
}

.shanghai-game-shell {
    position: relative;
    padding: 20px;
}

.shanghai-celebration {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 24px;
    background: rgba(7, 18, 34, .88);
}

.shanghai-celebration[hidden] {
    display: none;
}

.shanghai-celebration-panel {
    position: relative;
    z-index: 2;
    width: min(440px, 100%);
    padding: 30px 26px;
    border: 2px solid #facc15;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .38);
    opacity: 0;
    transform: scale(.78) translateY(20px);
    transition: opacity .28s ease, transform .38s cubic-bezier(.2, .8, .2, 1.2);
}

.shanghai-celebration.is-active .shanghai-celebration-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.shanghai-celebration-kicker {
    margin: 0 0 8px;
    color: #b45309;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.shanghai-celebration-panel h2 {
    margin: 0;
    font-size: 30px;
    line-height: 1.25;
}

.shanghai-celebration-panel > p:not(.shanghai-celebration-kicker) {
    margin: 12px 0 0;
    color: #475467;
    font-weight: 800;
}

.shanghai-celebration-countdown {
    min-height: 20px;
    font-size: 13px;
}

.shanghai-celebration-panel .shanghai-btn {
    min-width: 150px;
    margin-top: 20px;
}

.shanghai-confetti {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.shanghai-confetti i {
    position: absolute;
    top: -28px;
    left: var(--confetti-x);
    width: 9px;
    height: 18px;
    opacity: 0;
    transform: rotate(var(--confetti-rotate));
    animation: shanghai-confetti-fall var(--confetti-duration) linear var(--confetti-delay) infinite;
}

@keyframes shanghai-confetti-fall {
    0% {
        opacity: 0;
        transform: translate3d(0, -30px, 0) rotate(var(--confetti-rotate));
    }
    10% {
        opacity: 1;
    }
    100% {
        opacity: .9;
        transform: translate3d(var(--confetti-drift), calc(100vh + 60px), 0) rotate(780deg);
    }
}

.shanghai-game-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.shanghai-game-foot {
    position: relative;
    z-index: 3;
    clear: both;
    margin-top: 14px;
    background: #fff;
}

.shanghai-hud {
    display: grid;
    grid-template-columns: repeat(7, minmax(76px, 1fr));
    gap: 8px;
}

.shanghai-hud span {
    padding: 10px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 12px;
}

.shanghai-hud strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

.shanghai-board-frame {
    position: relative;
    z-index: 1;
    isolation: isolate;
    overflow: hidden;
    min-height: 660px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: radial-gradient(circle at 50% 10%, #26476e 0%, #102235 54%, #0c1726 100%);
}

.shanghai-board {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 660px;
    margin: 0 auto;
    --shanghai-tile-scale: 1;
}

.shanghai-tile {
    position: absolute;
    width: calc(64px * var(--shanghai-tile-scale, 1));
    height: calc(82px * var(--shanghai-tile-scale, 1));
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: translateZ(0);
    transform-origin: 50% 50%;
    cursor: pointer;
    padding: 0;
    overflow: visible;
    transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}

.shanghai-tile-visual {
    position: absolute;
    left: 0;
    top: 0;
    width: 64px;
    height: 82px;
    transform: scale(var(--shanghai-tile-scale, 1));
    transform-origin: 0 0;
    pointer-events: none;
}

.shanghai-tile-visual:before,
.shanghai-tile-visual:after {
    content: "";
    position: absolute;
    left: 15px;
    right: 7px;
    pointer-events: none;
}

.shanghai-tile-visual:before {
    top: 7px;
    z-index: 3;
    height: 3px;
    background: linear-gradient(90deg, rgba(70,48,13,.9), rgba(255,243,111,.95) 12%, rgba(255,255,229,.92) 55%, rgba(122,82,17,.86));
    box-shadow: 0 1px 0 rgba(31, 25, 10, .62);
}

.shanghai-tile-visual:after {
    bottom: 11px;
    z-index: 3;
    height: 5px;
    background: linear-gradient(180deg, rgba(239,219,76,.95), rgba(98,120,39,.96) 45%, rgba(28, 52, 18, .98));
    box-shadow: 0 2px 0 rgba(15, 31, 13, .86), 0 -1px 0 rgba(255,247,151,.48);
}

.shanghai-tile-shell {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    filter:
        drop-shadow(-1px 0 0 rgba(18, 39, 13, .92))
        drop-shadow(1px 0 0 rgba(79, 54, 16, .78))
        drop-shadow(0 -1px 0 rgba(74, 52, 14, .78))
        drop-shadow(0 1px 0 rgba(20, 42, 14, .9));
    pointer-events: none;
    user-select: none;
}

.shanghai-tile-face {
    position: absolute;
    z-index: 2;
    left: 20px;
    top: 14px;
    width: 34px;
    height: 50px;
    display: grid;
    align-items: center;
    justify-items: center;
    color: #24345d;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 0 rgba(255,255,235,.65);
}

.shanghai-tile-face:before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .72);
    box-shadow: none;
}

.shanghai-tile-corner {
    position: absolute;
    top: 2px;
    right: 3px;
    font-style: normal;
    font-size: 8px;
    font-weight: 800;
    color: #1d2438;
}

.shanghai-tile-rank {
    align-self: end;
    margin-bottom: -2px;
    font-size: 17px;
    font-weight: 900;
    color: #9f261c;
}

.shanghai-tile-kanji {
    align-self: start;
    font-size: 18px;
    font-weight: 900;
    color: #9f261c;
}

.shanghai-tile-big {
    font-size: 25px;
    font-weight: 900;
    color: #111827;
}

.shanghai-tile-face-wind .shanghai-tile-big {
    font-size: 27px;
    color: #17245a;
}

.shanghai-tile-face-dragon .shanghai-tile-big {
    font-size: 25px;
    color: #9f261c;
}

.shanghai-tile-pips,
.shanghai-tile-bamboos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-content: center;
    justify-content: center;
    gap: 1px;
    width: 24px;
    min-height: 34px;
}

.shanghai-tile-pips .pip {
    width: 6px;
    height: 6px;
    border: 2px solid #2f52b8;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px #fff9bf;
}

.shanghai-tile-pips .pip-1 {
    border-color: #b94c32;
}

.shanghai-tile-pips .pip-2 {
    border-color: #3b7f46;
}

.shanghai-tile-bamboos {
    grid-template-columns: repeat(3, 7px);
    gap: 0 1px;
}

.shanghai-tile-bamboos i {
    color: #277443;
    font-style: normal;
    font-size: 12px;
    font-weight: 900;
    line-height: .82;
}

.shanghai-tile-flower {
    display: grid;
    gap: 0;
    place-items: center;
    color: #2b6b3e;
}

.shanghai-tile-flower i {
    color: #b84976;
    font-size: 21px;
    font-style: normal;
    line-height: 1;
}

.shanghai-tile-flower b {
    margin-top: -2px;
    color: #4f5d41;
    font-size: 9px;
    font-weight: 800;
}

.shanghai-tile-count-1 { grid-template-columns: 1fr; }
.shanghai-tile-count-2 { grid-template-columns: repeat(2, 1fr); }
.shanghai-tile-count-3 { grid-template-columns: repeat(2, 1fr); }
.shanghai-tile-count-3 > :nth-child(3) { grid-column: 1 / -1; justify-self: center; }
.shanghai-tile-count-4 { grid-template-columns: repeat(2, 1fr); }
.shanghai-tile-count-5 { grid-template-columns: repeat(2, 1fr); }
.shanghai-tile-count-5 > :nth-child(5) { grid-column: 1 / -1; justify-self: center; }
.shanghai-tile-count-6 { grid-template-columns: repeat(2, 1fr); }
.shanghai-tile-count-7,
.shanghai-tile-count-8,
.shanghai-tile-count-9 { grid-template-columns: repeat(3, 1fr); }

.shanghai-tile.is-locked {
    filter: saturate(.78) brightness(.86);
    cursor: not-allowed;
}

.shanghai-tile.is-selected {
    outline: 3px solid #facc15;
    transform: translateY(-6px) translateZ(0);
}

.shanghai-tile.is-hint {
    outline: 3px solid #22c55e;
}

.shanghai-tile.is-removed {
    opacity: 0;
    pointer-events: none;
}

.shanghai-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #0f172a;
    background: #eff6ff;
}

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

.shanghai-message h2 {
    margin: 0;
    font-size: 18px;
}

.shanghai-message p {
    margin: 4px 0 0;
    color: #475467;
    font-weight: 700;
}

.shanghai-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.shanghai-game-shell:fullscreen,
.shanghai-game-shell:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}

.shanghai-game-shell:fullscreen .shanghai-board-frame,
.shanghai-game-shell:-webkit-full-screen .shanghai-board-frame {
    flex: 1 0 auto;
}

.shanghai-game-shell:fullscreen .shanghai-game-foot,
.shanghai-game-shell:-webkit-full-screen .shanghai-game-foot {
    flex: 0 0 auto;
}

.shanghai-rule p {
    margin: 0;
    color: #475467;
    line-height: 1.7;
}

.shanghai-table {
    width: 100%;
    border-collapse: collapse;
}

.shanghai-table th,
.shanghai-table td {
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

@media (max-width: 900px) {
    .shanghai-hero {
        display: block;
    }

    .shanghai-hero-stats,
    .shanghai-hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 14px;
    }

    .shanghai-mode-grid {
        grid-template-columns: 1fr;
    }

    .shanghai-game-shell {
        padding: 12px;
    }

    .shanghai-board-frame {
        min-height: 72vh;
    }

    .shanghai-celebration {
        padding: 14px;
    }

    .shanghai-celebration-panel {
        padding: 24px 18px;
    }

    .shanghai-celebration-panel h2 {
        font-size: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shanghai-celebration-panel {
        transition: none;
    }

    .shanghai-confetti i {
        animation-duration: 1ms;
        animation-iteration-count: 1;
    }
}
