
:root {
    --felt: #0b5b48;
    --felt-dark: #073c32;
    --felt-light: #11745c;
    --panel: rgba(4, 29, 24, 0.72);
    --panel-border: rgba(255, 255, 255, 0.12);
    --text: #f7f3e8;
    --muted: #b8cfc6;
    --gold: #e8c56b;
    --card-width: clamp(88px, 7vw, 116px);
    --card-height: calc(var(--card-width) * 1.42);
    --card-radius: 10px;
    --face-step: clamp(30px, 3.25vh, 42px);
    --back-step: clamp(15px, 1.85vh, 22px);
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    color: var(--text);
    background:
        radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.06), transparent 25%),
        radial-gradient(circle at 80% 90%, rgba(255, 255, 255, 0.035), transparent 28%),
        linear-gradient(145deg, var(--felt-light), var(--felt) 42%, var(--felt-dark));
}

button {
    font: inherit;
}

.app-shell {
    height: 100vh;
    width: 100vw;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.topbar {
    min-height: 86px;
    display: grid;
    grid-template-columns: minmax(250px, 1fr) auto minmax(300px, 1fr);
    align-items: center;
    gap: 24px;
    padding: 14px 28px;
    background: linear-gradient(180deg, rgba(3, 25, 21, 0.92), rgba(3, 25, 21, 0.72));
    border-bottom: 1px solid var(--panel-border);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
    position: relative;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #f6dc8c, #c8942f);
    color: #17211d;
    font-size: 30px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), var(--shadow);
}

.brand h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
    letter-spacing: 0.03em;
    margin: 0;
}

.brand p {
    color: var(--muted);
    margin: 3px 0 0;
    font-size: 13px;
}

.statusbar {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: var(--panel);
    overflow: hidden;
}

.status-item {
    min-width: 92px;
    padding: 9px 18px;
    display: grid;
    gap: 2px;
    text-align: center;
    border-right: 1px solid var(--panel-border);
}

.status-item:last-child {
    border-right: 0;
}

.status-item span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.status-item strong {
    font-size: 20px;
    font-variant-numeric: tabular-nums;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.button {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
    font-weight: 700;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button.primary {
    color: #17211d;
    background: linear-gradient(145deg, #f8df94, #d6a744);
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
}

.button.secondary {
    color: var(--text);
    border-color: var(--panel-border);
    background: rgba(255, 255, 255, 0.06);
}

.button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.button.large {
    padding: 13px 28px;
    font-size: 16px;
}

.game-board {
    min-height: 0;
    padding: 18px 30px 12px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 18px;
}

.top-row {
    display: grid;
    grid-template-columns: auto minmax(190px, 1fr) auto;
    align-items: start;
    gap: 28px;
}

.pile-group,
.foundations {
    display: flex;
    gap: clamp(16px, 2vw, 28px);
}

.pile-wrap {
    display: grid;
    justify-items: center;
    gap: 6px;
}

.pile-label {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pile-label.red,
.red {
    color: #e54848;
}

.pile-label.black {
    color: #f4f4ef;
}

.pile,
.tableau-column {
    width: var(--card-width);
    min-width: var(--card-width);
    position: relative;
    border-radius: var(--card-radius);
}

.pile {
    height: var(--card-height);
    border: 2px dashed rgba(255, 255, 255, 0.19);
    background: rgba(0, 0, 0, 0.085);
}

.pile::after {
    content: attr(data-empty-symbol);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.16);
    font-size: calc(var(--card-width) * 0.44);
    pointer-events: none;
}

.foundation[data-suit="hearts"]::after { content: "♥"; }
.foundation[data-suit="clubs"]::after { content: "♣"; }
.foundation[data-suit="diamonds"]::after { content: "♦"; }
.foundation[data-suit="spades"]::after { content: "♠"; }

.message-area {
    align-self: center;
    justify-self: center;
    width: min(100%, 560px);
    text-align: center;
    color: #d9e8e1;
    font-size: 14px;
    min-height: 44px;
    display: grid;
    place-items: center;
}

.message-area > div {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(2, 35, 28, 0.45);
}

.tableau {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(7, var(--card-width));
    justify-content: space-between;
    gap: clamp(10px, 1.4vw, 26px);
    overflow: visible;
    padding: 0 2px;
}

.tableau-column {
    height: 100%;
    min-height: var(--card-height);
    border: 2px dashed rgba(255, 255, 255, 0.13);
    background: rgba(0, 0, 0, 0.045);
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    position: absolute;
    left: -2px;
    border-radius: var(--card-radius);
    user-select: none;
    cursor: pointer;
    transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.card.face-up {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(239, 235, 222, 0.98)),
        #f8f5ec;
    color: #151b19;
    border: 1px solid rgba(20, 20, 20, 0.22);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}

.card.face-down {
    border: 4px solid #f4efe4;
    background:
        linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%),
        linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%),
        linear-gradient(145deg, #193d6a, #0e274a);
    background-position: 0 0, 8px 8px, 0 0;
    background-size: 16px 16px, 16px 16px, auto;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.26);
}

.card.face-down::after {
    content: "♠";
    position: absolute;
    inset: 8px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.38);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: calc(var(--card-width) * 0.42);
}

