:root {
    color-scheme: dark;
    --pisti-bg: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 60%), #050910;
    --pisti-surface: rgba(15, 23, 42, 0.78);
    --pisti-table: linear-gradient(135deg, rgba(15, 44, 84, 0.92), rgba(17, 52, 105, 0.78));
    --pisti-table-pattern: url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M80 20l18 18-18 18-18-18zm-40 0l18 18-18 18-18-18zm80 0l18 18-18 18-18-18zm-40 80l18 18-18 18-18-18zm-40 0l18 18-18 18-18-18zm80 0l18 18-18 18-18-18z' fill='rgba(148,196,255,0.18)'/%3E%3C/svg%3E");
    --pisti-card: rgba(241, 245, 249, 0.9);
    --pisti-card-border: rgba(71, 85, 105, 0.85);
    --pisti-text: #f8fafc;
    --pisti-muted: #94a3b8;
    --pisti-accent: #38bdf8;
    --pisti-danger: #fb7185;
    --pisti-success: #4ade80;
    --pisti-font: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--pisti-font);
    background: var(--pisti-bg);
    color: var(--pisti-text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 48px;
}

.pisti-shell {
    width: min(1100px, 100%);
    display: grid;
    gap: 24px;
}

.pisti-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.pisti-header h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.02em;
}

.pisti-header p {
    margin: 6px 0 0;
    color: var(--pisti-muted);
    max-width: 520px;
    line-height: 1.6;
}

.pisti-lang {
    display: inline-flex;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.pisti-lang button {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--pisti-muted);
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.pisti-lang button.is-active,
.pisti-lang button:hover {
    color: var(--pisti-text);
    background: rgba(148, 163, 184, 0.18);
}

.pisti-controls {
    background: var(--pisti-surface);
    border-radius: 20px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    padding: 18px 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
}

.pisti-buttons {
    display: flex;
    gap: 12px;
}

.pisti-button {
    appearance: none;
    border: none;
    border-radius: 16px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    background: var(--pisti-accent);
    color: #031422;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.pisti-button[disabled] {
    opacity: 0.45;
    pointer-events: none;
}

.pisti-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -16px rgba(56, 189, 248, 0.8);
}

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

.pisti-button--secondary {
    background: rgba(15, 23, 42, 0.65);
    color: var(--pisti-text);
    border: 1px solid rgba(59, 130, 246, 0.38);
}

.pisti-scoreboard {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.score-box {
    min-width: 110px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(8, 47, 73, 0.58);
    border: 1px solid rgba(56, 189, 248, 0.24);
}

.score-box--small {
    min-width: 80px;
}

.score-box__label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.86);
    margin-bottom: 6px;
}

.score-box__value {
    font-size: 22px;
    font-weight: 700;
    color: var(--pisti-text);
}

.pisti-table {
    position: relative;
    background: var(--pisti-table);
    border-radius: 28px;
    border: 1px solid rgba(37, 99, 235, 0.32);
    padding: 24px 28px;
    display: grid;
    gap: 16px;
    overflow: hidden;
}

.pisti-table::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--pisti-table-pattern);
    background-size: 160px 160px;
    opacity: 0.65;
    mix-blend-mode: screen;
    pointer-events: none;
}

.pisti-zone-title {
    margin: 0 0 8px;
    font-size: 18px;
    letter-spacing: 0.02em;
}

.pisti-hand {
    display: flex;
    justify-content: center;
    gap: 14px;
    min-height: 140px;
}

.pisti-hand--opponent {
    min-height: 90px;
}

