/* =============================================
   WP Hjertefri – Hearts Card Game
   Premium dark-mode card game styling
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --hjf-bg: #0a1628;
    --hjf-felt: #1a3a2a;
    --hjf-felt-light: #1f4d35;
    --hjf-felt-dark: #0f2a1c;
    --hjf-card-w: 72px;
    --hjf-card-h: 104px;
    --hjf-card-radius: 8px;
    --hjf-card-shadow: 0 2px 6px rgba(0,0,0,0.3);
    --hjf-red: #e63946;
    --hjf-black: #1d1d1d;
    --hjf-gold: #ffd700;
    --hjf-accent: #4cc9f0;
    --hjf-heart-glow: rgba(230,57,70,0.25);
    --hjf-glass: rgba(255,255,255,0.08);
    --hjf-glass-border: rgba(255,255,255,0.12);
    --hjf-font: 'Inter', -apple-system, sans-serif;
}

.hjf-wrapper {
    font-family: var(--hjf-font);
    max-width: 860px;
    margin: 20px auto;
    padding: 20px;
    background: radial-gradient(ellipse at 30% 30%, var(--hjf-felt-light), var(--hjf-felt), var(--hjf-felt-dark));
    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);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    min-height: 500px;
}

/* Felt texture */
.hjf-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 4px);
    pointer-events: none;
    z-index: 0;
    border-radius: 20px;
}

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

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

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

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

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

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

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

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

.hjf-stats {
    display: flex;
    gap: 12px;
}

.hjf-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--hjf-glass);
    border: 1px solid var(--hjf-glass-border);
    border-radius: 8px;
    padding: 4px 12px;
    backdrop-filter: blur(6px);
}

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

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

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

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

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

/* Game board layout */
.hjf-board {
    display: grid;
    grid-template-areas:
        ".    north  ."
        "west center east"
        ".    south  .";
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    min-height: 380px;
    align-items: center;
}

/* Player areas */
.hjf-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hjf-player-north { grid-area: north; }
.hjf-player-south { grid-area: south; }
.hjf-player-west  { grid-area: west; }
.hjf-player-east  { grid-area: east; }

.hjf-player-label {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    background: var(--hjf-glass);
    border: 1px solid var(--hjf-glass-border);
    border-radius: 6px;
    padding: 3px 10px;
    backdrop-filter: blur(6px);
    white-space: nowrap;
}

.hjf-player-label.active {
    color: var(--hjf-gold);
    border-color: var(--hjf-gold);
    box-shadow: 0 0 8px rgba(255,215,0,0.2);
}

.hjf-player-score {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
}

/* Center trick area */
.hjf-center {
    grid-area: center;
    display: grid;
    grid-template-areas:
        ". n ."
        "w . e"
        ". s .";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    min-height: 200px;
    place-items: center;
}

.hjf-trick-card {
    transition: all 0.3s ease;
}

.hjf-trick-n { grid-area: n; }
.hjf-trick-s { grid-area: s; }
.hjf-trick-w { grid-area: w; }
.hjf-trick-e { grid-area: e; }

/* AI hand (face-down fan) */
.hjf-ai-hand {
    display: flex;
    justify-content: center;
}

.hjf-ai-hand .hjf-card {
    margin: 0 -18px;
    position: relative;
}

.hjf-player-west .hjf-ai-hand,
.hjf-player-east .hjf-ai-hand {
    flex-direction: column;
}

.hjf-player-west .hjf-ai-hand .hjf-card,
.hjf-player-east .hjf-ai-hand .hjf-card {
    margin: -28px 0;
}

/* Player hand (bottom, face-up) */
.hjf-hand {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    padding: 8px 0;
}

.hjf-hand .hjf-card {
    margin: 0 -10px;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    position: relative;
}

.hjf-hand .hjf-card:hover {
    transform: translateY(-12px);
    z-index: 100;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.hjf-hand .hjf-card.playable {
    cursor: pointer;
}

.hjf-hand .hjf-card.not-playable {
    cursor: not-allowed;
    opacity: 0.5;
    filter: brightness(0.7);
}

.hjf-hand .hjf-card.not-playable:hover {
    transform: none;
    box-shadow: var(--hjf-card-shadow);
}

.hjf-hand .hjf-card.selected-pass {
    transform: translateY(-16px);
    box-shadow: 0 0 0 3px var(--hjf-accent), 0 8px 20px rgba(0,0,0,0.4);
}

/* Cards */
.hjf-card {
    width: var(--hjf-card-w);
    height: var(--hjf-card-h);
    border-radius: var(--hjf-card-radius);
    box-shadow: var(--hjf-card-shadow);
    flex-shrink: 0;
}

.hjf-card.face-up {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
}

.hjf-card.face-down {
    background: linear-gradient(135deg, #1a237e, #283593, #1a237e);
    border: 1px solid rgba(255,255,255,0.12);
    overflow: hidden;
}

.hjf-card.face-down::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 5px;
    border: 2px solid rgba(255,255,255,0.12);
    background: repeating-linear-gradient(45deg, rgba(255,215,0,0.06) 0px, rgba(255,215,0,0.06) 2px, transparent 2px, transparent 5px),
                repeating-linear-gradient(-45deg, rgba(255,215,0,0.04) 0px, rgba(255,215,0,0.04) 2px, transparent 2px, transparent 5px);
}

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

.hjf-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    box-sizing: border-box;
    position: relative;
}

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

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

