/* =============================================
   WP Syvkabale – Klondike Solitaire
   Premium dark-mode card game styling
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ------ Design tokens ------ */
:root {
    --syv-bg: #0a1628;
    --syv-felt: #0d6b3a;
    --syv-felt-light: #11854a;
    --syv-felt-dark: #094d2b;
    --syv-felt-pattern: rgba(255,255,255,0.03);
    --syv-card-w: 90px;
    --syv-card-h: 130px;
    --syv-card-radius: 10px;
    --syv-card-shadow: 0 2px 8px rgba(0,0,0,0.35);
    --syv-card-hover: 0 4px 16px rgba(0,0,0,0.5);
    --syv-gold: #ffd700;
    --syv-red: #e63946;
    --syv-black: #1d1d1d;
    --syv-accent: #4cc9f0;
    --syv-success: #2dc653;
    --syv-glass: rgba(255,255,255,0.08);
    --syv-glass-border: rgba(255,255,255,0.12);
    --syv-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --syv-gap: 14px;
    --syv-stack-offset: 22px;
    --syv-facedown-offset: 8px;
}

/* ------ Wrapper ------ */
.syvkabale-wrapper {
    font-family: var(--syv-font);
    max-width: 780px;
    margin: 30px auto;
    padding: 24px 20px 30px;
    background:
        radial-gradient(ellipse at 30% 20%, var(--syv-felt-light) 0%, var(--syv-felt) 50%, var(--syv-felt-dark) 100%);
    border-radius: 20px;
    border: 3px solid rgba(0,0,0,0.3);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.05),
        0 20px 60px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.06);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Felt texture overlay */
.syvkabale-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            var(--syv-felt-pattern) 0px,
            var(--syv-felt-pattern) 1px,
            transparent 1px,
            transparent 4px
        );
    pointer-events: none;
    z-index: 0;
}

.syvkabale-wrapper > * {
    position: relative;
    z-index: 1;
}

/* ------ Loading spinner ------ */
.syvkabale-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: rgba(255,255,255,0.7);
    font-size: 15px;
    gap: 16px;
}

.syvkabale-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--syv-gold);
    border-radius: 50%;
    animation: syv-spin 0.8s linear infinite;
}

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

/* ------ Top bar ------ */
.syvkabale-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.syvkabale-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.syvkabale-title-icon {
    font-size: 24px;
}

/* Name input */
.syvkabale-name-box {
    display: flex;
    align-items: center;
}

.syvkabale-name-input {
    background: var(--syv-glass);
    border: 1px solid var(--syv-glass-border);
    border-radius: 8px;
    padding: 7px 12px;
    font-family: var(--syv-font);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    width: 130px;
    outline: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.syvkabale-name-input::placeholder {
    color: rgba(255,255,255,0.35);
}

.syvkabale-name-input:focus {
    border-color: var(--syv-accent);
    box-shadow: 0 0 0 2px rgba(76,201,240,0.2);
}

.syvkabale-stats {
    display: flex;
    gap: 16px;
    align-items: center;
}

.syvkabale-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--syv-glass);
    border: 1px solid var(--syv-glass-border);
    border-radius: 10px;
    padding: 6px 14px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.syvkabale-stat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.5);
}

.syvkabale-stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--syv-gold);
    font-variant-numeric: tabular-nums;
}

/* ------ Buttons ------ */
.syvkabale-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.syvkabale-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-family: var(--syv-font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.syvkabale-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}

.syvkabale-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102,126,234,0.45);
}

.syvkabale-btn-secondary {
    background: var(--syv-glass);
    border: 1px solid var(--syv-glass-border);
    backdrop-filter: blur(6px);
}

.syvkabale-btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

.syvkabale-btn-mode {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
}

.syvkabale-btn-mode.active {
    background: linear-gradient(135deg, var(--syv-gold), #f0a500);
    color: #1a1a2e;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(255,215,0,0.3);
}

.syvkabale-btn-mode:hover:not(.active) {
    background: rgba(255,255,255,0.18);
}

.syvkabale-btn-fs {
    font-size: 18px;
    padding: 4px 10px;
    line-height: 1;
    margin-left: 4px;
}

/* Fullscreen mode */
.syvkabale-wrapper:fullscreen,
.syvkabale-wrapper:-webkit-full-screen {
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

/* ------ Game board ------ */
.syvkabale-board {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.syvkabale-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.syvkabale-stock-area {
    display: flex;
    gap: var(--syv-gap);
    align-items: flex-start;
}

.syvkabale-foundations {
    display: flex;
    gap: var(--syv-gap);
}

/* ------ Tableau ------ */
.syvkabale-tableau {
    display: flex;
    justify-content: center;
    gap: var(--syv-gap);
}

.syvkabale-pile {
    position: relative;
    width: var(--syv-card-w);
    min-height: var(--syv-card-h);
}

/* ------ Card placeholder (empty slot) ------ */
.syvkabale-slot {
    width: var(--syv-card-w);
    height: var(--syv-card-h);
    border-radius: var(--syv-card-radius);
    border: 2px dashed rgba(255,255,255,0.18);
    background: rgba(0,0,0,0.12);
    position: relative;
    box-sizing: border-box;
}

.syvkabale-slot-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.15);
    font-size: 28px;
}

/* Stock pile refresh icon */
.syvkabale-stock-empty {
    cursor: pointer;
    transition: all 0.2s;
}

.syvkabale-stock-empty:hover {
    border-color: rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.06);
}

