/* Freedom Stack Card Game — Dark Theme */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Playfair+Display:wght@700&display=swap');

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-hover: #222222;
    --gold: #C9A84C;
    --gold-dim: #8a7433;
    --green: #2ecc71;
    --green-dark: #1a7a42;
    --blue: #3498db;
    --blue-dark: #1a5276;
    --red: #e74c3c;
    --red-dark: #7a1a1a;
    --yellow: #f1c40f;
    --yellow-dark: #7a6200;
    --purple: #9b59b6;
    --text-primary: #e0e0e0;
    --text-secondary: #888888;
    --text-muted: #555555;
    --border: #333333;
    --border-light: #444444;
    --shadow: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(201, 168, 76, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(201, 168, 76, 0.03) 0%, transparent 50%);
}

h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    color: var(--gold);
}

/* ============ START SCREEN ============ */
#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

#start-screen h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

#start-screen .tagline {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 2rem;
    font-style: italic;
}

.start-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.start-form label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.start-form input, .start-form select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: 'DM Sans', sans-serif;
}

.start-form input:focus, .start-form select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.2);
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
}

.btn-gold {
    background: var(--gold);
    color: #000;
}

.btn-gold:hover {
    background: #dbb955;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 168, 76, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--gold-dim);
}

.btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--red-dark);
    color: #fff;
}

.btn-danger:hover {
    background: var(--red);
}

/* ============ GAME BOARD ============ */
#game-screen {
    display: none;
    height: 100vh;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.game-info {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
}

.game-info span {
    color: var(--text-secondary);
}

.game-info .value {
    color: var(--gold);
    font-weight: 700;
}