.hjf-card-rank {
    font-size: 15px;
    font-weight: 800;
    font-family: var(--hjf-font);
}

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

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

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

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

/* Pass phase */
.hjf-pass-info {
    text-align: center;
    margin: 12px 0;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 600;
}

.hjf-pass-btn {
    margin-top: 8px;
    background: linear-gradient(135deg, #2dc653, #1fa842);
    box-shadow: 0 2px 10px rgba(45,198,83,0.3);
}

.hjf-pass-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* Message / info */
.hjf-message {
    text-align: center;
    padding: 10px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 600;
    animation: hjf-fadeIn 0.3s ease;
}

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

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

.hjf-lobby-icon {
    font-size: 64px;
    color: var(--hjf-red);
    text-shadow: 0 4px 20px rgba(230,57,70,0.4);
    animation: hjf-heartbeat 1.5s ease infinite;
}

@keyframes hjf-heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
}

.hjf-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;
}

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

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

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

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

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

.hjf-lobby-opponents {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

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

.hjf-lobby-opp-names {
    display: flex;
    gap: 10px;
}

.hjf-lobby-opp {
    background: var(--hjf-glass);
    border: 1px solid var(--hjf-glass-border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    backdrop-filter: blur(6px);
}

.hjf-btn-start {
    margin-top: 16px;
    background: linear-gradient(135deg, var(--hjf-red), #c62828);
    box-shadow: 0 4px 16px rgba(230,57,70,0.35);
    font-size: 16px;
    padding: 12px 36px;
    border-radius: 12px;
    transition: all 0.2s;
}

.hjf-btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(230,57,70,0.5);
}

/* Fullscreen button */
.hjf-btn-mode {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
}

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

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

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

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

/* Fullscreen mode */
.hjf-wrapper:fullscreen,
.hjf-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;
}

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

.hjf-scoreboard-title {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--hjf-gold), #f0a500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.hjf-scoreboard {
    background: var(--hjf-glass);
    border: 1px solid var(--hjf-glass-border);
    border-radius: 12px;
    padding: 16px 24px;
    backdrop-filter: blur(6px);
    margin-bottom: 20px;
    min-width: 280px;
}

.hjf-scoreboard table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
    font-size: 14px;
}

.hjf-scoreboard th {
    text-align: left;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hjf-scoreboard td {
    padding: 6px 12px;
}

.hjf-scoreboard tr.winner td {
    color: var(--hjf-gold);
    font-weight: 700;
}

.hjf-scoreboard tr.loser td {
    color: var(--hjf-red);
}

/* Trick won animation */
.hjf-trick-won {
    animation: hjf-trickPulse 0.5s ease;
}

@keyframes hjf-trickPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 700px) {
    :root {
        --hjf-card-w: 52px;
        --hjf-card-h: 76px;
        --hjf-card-radius: 6px;
    }

    .hjf-wrapper {
        padding: 12px 8px;
        border-radius: 14px;
        margin: 10px;
    }

    .hjf-title { font-size: 14px; }

    .hjf-hand .hjf-card { margin: 0 -14px; }

    .hjf-ai-hand .hjf-card { margin: 0 -22px; }

    .hjf-player-west .hjf-ai-hand .hjf-card,
    .hjf-player-east .hjf-ai-hand .hjf-card {
        margin: -32px 0;
    }

    .hjf-card-rank { font-size: 12px; }
    .hjf-card-suit-small { font-size: 9px; }
    .hjf-card-center { font-size: 20px; }
    .hjf-card-inner { padding: 3px 4px; }
    .hjf-card-corner-bottom { bottom: 3px; right: 4px; }

    .hjf-board {
        grid-template-columns: auto 1fr auto;
        gap: 6px;
        min-height: 280px;
    }
}

@media (max-width: 450px) {
    :root {
        --hjf-card-w: 42px;
        --hjf-card-h: 62px;
    }

    .hjf-hand .hjf-card { margin: 0 -16px; }
    .hjf-card-rank { font-size: 10px; }
    .hjf-card-suit-small { font-size: 8px; }
    .hjf-card-center { font-size: 16px; }
}