.syvkabale-stock-empty .syvkabale-slot-label {
    font-size: 32px;
    color: rgba(255,255,255,0.3);
}

/* ------ Cards ------ */
.syvkabale-card {
    width: var(--syv-card-w);
    height: var(--syv-card-h);
    border-radius: var(--syv-card-radius);
    position: absolute;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.syvkabale-card.face-up {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: var(--syv-card-shadow);
}

.syvkabale-card.face-down {
    background:
        linear-gradient(135deg, #1a237e 0%, #283593 50%, #1a237e 100%);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: var(--syv-card-shadow);
    cursor: default;
    overflow: hidden;
}

/* Card back pattern */
.syvkabale-card.face-down::before {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.15);
    background:
        repeating-linear-gradient(
            45deg,
            rgba(255,215,0,0.08) 0px,
            rgba(255,215,0,0.08) 2px,
            transparent 2px,
            transparent 6px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(255,215,0,0.06) 0px,
            rgba(255,215,0,0.06) 2px,
            transparent 2px,
            transparent 6px
        );
}

.syvkabale-card.face-down::after {
    content: '♠';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: rgba(255,215,0,0.2);
}

.syvkabale-card.face-up:hover {
    box-shadow: var(--syv-card-hover);
}

.syvkabale-card.selected {
    box-shadow: 0 0 0 3px var(--syv-accent), 0 4px 16px rgba(76,201,240,0.35);
    transform: translateY(-4px);
}

.syvkabale-card.dragging {
    z-index: 1000 !important;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    transform: rotate(2deg) scale(1.04);
    transition: none;
}

/* Card face content */
.syvkabale-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    box-sizing: border-box;
    position: relative;
}

.syvkabale-card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.syvkabale-card-corner-bottom {
    position: absolute;
    bottom: 6px;
    right: 8px;
    transform: rotate(180deg);
}

.syvkabale-card-rank {
    font-size: 18px;
    font-weight: 800;
    font-family: var(--syv-font);
}

.syvkabale-card-suit-small {
    font-size: 14px;
    line-height: 1;
    margin-top: -1px;
}

.syvkabale-card-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.syvkabale-card.red .syvkabale-card-rank,
.syvkabale-card.red .syvkabale-card-suit-small,
.syvkabale-card.red .syvkabale-card-center {
    color: var(--syv-red);
}

.syvkabale-card.black .syvkabale-card-rank,
.syvkabale-card.black .syvkabale-card-suit-small,
.syvkabale-card.black .syvkabale-card-center {
    color: var(--syv-black);
}

/* ------ Waste pile (3-card spread) ------ */
.syvkabale-waste {
    position: relative;
    width: var(--syv-card-w);
    height: var(--syv-card-h);
}

.syvkabale-waste .syvkabale-card {
    position: absolute;
    top: 0;
    left: 0;
}

.syvkabale-waste[data-spread="3"] .syvkabale-card:nth-last-child(3) {
    left: 0;
}

.syvkabale-waste[data-spread="3"] .syvkabale-card:nth-last-child(2) {
    left: 22px;
}

.syvkabale-waste[data-spread="3"] .syvkabale-card:nth-last-child(1) {
    left: 44px;
}

/* ------ Win overlay ------ */
.syvkabale-win-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    border-radius: 20px;
    animation: syv-fadeIn 0.5s ease;
}

@keyframes syv-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.syvkabale-win-title {
    font-size: 32px;
    font-weight: 800;
    text-align: center;
    max-width: 90%;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--syv-gold), #f0a500, var(--syv-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
    margin-bottom: 8px;
    animation: syv-pulse 1.5s ease infinite;
}

@keyframes syv-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.syvkabale-win-stats {
    color: rgba(255,255,255,0.8);
    font-size: 16px;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.8;
}