.phase-indicator {
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.phase-draw { background: var(--blue-dark); color: var(--blue); }
.phase-play { background: var(--green-dark); color: var(--green); }
.phase-income { background: rgba(201, 168, 76, 0.2); color: var(--gold); }
.phase-expense { background: var(--red-dark); color: var(--red); }
.phase-game_over { background: var(--gold); color: #000; }

/* Board sections */
.board-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}

/* Opponent area */
.opponent-area {
    flex: 0 0 auto;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.player-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.player-name.is-turn {
    color: var(--gold);
}

.player-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    font-weight: 700;
}

.stat-income { color: var(--green); }
.stat-expense { color: var(--red); }
.stat-cash { color: var(--gold); }

.cards-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0;
    min-height: 80px;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Middle area */
.middle-area {
    flex: 1;
    display: flex;
    gap: 0.5rem;
    min-height: 0;
    overflow: hidden;
}

.deck-discard {
    flex: 0 0 120px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.deck-pile, .discard-pile {
    width: 80px;
    height: 110px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border: 2px solid var(--border);
    position: relative;
}

.deck-pile {
    background: linear-gradient(135deg, var(--bg-card), #252525);
    border-color: var(--gold-dim);
}

.discard-pile {
    background: var(--bg-card);
    border-style: dashed;
}

.pile-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

.pile-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.turn-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.4;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.turn-log .log-entry {
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
    color: var(--text-secondary);
}

.turn-log .log-entry:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* Your area */
.your-area {
    flex: 0 0 auto;
}

/* Hand area */
.hand-area {
    flex: 0 0 auto;
    padding-bottom: 0.5rem;
}

.hand-cards {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    justify-content: center;
    flex-wrap: wrap;
}

.hand-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}

/* ============ CARDS ============ */
.card {
    flex: 0 0 auto;
    width: 120px;
    min-height: 80px;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
    font-size: 0.75rem;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 10;
}

.card.selected {
    border-color: var(--gold) !important;
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
    transform: translateY(-8px);
}

/* Card types */
.card-asset {
    background: linear-gradient(135deg, #1a3d1a, #0d260d);
    border-color: var(--green-dark);
}

.card-skill {
    background: linear-gradient(135deg, #1a2d4d, #0d1a33);
    border-color: var(--blue-dark);
}

.card-attack {
    background: linear-gradient(135deg, #4d1a1a, #330d0d);
    border-color: var(--red-dark);
}

.card-defense {
    background: linear-gradient(135deg, #4d3d00, #332800);
    border-color: var(--yellow-dark);
}

.card-wild {
    background: linear-gradient(135deg, #3d2b00, #261a00);
    border-color: var(--gold-dim);
}

/* Card rarity glow */
.card-legendary {
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.3);
}

.card-mythic {
    box-shadow: 0 0 12px rgba(155, 89, 182, 0.4);
    animation: mythic-pulse 3s infinite;
}

@keyframes mythic-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(155, 89, 182, 0.4); }
    50% { box-shadow: 0 0 20px rgba(155, 89, 182, 0.6); }
}

.card-name {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-type-badge {
    display: inline-block;
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.badge-asset { background: var(--green-dark); color: var(--green); }
.badge-skill { background: var(--blue-dark); color: var(--blue); }
.badge-attack { background: var(--red-dark); color: var(--red); }
.badge-defense { background: var(--yellow-dark); color: var(--yellow); }
.badge-wild { background: rgba(201, 168, 76, 0.2); color: var(--gold); }

.card-income {
    color: var(--green);
    font-weight: 700;
    font-size: 0.85rem;
}

.card-effect {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.2;
    margin-top: 0.25rem;
    max-height: 2.5em;
    overflow: hidden;
}

.card-rarity {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.55rem;
    text-transform: uppercase;
    font-weight: 700;
}

.rarity-common { color: var(--text-muted); }
.rarity-uncommon { color: var(--green); }
.rarity-rare { color: var(--blue); }
.rarity-legendary { color: var(--gold); }
.rarity-mythic { color: var(--purple); }

/* Face-down cards (opponent hand) */
.card-hidden {
    background: linear-gradient(135deg, #1a1a1a, #252525);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--gold-dim);
    width: 50px;
    min-height: 70px;
}

/* Board cards (smaller) */
.board-card {
    width: 100px;
    min-height: 60px;
    font-size: 0.7rem;
}

.board-card .card-name {
    font-size: 0.7rem;
}

.board-card .card-effect {
    display: none;
}

/* Job card */
.job-card {
    background: linear-gradient(135deg, #2a2a0a, #1a1a00);
    border: 2px solid var(--gold-dim);
    border-radius: 8px;
    padding: 0.5rem;
    min-height: 60px;
    width: 100px;
    flex: 0 0 auto;
}

.job-card .card-name {
    font-size: 0.7rem;
    color: var(--gold);
}

.job-card .card-income {
    font-size: 0.85rem;
}

/* ============ CARD DETAIL TOOLTIP ============ */
.card-tooltip {
    display: none;
    position: fixed;
    z-index: 1000;
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 1rem;
    width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.card-tooltip.visible {
    display: block;
}

.card-tooltip .tooltip-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.card-tooltip .tooltip-type {
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.card-tooltip .tooltip-effect {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.card-tooltip .tooltip-flavor {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

/* ============ MODAL ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 2px solid var(--gold);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.modal h2 {
    margin-bottom: 1rem;
}

.modal p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.modal .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem 0;
    text-align: left;
}

.modal .stats-grid .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 6px;
}

/* ============ FLOATING INCOME ============ */
.float-income {
    position: fixed;
    pointer-events: none;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--green);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: float-up 1.5s ease-out forwards;
    z-index: 5000;
}

@keyframes float-up {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-60px); }
}

.attack-flash {
    animation: flash-red 0.3s ease-out;
}

@keyframes flash-red {
    0% { box-shadow: 0 0 0 transparent; }
    50% { box-shadow: 0 0 30px rgba(231, 76, 60, 0.6); }
    100% { box-shadow: 0 0 0 transparent; }
}

.defense-flash {
    animation: flash-yellow 0.5s ease-out;
}

@keyframes flash-yellow {
    0% { box-shadow: 0 0 0 transparent; }
    50% { box-shadow: 0 0 30px rgba(241, 196, 15, 0.6); }
    100% { box-shadow: 0 0 0 transparent; }
}

/* ============ WIN CONFETTI ============ */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .card { width: 100px; min-height: 70px; }
    .board-card { width: 85px; min-height: 55px; }
    .game-info { gap: 0.75rem; font-size: 0.8rem; }
    .player-stats { gap: 0.5rem; font-size: 0.8rem; }
    #start-screen h1 { font-size: 2rem; }
}
