/* ═══════════════════════════════════════════════════════════
   Vampires & Peasants — Gothic Dark Theme
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-deep:       #0d0008;
    --bg-dark:       #1a0533;
    --bg-panel:      #1f0a3a;
    --bg-card:       #2a0f4a;
    --border:        #4a1a6a;
    --border-light:  #6a2a8a;
    --text-primary:  #e8d5f5;
    --text-muted:    #9a7ab5;
    --text-dim:      #5a3a7a;
    --accent-purple: #8b2fc9;
    --accent-gold:   #c9a84c;
    --accent-red:    #8b0000;
    --accent-crimson:#cc2244;
    --day-color:     #f5c842;
    --night-color:   #4455cc;
    --castle-red:    #cc2233;
    --castle-blue:   #2244aa;
    --castle-gray:   #667788;
    --castle-gold:   #cc9922;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 15px;
}

a { color: var(--accent-gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────────────── */

.page-wrapper {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

.app-container {
    min-height: 100vh;
    background: var(--bg-deep);
}

/* Widescreen game layout */
.game-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.75rem;
    min-height: calc(100vh - 2rem);
    padding: 0.75rem;
}

.player-panel {
    grid-column: 1;
    grid-row: 1 / -1;
}

.phase-bar, .deck-area, .played-cards-area {
    grid-column: 2;
}

.hand-area {
    grid-column: 2;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

@media (max-width: 767px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .player-panel {
        grid-column: 1;
        grid-row: auto;
        order: 5;
    }
    .phase-bar { order: 1; grid-column: 1; }
    .deck-area { order: 2; grid-column: 1; }
    .played-cards-area { order: 3; grid-column: 1; }
    .hand-area { order: 4; grid-column: 1; }
}

/* ─── Cards ─────────────────────────────────────────────── */

.card-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    margin: 0.25rem;
    user-select: none;
}

.card {
    width: 70px;
    height: 100px;
    border-radius: 8px;
    border: 2px solid var(--border-light);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 6px;
    background: #fdfbf0;
    color: #111;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: 'Georgia', serif;
}

.card:hover { transform: translateY(-4px); box-shadow: 0 6px 20px rgba(139,47,201,0.5); }

.card.selected {
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px var(--accent-gold);
    transform: translateY(-6px);
}

.card.played {
    border-color: var(--accent-crimson);
    box-shadow: 0 0 8px var(--accent-crimson);
}

.card-destroyed-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: bold;
    color: rgba(220, 30, 30, 0.85);
    text-shadow: 0 0 6px rgba(0,0,0,0.4);
    pointer-events: none;
    z-index: 5;
}

.card-wrapper {
    position: relative;
}

.card-value-top { font-size: 0.75rem; font-weight: bold; line-height: 1; }
.card-value-bot { font-size: 0.75rem; font-weight: bold; line-height: 1; transform: rotate(180deg); align-self: flex-end; }
.card-center { font-size: 1.6rem; text-align: center; flex: 1; display: flex; align-items: center; justify-content: center; }

.card-svg { width: 100%; height: 100%; }

.vamp-center, .peasant-center {
    flex: 1;
    padding: 0;
    overflow: hidden;
}