.pisti-card {
    width: 90px;
    height: 130px;
    border-radius: 12px;
    background: var(--pisti-card);
    border: 2px solid var(--pisti-card-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #0f172a;
    box-shadow: 0 12px 32px -20px rgba(15, 15, 15, 0.45);
    transform-origin: bottom;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pisti-card.is-interactive {
    cursor: pointer;
}

.pisti-card.is-interactive:hover {
    transform: translateY(-8px);
    box-shadow: 0 18px 40px -22px rgba(15, 15, 15, 0.55);
}

.pisti-card.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pisti-card .card-rank {
    font-size: 24px;
}

.pisti-card .card-suit {
    font-size: 18px;
}

.pisti-card.red {
    color: #e11d48;
}

.pisti-card.back {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(14, 165, 233, 0.8));
    border: 2px solid rgba(125, 211, 252, 0.88);
    color: rgba(15, 23, 42, 0.8);
    font-size: 32px;
    letter-spacing: 0.1em;
}

.pisti-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 16px 0;
}

.pisti-deck {
    width: 96px;
    height: 140px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.82), rgba(59, 130, 246, 0.76));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 24px;
    color: rgba(15, 23, 42, 0.82);
    border: 2px solid rgba(125, 211, 252, 0.75);
    box-shadow: 0 18px 40px -26px rgba(14, 165, 233, 0.65);
    position: relative;
}

.pisti-deck::after {
    content: "";
    position: absolute;
    inset: 6px -12px -6px 12px;
    border-radius: 16px;
    border: 2px solid rgba(125, 211, 252, 0.25);
    pointer-events: none;
}

.pisti-table-stack {
    min-width: 220px;
    min-height: 140px;
    border-radius: 18px;
    border: 2px dashed rgba(125, 211, 252, 0.32);
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.pisti-table-stack .pisti-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.pisti-table-stack .pisti-card:nth-child(1) { transform: translate(-55%, -48%) rotate(-6deg); }
.pisti-table-stack .pisti-card:nth-child(2) { transform: translate(-50%, -50%) rotate(-2deg); }
.pisti-table-stack .pisti-card:nth-child(3) { transform: translate(-45%, -52%) rotate(4deg); }
.pisti-table-stack .pisti-card:nth-child(n+4) { transform: translate(-50%, -50%) rotate(0deg); }

.pisti-status {
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(15, 23, 42, 0.6);
    font-weight: 500;
    color: rgba(226, 232, 240, 0.92);
    min-height: 54px;
    display: flex;
    align-items: center;
}

.pisti-status.success {
    border-color: rgba(74, 222, 128, 0.28);
    background: rgba(22, 101, 52, 0.35);
    color: var(--pisti-success);
}

.pisti-status.error {
    border-color: rgba(248, 113, 113, 0.28);
    background: rgba(127, 29, 29, 0.32);
    color: var(--pisti-danger);
}

.pisti-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 14, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(16px);
}

.pisti-overlay.hidden {
    display: none;
}

.pisti-overlay__panel {
    width: min(420px, 90vw);
    background: rgba(15, 23, 42, 0.95);
    border-radius: 26px;
    border: 1px solid rgba(59, 130, 246, 0.4);
    padding: 26px 30px;
    text-align: center;
    box-shadow: 0 24px 54px -32px rgba(30, 65, 130, 0.65);
}

.pisti-overlay__panel h2 {
    margin: 0 0 12px;
    font-size: 26px;
}

.pisti-overlay__panel p {
    margin: 0 0 18px;
    color: var(--pisti-muted);
    line-height: 1.6;
}

.pisti-overlay__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 18px;
}

.pisti-overlay__stats div {
    padding: 12px;
    border-radius: 14px;
    background: rgba(8, 47, 73, 0.55);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.pisti-overlay__stats dt {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(148, 163, 184, 0.88);
}

.pisti-overlay__stats dd {
    margin: 6px 0 0;
    font-size: 22px;
    font-weight: 700;
}

.pisti-overlay__actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

@media (max-width: 820px) {
    body {
        padding: 24px 12px 32px;
    }
    .pisti-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .pisti-buttons {
        justify-content: center;
    }
    .pisti-hand {
        min-height: 120px;
        gap: 10px;
    }
    .pisti-card {
        width: 78px;
        height: 112px;
        font-size: 16px;
    }
    .pisti-deck {
        width: 82px;
        height: 120px;
        font-size: 20px;
    }
}
