* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --page-bg: #0f0f1a;
    --page-text: #e7e7eb;
    --muted: #a7a7b5;
    --accent: #4ecca3;
    --panel: #17633b;
    --panel-deep: #10482b;
    --panel-border: #26885a;
    --card-bg: #fffef8;
    --card-border: #c9c6b9;
    --card-red: #c51f3a;
    --card-black: #181a21;
    --control-bg: rgba(6, 25, 17, 0.66);
    --focus: #ffd166;
}

html.light {
    --page-bg: #eef3f0;
    --page-text: #18221d;
    --muted: #53615a;
    --accent: #087b5a;
}

body {
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--page-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.55;
}

main {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 1rem;
}

.noscript {
    padding: 2rem 1rem;
    text-align: center;
}

.breadcrumb {
    margin-bottom: 0.8rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.breadcrumb a,
.content a {
    color: var(--accent);
}

.breadcrumb a {
    text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible,
.content a:hover,
.content a:focus-visible {
    text-decoration: underline;
}

.game-header {
    position: relative;
    margin-bottom: 0.85rem;
    padding: 0 3rem;
    text-align: center;
}

h1 {
    color: var(--accent);
    font-size: clamp(1.7rem, 4vw, 2.25rem);
    line-height: 1.2;
}

.tagline {
    margin-top: 0.35rem;
    color: var(--muted);
}

.theme-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid #3b3b54;
    border-radius: 999px;
    background: #1a1a2e;
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
}

.game-tip {
    margin: 0 auto 0.85rem;
    max-width: 860px;
}

.game-container {
    position: relative;
    margin-bottom: 2rem;
    padding: clamp(0.5rem, 2vw, 1rem);
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background:
        radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.12), transparent 46%),
        linear-gradient(160deg, var(--panel), var(--panel-deep));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
    color: #fff;
    touch-action: manipulation;
}

.game-container:fullscreen,
.game-container:-webkit-full-screen {
    overflow: auto;
    border: 0;
    border-radius: 0;
    padding: clamp(0.75rem, 3vw, 2rem);
}

.fullscreen-btn {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    z-index: 20;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 7px;
    background: rgba(7, 31, 20, 0.7);
    color: #fff;
    cursor: pointer;
    font-size: 1.15rem;
}

.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    min-height: 2.4rem;
    padding-right: 2.8rem;
}

.stats,
.game-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.stats > span {
    display: grid;
    min-width: 3.6rem;
    text-align: center;
}

.stat-label {
    color: #b7e5ca;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.15;
    text-transform: uppercase;
}

.stats strong {
    font-size: 1.05rem;
}

.game-actions button,
.action-btn {
    min-height: 2.25rem;
    padding: 0.42rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 7px;
    background: var(--control-bg);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
}

.game-actions button:hover:not(:disabled),
.action-btn:hover,
.fullscreen-btn:hover {
    border-color: var(--focus);
    background: rgba(5, 21, 14, 0.88);
}

.game-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.game-status {
    min-height: 1.55rem;
    margin: 0.35rem 0 0.55rem;
    color: #d3f1de;
    font-size: 0.8rem;
    text-align: center;
}

.game-status.warning {
    color: #ffe09a;
}

.top-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(0.5rem, 3vw, 2.5rem);
    margin-bottom: clamp(0.8rem, 2.5vw, 1.35rem);
}