.vamp-value { font-size: 0.65rem; font-weight: bold; color: #550000; }

.card.red { color: #cc0000; }
.card.black { color: #111; }

/* Vampire Deck castle colors */
.card.castle-red { border-color: var(--castle-red); background: #fff0f0; }
.card.castle-blue { border-color: var(--castle-blue); background: #f0f0ff; }
.card.castle-gray { border-color: var(--castle-gray); background: #f4f4f4; }
.card.castle-gold { border-color: var(--castle-gold); background: #fffbe8; }

.card.castle-red .card-value-top,
.card.castle-red .card-value-bot { color: var(--castle-red); }
.card.castle-blue .card-value-top,
.card.castle-blue .card-value-bot { color: var(--castle-blue); }
.card.castle-gray .card-value-top,
.card.castle-gray .card-value-bot { color: var(--castle-gray); }
.card.castle-gold .card-value-top,
.card.castle-gold .card-value-bot { color: var(--castle-gold); }

/* Joker — split */
.card.joker {
    background: linear-gradient(135deg, #f5e6ff 50%, #ffe6e6 50%);
    border-color: var(--accent-purple);
}

/* Vampire card dark background */
.card.vampire-bg {
    background: #2a2a2e;
}

/* Face-down: gothic back */
.card.face-down {
    background: repeating-linear-gradient(
        45deg,
        #1a0533,
        #1a0533 4px,
        #2a0f4a 4px,
        #2a0f4a 8px
    );
    border-color: var(--accent-gold);
    cursor: default;
}

.card.face-down:hover { transform: none; box-shadow: none; }

/* Ace cards */
.card.ace-day { background: linear-gradient(135deg, #fff8cc, #ffee88); }
.card.ace-night { background: linear-gradient(135deg, #1a1a4a, #2a2a6a); color: #aaa; }

/* ─── Pile displays ────────────────────────────────────────── */

.pile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.pile-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pile-count {
    font-size: 0.65rem;
    color: var(--text-dim);
}

/* ─── Panels ─────────────────────────────────────────────── */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}

.panel-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-gold);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
}

/* ─── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.4rem 0.9rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--accent-purple); color: #fff; }
.btn-primary:hover { background: #a040e0; }
.btn-danger    { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: var(--accent-crimson); }
.btn-gold      { background: var(--accent-gold); color: #1a0533; font-weight: bold; }
.btn-gold:hover { background: #e0b84a; }
.btn-secondary { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm        { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-lg        { padding: 0.6rem 1.4rem; font-size: 1rem; }

/* ─── Forms ──────────────────────────────────────────────── */

.form-group { margin-bottom: 0.75rem; }
.form-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.form-control {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}
.form-control:focus { outline: 2px solid var(--accent-purple); }
select.form-control option { background: var(--bg-card); }
.error-msg { color: var(--accent-crimson); font-size: 0.8rem; margin-top: 0.25rem; }

/* ─── Player List ────────────────────────────────────────── */

.player-list { display: flex; flex-direction: column; gap: 0.3rem; }

.player-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-card);
    border-radius: 5px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
}

.player-item.eliminated { opacity: 0.45; text-decoration: line-through; }
.player-item.is-me { border-color: var(--accent-gold); }

.player-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fff;
    flex-shrink: 0;
}

.player-name { flex: 1; }
.player-score { font-size: 0.7rem; color: var(--accent-gold); }
.player-ready { font-size: 0.65rem; color: #4caf50; }

/* ─── Phase Bar ──────────────────────────────────────────── */

.phase-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
}

.phase-badge {
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.phase-badge.day   { background: var(--day-color); color: #3a2800; }
.phase-badge.night { background: var(--night-color); color: #fff; }

.phase-bar-village {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--accent-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 14rem;
}

.round-info { color: var(--text-muted); }

/* ─── Deck Area ──────────────────────────────────────────── */

.deck-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

/* Smaller cards in the deck area */
.deck-area .card,
.deck-area .deck-card {
    width: 50px;
    height: 72px;
}

.deck-area .card-wrapper {
    margin: 0.15rem;
    cursor: default;
}

.deck-area .card:hover {
    transform: none;
    box-shadow: none;
}

/* Aces stack — face-down cards with horizontal offset, face-up on top */
.aces-stack-cards {
    display: flex;
    align-items: center;
    min-height: 72px;
}

.aces-stack-cards > .ace-stack-fd {
    margin-right: -44px;
    flex-shrink: 0;
    cursor: default;
}

.aces-stack-cards > .ace-stack-revealed {
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.aces-stack-cards > .ace-stack-revealed .card-wrapper {
    margin: 0;
}

@media (max-width: 767px) {
    .deck-area {
        gap: 0.4rem;
    }

    .deck-area .card,
    .deck-area .deck-card {
        width: 42px;
        height: 60px;
    }

    .deck-area .card-wrapper {
        margin: 0.1rem;
    }

    .aces-stack-cards {
        min-height: 60px;
    }

    .aces-stack-cards > .ace-stack-fd {
        margin-right: -37px;
    }

    .pile-label { font-size: 0.6rem; }
    .pile-count { font-size: 0.55rem; }
}

/* Deck area card text scaling for smaller cards */
.deck-area .card-value-top,
.deck-area .card-value-bot { font-size: 0.6rem; }
.deck-area .card-center { font-size: 1.2rem; }

/* ─── Hand Area ──────────────────────────────────────────── */

.hand-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hand-label { font-size: 0.75rem; color: var(--text-muted); }

.hand-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* ─── Played Cards Area ──────────────────────────────────── */

.played-cards-area {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.played-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.player-played-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.player-played-name { font-size: 0.65rem; color: var(--text-muted); text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }

/* ─── Played Cards Panel (compact for mobile) ───────────── */

.played-cards-panel {
    max-height: 25vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.played-cards-panel .panel-title {
    font-size: 0.75em;
    padding: 0.2rem 0.4rem;
}

.played-cards-panel .played-card-row {
    gap: 0.3rem;
}

.played-cards-panel .player-played-item {
    transform: scale(0.75);
    transform-origin: top center;
}

.played-cards-panel .player-played-name {
    font-size: 0.5rem;
}

/* ─── Game Log ───────────────────────────────────────────── */

.game-log {
    height: 200px;
    overflow-y: auto;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.game-log-entry { padding: 0.1rem 0; border-bottom: 1px solid rgba(255,255,255,0.03); }

/* ─── Overlay / Modal ────────────────────────────────────── */

.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-box {
    background: var(--bg-panel);
    border: 2px solid var(--accent-purple);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 0 40px rgba(139,47,201,0.4);
    position: relative;
}

.overlay-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #000;
    border: 2px solid #550000;
    border-radius: 5px;
    color: #ff3333;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0.3rem 0.6rem;
    min-width: 2.1rem;
    text-align: center;
}
.overlay-close-btn:hover {
    background: #1a0000;
    border-color: #ff3333;
    color: #ff6666;
}

.overlay-title {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 0.75rem;
    text-align: center;
}

/* Fate match overlay */
.fate-match-overlay {
    text-align: center;
}

.fate-overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.fate-overlay-matches {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.fate-overlay-match-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fate-overlay-match-name {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent-gold);
}

/* Sacrifice results overlay */
.sacrifice-overlay {
    text-align: center;
    max-width: 560px;
}

.sacrifice-section {
    margin-bottom: 1rem;
}

.sacrifice-section:last-child {
    margin-bottom: 0;
}

.sacrifice-label {
    font-size: 0.95rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    display: inline-block;
}

.sacrifice-label.replaced-label {
    color: #1a1a1a;
    background: var(--accent-gold);
}

.sacrifice-label.destroyed-label {
    color: #fff;
    background: var(--accent-crimson);
}

.sacrifice-label.returned-label {
    color: var(--text-primary);
    background: var(--border);
}

.sacrifice-card-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.sacrifice-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sacrifice-player-name {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent-gold);
}

/* ─── Time of Day Indicator ──────────────────────────────── */

.tod-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1rem;
    font-weight: bold;
}

.tod-indicator.day { color: var(--day-color); }
.tod-indicator.night { color: var(--night-color); }

/* ─── Homepage ───────────────────────────────────────────── */

.home-hero {
    text-align: center;
    padding: 2rem 1rem;
}

.home-title {
    font-size: 2.2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(201,168,76,0.5);
    margin-bottom: 0.5rem;
}

.home-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ─── Lobby ──────────────────────────────────────────────── */

.lobby-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) { .lobby-grid { grid-template-columns: 1fr; } }

/* ─── GameOver ───────────────────────────────────────────── */

.gameover-panel {
    text-align: center;
    padding: 2rem;
}

.gameover-title {
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.leaderboard { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.leaderboard th, .leaderboard td { padding: 0.4rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.leaderboard th { color: var(--accent-gold); }
.leaderboard tr.winner td { color: var(--day-color); font-weight: bold; }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.admin-table th, .admin-table td { padding: 0.4rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.82rem; vertical-align: middle; }
.admin-table th { color: var(--accent-gold); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.admin-table tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ─── Claim Button ───────────────────────────────────────── */

.claim-btn { font-size: 0.7rem; padding: 0.2rem 0.4rem; margin-top: 0.2rem; }

/* ─── Sacrifice Selection ────────────────────────────────── */

.sacrifice-label { font-size: 0.7rem; color: var(--accent-crimson); text-align: center; }

/* ─── Stake ──────────────────────────────────────────────── */

.stake-choose-overlay {
    max-width: 560px;
    text-align: center;
}

.stake-target {
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.stake-target:hover { border-color: var(--accent-crimson); }
.stake-target-selected { border-color: var(--accent-crimson); background: rgba(139,0,0,0.15); }

.stake-played-indicator {
    width: 70px;
    height: 100px;
    border-radius: 8px;
    border: 2px solid var(--accent-crimson);
    background: rgba(139,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--accent-crimson);
    font-size: 0.75rem;
    font-weight: bold;
    gap: 0.2rem;
}

.justify-center { justify-content: center; }

/* ─── Scrollbar ──────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ─── Animations ─────────────────────────────────────────── */

@keyframes slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 6px var(--accent-purple); }
    50%       { box-shadow: 0 0 16px var(--accent-purple); }
}

.card-slide-in { animation: slide-up 0.25s ease; }

/* ─── Utility ────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }

.active-game-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 0.5rem;
}
.active-game-row:last-of-type { border-bottom: none; }
.active-game-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.active-game-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.text-gold   { color: var(--accent-gold); }
.text-danger { color: var(--accent-crimson); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