.card.red {
    color: #c92727;
}

.card:hover {
    filter: brightness(1.03);
}

.card.selected {
    transform: translateY(-6px);
    box-shadow: 0 0 0 4px rgba(247, 213, 116, 0.9), 0 14px 24px rgba(0, 0, 0, 0.3);
    z-index: 200 !important;
}

.card.hint {
    animation: hintPulse 900ms ease-in-out 2;
}

.card-corner {
    position: absolute;
    top: 7px;
    left: 8px;
    display: grid;
    justify-items: center;
    line-height: 0.9;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

.card-corner.bottom {
    top: auto;
    left: auto;
    right: 8px;
    bottom: 7px;
    transform: rotate(180deg);
}

.card-rank {
    font-size: clamp(18px, 1.55vw, 24px);
}

.card-suit-small {
    font-size: clamp(16px, 1.35vw, 22px);
}

.card-suit-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: calc(var(--card-width) * 0.54);
    line-height: 1;
    opacity: 0.96;
}

.stock.has-cards {
    cursor: pointer;
    border-style: solid;
    border-color: transparent;
}

.stock.has-cards::before {
    content: "";
    position: absolute;
    inset: -5px 5px 5px -5px;
    border-radius: var(--card-radius);
    border: 2px solid rgba(245, 239, 228, 0.55);
    background: rgba(13, 40, 72, 0.55);
    z-index: 0;
}

.stock .card {
    top: -2px;
    z-index: 2;
}

.waste .card,
.foundation .card {
    top: -2px;
}

.drop-target {
    box-shadow: 0 0 0 4px rgba(247, 213, 116, 0.72);
}

.footerbar {
    min-height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 9px 28px;
    color: var(--muted);
    font-size: 12px;
    background: rgba(2, 24, 20, 0.78);
    border-top: 1px solid var(--panel-border);
}

#saveStatus {
    white-space: nowrap;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    background: rgba(0, 20, 16, 0.72);
    backdrop-filter: blur(7px);
}

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

.modal-card {
    width: min(430px, calc(100vw - 40px));
    text-align: center;
    padding: 34px;
    border-radius: 22px;
    background: linear-gradient(155deg, #fffdf5, #e8e0ca);
    color: #18221f;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

.modal-suit-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 34px;
}

.modal-card h2 {
    margin: 12px 0 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 38px;
}

.modal-card p {
    margin: 0 0 24px;
    color: #52605b;
}

@keyframes hintPulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-9px); box-shadow: 0 0 0 5px rgba(247, 213, 116, 0.82), 0 16px 30px rgba(0, 0, 0, 0.35); }
}

@media (max-width: 1180px) {
    :root {
        --card-width: clamp(78px, 7vw, 94px);
    }

    .topbar {
        grid-template-columns: 1fr auto;
    }

    .statusbar {
        justify-self: end;
    }

    .actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

/* v1.2: automatische Fundament-Animation und Kartenfeuerwerk */
.app-shell.auto-moving .card,
.app-shell.auto-moving .pile,
.app-shell.auto-moving .tableau-column {
    pointer-events: none;
}

.foundation-flight {
    position: fixed !important;
    z-index: 900 !important;
    margin: 0 !important;
    pointer-events: none !important;
    visibility: visible !important;
    transition: transform 430ms cubic-bezier(.22,.78,.2,1), filter 430ms ease;
    filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .34));
    will-change: transform;
}

.celebration-layer {
    position: fixed;
    inset: 0;
    z-index: 620;
    overflow: hidden;
    pointer-events: none;
    display: none;
}

.celebration-layer.active {
    display: block;
}

.firework-card {
    position: absolute;
    width: 44px;
    height: 62px;
    display: grid;
    grid-template-rows: auto 1fr;
    align-items: start;
    justify-items: start;
    padding: 4px 5px;
    border-radius: 5px;
    border: 1px solid rgba(20, 20, 20, .34);
    background: linear-gradient(145deg, #fffef8, #ece5d2);
    color: #151b19;
    box-shadow: 0 7px 14px rgba(0, 0, 0, .28);
    font-family: Georgia, "Times New Roman", serif;
    line-height: .9;
    transform-origin: center;
    will-change: transform, opacity;
}

.firework-card.red {
    color: #c92727;
}

.firework-card strong {
    font-size: 16px;
}

.firework-card span {
    align-self: center;
    justify-self: center;
    font-size: 25px;
}