.zone-group h2 {
    margin-bottom: 0.28rem;
    color: #b7e5ca;
    font-size: clamp(0.68rem, 1.8vw, 0.82rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.slot-grid,
.tableau {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(0.15rem, 0.8vw, 0.5rem);
}

.tableau {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-items: start;
}

.card-slot,
.tableau-column::before {
    aspect-ratio: 5 / 7;
    border: 2px dashed rgba(232, 255, 240, 0.3);
    border-radius: clamp(4px, 0.8vw, 8px);
    background: rgba(0, 0, 0, 0.08);
}

.card-slot {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    color: rgba(255, 255, 255, 0.34);
    cursor: pointer;
    font-size: clamp(1rem, 4vw, 2rem);
}

.foundation {
    color: rgba(255, 115, 129, 0.5);
}

.foundation.black-placeholder {
    color: rgba(255, 255, 255, 0.36);
}

.card-slot > .card {
    position: absolute;
    inset: -2px;
    width: calc(100% + 4px);
}

.tableau-column {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: clamp(86px, 12.2vw, 154px);
    cursor: pointer;
}

.tableau-column::before {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    content: "";
}

.card {
    position: relative;
    z-index: 1;
    display: block;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 5 / 7;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--card-border);
    border-radius: clamp(4px, 0.8vw, 8px);
    background: linear-gradient(145deg, #fff, var(--card-bg));
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
    color: var(--card-black);
    cursor: pointer;
    font-family: Georgia, "Times New Roman", serif;
    text-align: left;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tableau-column .card + .card {
    margin-top: -105%;
}

.card.red {
    color: var(--card-red);
}

.card.selected {
    z-index: 12;
    outline: 3px solid var(--focus);
    outline-offset: -2px;
    filter: brightness(1.05);
    transform: translateY(-2px);
}

.card:focus-visible,
.card-slot:focus-visible,
.tableau-column:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.card-corner {
    position: absolute;
    top: clamp(2px, 0.5vw, 6px);
    left: clamp(3px, 0.65vw, 7px);
    display: grid;
    justify-items: center;
    font-weight: 700;
    line-height: 0.9;
}

.card-rank {
    font-size: clamp(0.58rem, 1.8vw, 1.12rem);
}

.card-suit-small {
    margin-top: 0.12rem;
    font-size: clamp(0.52rem, 1.6vw, 1rem);
}

.card-suit-large {
    position: absolute;
    top: 52%;
    left: 53%;
    font-size: clamp(0.8rem, 3vw, 2rem);
    transform: translate(-50%, -50%);
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1rem;
    border-radius: inherit;
    background: rgba(4, 12, 8, 0.84);
}

.overlay.hidden {
    display: none;
}

.win-card {
    width: min(430px, 100%);
    padding: clamp(1.3rem, 5vw, 2rem);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 14px;
    background: #14251d;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.celebration {
    color: #ff7b88;
    font-size: 1.5rem;
    letter-spacing: 0.35rem;
}

.win-card h2 {
    margin: 0.45rem 0;
    color: var(--accent);
    font-size: 2rem;
}

.win-result {
    margin-top: 0.45rem;
    color: #d3f1de;
    font-weight: 700;
}

.overlay-actions {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 1rem;
}

.action-btn.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #0c2119;
}

.content {
    padding-top: 0.5rem;
    border-top: 1px solid #2a2a4e;
}

html.light .content {
    border-top-color: #c9d4ce;
}

.last-updated {
    margin-bottom: 0.7rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.content h2 {
    margin: 1.5rem 0 0.65rem;
    color: var(--accent);
    font-size: 1.28rem;
}

.content p,
.content ul,
.content dl {
    color: var(--muted);
}

.content p {
    margin-bottom: 0.75rem;
}

.content ul {
    margin: 0.5rem 0 1rem 1.45rem;
}

.content li {
    margin-bottom: 0.45rem;
}

.faq dt {
    margin-top: 0.9rem;
    color: var(--page-text);
    font-weight: 700;
}

.faq dd {
    margin: 0.2rem 0 0;
}

.related-games {
    margin-top: 1.6rem;
}

.related-games h3 {
    margin-bottom: 0.7rem;
    color: var(--accent);
    font-size: 1.05rem;
}

.game-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-links a {
    display: inline-block;
    padding: 0.42rem 0.8rem;
    border: 1px solid #34344d;
    border-radius: 6px;
    background: #1a1a2e;
    color: #70dfbd;
    font-size: 0.9rem;
    text-decoration: none;
}

html.light .game-links a {
    border-color: #b8c8c0;
    background: #fff;
    color: #087b5a;
}

.game-links a:hover,
.game-links a:focus-visible {
    border-color: var(--accent);
    text-decoration: none;
}

@media (max-width: 620px) {
    main {
        padding: 0.55rem;
    }

    .game-header {
        padding: 0 2.8rem 0 0;
        text-align: left;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .game-toolbar {
        align-items: flex-start;
        padding-right: 2.55rem;
    }

    .stats,
    .game-actions {
        gap: 0.3rem;
    }

    .stats > span {
        min-width: 2.8rem;
    }

    .game-actions button {
        min-height: 2.1rem;
        padding: 0.35rem 0.5rem;
        font-size: 0.78rem;
    }

    .game-status {
        font-size: 0.74rem;
    }

    .top-zones {
        gap: 0.45rem;
    }

    .card-suit-large {
        display: none;
    }

    .tableau-column .card + .card {
        margin-top: -102%;
    }
}

@media (max-width: 390px) {
    .game-container {
        padding: 0.38rem;
        border-radius: 9px;
    }

    .game-toolbar {
        flex-wrap: wrap;
        padding-right: 2.35rem;
    }

    .game-status {
        margin-top: 0.15rem;
    }

    .card-slot,
    .tableau-column::before,
    .card {
        border-radius: 3px;
    }

    .card-corner {
        top: 2px;
        left: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