.syvkabale-win-emoji {
    font-size: 48px;
    margin-bottom: 16px;
    animation: syv-bounce 0.6s ease;
}

@keyframes syv-bounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ------ Auto-complete bar ------ */
.syvkabale-autocomplete-bar {
    margin-top: 16px;
    text-align: center;
    animation: syv-fadeIn 0.4s ease;
}

.syvkabale-btn-autocomplete {
    background: linear-gradient(135deg, var(--syv-success), #1fa842);
    box-shadow: 0 2px 12px rgba(45,198,83,0.35);
    font-size: 14px;
    padding: 10px 24px;
}

.syvkabale-btn-autocomplete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(45,198,83,0.5);
}

/* ------ Lobby / Start screen ------ */
.syvkabale-lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    gap: 16px;
    padding: 40px 20px;
    animation: syv-fadeIn 0.5s ease;
}

.syvkabale-lobby-icon {
    font-size: 64px;
    text-shadow: 0 4px 20px rgba(255,215,0,0.3);
    animation: syv-lobbyBounce 2s ease infinite;
}

@keyframes syv-lobbyBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(-3deg); }
    75% { transform: translateY(-4px) rotate(3deg); }
}

.syvkabale-lobby-title {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, rgba(255,255,255,0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.syvkabale-lobby-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}

.syvkabale-lobby-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 260px;
}

.syvkabale-lobby-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.6);
}

.syvkabale-lobby-input {
    background: var(--syv-glass);
    border: 1px solid var(--syv-glass-border);
    border-radius: 10px;
    padding: 12px 16px;
    font-family: var(--syv-font);
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    outline: none;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.syvkabale-lobby-input::placeholder { color: rgba(255,255,255,0.3); }
.syvkabale-lobby-input:focus {
    border-color: var(--syv-accent);
    box-shadow: 0 0 0 3px rgba(76,201,240,0.15);
}

.syvkabale-lobby-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.syvkabale-lobby-mode-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
}

.syvkabale-lobby-mode-btns {
    display: flex;
    gap: 10px;
}

.syvkabale-btn-start {
    margin-top: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 4px 16px rgba(102,126,234,0.35);
    font-size: 16px;
    padding: 12px 36px;
    border-radius: 12px;
    transition: all 0.2s;
}

.syvkabale-btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102,126,234,0.5);
}

.syvkabale-lobby-fs {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.syvkabale-lobby-fs:hover {
    opacity: 1;
}

/* ------ Card flip animation ------ */
.syvkabale-card.flipping {
    animation: syv-flip 0.3s ease;
}

@keyframes syv-flip {
    0% { transform: scaleX(1); }
    50% { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* ------ Responsive ------ */
@media (max-width: 700px) {
    :root {
        --syv-card-w: 56px;
        --syv-card-h: 82px;
        --syv-card-radius: 7px;
        --syv-gap: 6px;
        --syv-stack-offset: 16px;
        --syv-facedown-offset: 5px;
    }

    .syvkabale-wrapper {
        padding: 14px 8px 20px;
        border-radius: 14px;
        margin: 10px auto;
    }

    .syvkabale-title {
        font-size: 15px;
    }

    .syvkabale-title-icon {
        font-size: 18px;
    }

    .syvkabale-stat {
        padding: 4px 8px;
    }

    .syvkabale-stat-label {
        font-size: 8px;
    }

    .syvkabale-stat-value {
        font-size: 14px;
    }

    .syvkabale-btn {
        font-size: 11px;
        padding: 6px 10px;
    }

    .syvkabale-card-rank {
        font-size: 13px;
    }

    .syvkabale-card-suit-small {
        font-size: 10px;
    }

    .syvkabale-card-center {
        font-size: 22px;
    }

    .syvkabale-card-corner-bottom {
        bottom: 4px;
        right: 5px;
    }

    .syvkabale-card.face-down::after {
        font-size: 16px;
    }

    .syvkabale-win-title {
        font-size: 28px;
    }

    .syvkabale-win-emoji {
        font-size: 36px;
    }
}

@media (max-width: 450px) {
    :root {
        --syv-card-w: 44px;
        --syv-card-h: 66px;
        --syv-gap: 4px;
        --syv-stack-offset: 13px;
        --syv-facedown-offset: 4px;
    }

    .syvkabale-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .syvkabale-card-rank {
        font-size: 11px;
    }

    .syvkabale-card-suit-small {
        font-size: 8px;
    }

    .syvkabale-card-center {
        font-size: 16px;
    }

    .syvkabale-card-inner {
        padding: 3px 4px;
    }
}
