/* === CSS Variables === */
:root {
    --bg-dark: #0d1117;
    --bg-felt: #1a472a;
    --bg-felt-dark: #0f2818;
    --gold: #d4af37;
    --gold-light: #f4cf57;
    --gold-dark: #a48820;
    --text-light: #e6e6e6;
    --text-muted: #8b949e;
    --danger: #c53030;
    --danger-light: #e53e3e;
    --success: #38a169;
    --card-white: #fefefe;
    --shadow: rgba(0, 0, 0, 0.4);
    
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.5;
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
}

/* === Screen System === */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* === Buttons === */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #1a1a1a;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-gold:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-action {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-light);
}

.btn-raise {
    background: var(--success);
    color: white;
    border: none;
}

.btn-raise:hover:not(:disabled) {
    background: #48bb78;
}

/* Raise Controls */
.raise-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.raise-amount-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.raise-input {
    width: 80px;
    padding: 0.5rem;
    font-size: 1.1rem;
    font-family: var(--font-body);
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--gold);
    -moz-appearance: textfield;
}

.raise-input::-webkit-outer-spin-button,
.raise-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.raise-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.3);
}

.btn-adjust {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-adjust:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.raise-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-tiny {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-preset {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-preset:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--gold);
}

.btn-allin {
    background: linear-gradient(135deg, var(--danger) 0%, #9b2c2c 100%);
    border-color: var(--danger);
    color: white;
}

.btn-allin:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--danger-light) 0%, var(--danger) 100%);
}

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

/* === Splash Screen === */
#splash-screen {
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a2332 50%, var(--bg-dark) 100%);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.splash-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.logo-container {
    margin-bottom: 3rem;
}

.logo {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(212, 175, 55, 0.3);
    letter-spacing: 0.1em;
}

.tagline {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-top: 0.5rem;
}

.splash-cards {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    z-index: -1;
    opacity: 0.15;
}

.floating-card {
    position: absolute;
    font-size: 5rem;
    animation: float 4s ease-in-out infinite;
}

.card-1 { top: 0; left: 50%; color: #1a1a1a; animation-delay: 0s; }
.card-2 { top: 50%; right: 0; color: #c53030; animation-delay: 1s; }
.card-3 { bottom: 0; left: 50%; color: #c53030; animation-delay: 2s; }
.card-4 { top: 50%; left: 0; color: #1a1a1a; animation-delay: 3s; }

/* === Form Screens === */
#login-screen,
#register-screen {
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a2332 100%);
    justify-content: center;
    align-items: center;
}

.form-container {
    background: rgba(255, 255, 255, 0.05);
    padding: 3rem;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.form-container h2 {
    font-family: var(--font-display);
    text-align: center;
    margin-bottom: 2rem;
    color: var(--gold);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    font-family: var(--font-body);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-light);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-container .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.form-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.form-switch a {
    color: var(--gold);
    text-decoration: none;
}

.form-switch a:hover {
    text-decoration: underline;
}

.error-msg {
    color: var(--danger-light);
    text-align: center;
    margin-top: 1rem;
    min-height: 1.5em;
}

/* === Game Screen === */
#game-screen {
    flex-direction: column;
    background: 
        radial-gradient(ellipse at center, var(--bg-felt) 0%, var(--bg-felt-dark) 70%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.03) 2px,
            rgba(0,0,0,0.03) 4px
        );
}

/* === Game Header === */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.game-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--gold);
    letter-spacing: 0.1em;
}

.player-name {
    font-weight: 600;
    color: var(--gold-light);
}

.token-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.token-icon {
    font-size: 1.2rem;
}

/* === Game Table === */
.game-table {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    position: relative;
    min-height: 0;
    overflow-y: auto;
}

/* === Player Areas === */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ai-area {
    padding-top: 1rem;
}

.player-area-self {
    padding-bottom: 1rem;
}

.player-label {
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.player-info {
    margin-bottom: 0.5rem;
}

.ai-tokens {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.bet-display {
    font-size: 0.85rem;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

/* === Cards Container === */
.cards-container {
    display: flex;
    gap: 0.75rem;
    perspective: 1000px;
}

/* === Pot Area === */
.pot-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.pot-label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    color: var(--text-muted);
}

.pot-amount {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.game-message {
    margin-top: 1rem;
    font-size: 1.1rem;
    text-align: center;
    color: var(--text-light);
    min-height: 1.5em;
    max-width: 400px;
}

/* === Controls === */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-top: 1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* === Result Overlay === */
.overlay {
    position: absolute;
    top: 80px;
    left: 20px;
    width: auto;
    height: auto;
    background: transparent;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.result-content {
    text-align: center;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, rgba(26, 71, 42, 0.98), rgba(15, 40, 24, 0.98));
    border-radius: 12px;
    border: 2px solid var(--gold);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 40px rgba(212, 175, 55, 0.2);
}

.result-content h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.result-content p {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* === Rules Screen === */
#rules-screen {
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a2332 100%);
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.rules-container {
    background: rgba(255, 255, 255, 0.05);
    padding: 2.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.back-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
}

.rules-container h2 {
    font-family: var(--font-display);
    color: var(--gold);
    text-align: center;
    margin-bottom: 2rem;
}

.rules-section {
    margin-bottom: 1.5rem;
}

.rules-section h3 {
    font-size: 1.1rem;
    color: var(--gold-light);
    margin-bottom: 0.75rem;
}

.rules-section ol,
.rules-section ul {
    padding-left: 1.5rem;
    color: var(--text-muted);
}

.rules-section li {
    margin-bottom: 0.5rem;
}

.hand-ranks {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid var(--gold);
}

.rank-name {
    font-weight: 600;
    color: var(--text-light);
}

.rank-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Lobby Screen === */
#lobby-screen {
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a2332 50%, var(--bg-dark) 100%);
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.lobby-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.lobby-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    gap: 2rem;
    overflow-y: auto;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Lobby Actions */
.lobby-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 2.5rem;
    min-width: 200px;
    gap: 0.3rem;
}

.btn-icon {
    font-size: 2rem;
}

.btn-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-desc {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: none;
    letter-spacing: normal;
}

/* Games List */
.lobby-games,
.lobby-my-games {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-games h2,
.lobby-my-games h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 80px;
}

.games-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.game-item:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--gold);
}

.game-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.game-item-creator {
    font-weight: 600;
    color: var(--text-light);
}

.game-item-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.game-item-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
}

.game-item-status.waiting {
    color: var(--gold);
    background: rgba(212, 175, 55, 0.15);
}

.game-item-status.playing {
    color: var(--success);
    background: rgba(56, 161, 105, 0.15);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: linear-gradient(135deg, rgba(26, 35, 50, 0.98), rgba(13, 17, 23, 0.98));
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--gold);
    min-width: 320px;
    text-align: center;
}

.modal-content h3 {
    font-family: var(--font-display);
    color: var(--gold);
    margin-bottom: 1.5rem;
}

.modal-content .form-group {
    text-align: left;
}

.modal-content label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-family: var(--font-body);
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-light);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--gold);
}

.modal-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 1rem 0;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Waiting Spinner */
.waiting-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(212, 175, 55, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1.5rem auto;
}

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

/* Turn Indicator */
.turn-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    border: 2px solid var(--gold);
    font-weight: 600;
    color: var(--gold);
    animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(212, 175, 55, 0); }
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 2.5rem;
    }

    #game-screen {
        overflow-y: auto;
    }

    .game-header,
    .lobby-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .header-center {
        order: -1;
        width: 100%;
        text-align: center;
    }

    .game-table {
        padding: 1rem 0.5rem;
        min-height: auto;
        overflow-y: visible;
        justify-content: flex-start;
        gap: 1.5rem;
    }

    .pot-amount {
        font-size: 2rem;
    }

    .pot-area {
        flex: 0 0 auto;
        min-height: 150px;
    }

    .controls {
        flex-wrap: wrap;
        padding: 1rem 0.5rem;
        gap: 0.75rem;
        margin-bottom: 1rem;
        position: sticky;
        bottom: 0;
        background: rgba(0, 0, 0, 0.95);
        border-radius: 12px 12px 0 0;
    }

    .controls .btn {
        min-width: 100px;
        flex: 1 1 auto;
    }

    .raise-controls {
        width: 100%;
        order: 10;
    }

    .raise-presets {
        gap: 0.3rem;
    }

    .btn-tiny {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .raise-input {
        width: 70px;
        font-size: 1rem;
    }

    .lobby-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn-large {
        width: 100%;
        max-width: 280px;
    }

    .game-message {
        font-size: 0.95rem;
        padding: 0 1rem;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    html, body {
        font-size: 15px;
    }

    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .game-title {
        font-size: 1.2rem;
    }

    .game-header,
    .lobby-header {
        padding: 0.5rem;
    }

    .header-right,
    .header-left {
        gap: 0.5rem;
    }

    .btn-small {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .game-table {
        padding: 0.5rem;
    }

    .pot-amount {
        font-size: 1.5rem;
    }

    .pot-label {
        font-size: 0.75rem;
    }

    .controls {
        padding: 0.75rem 0.25rem;
        gap: 0.5rem;
    }

    .controls .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        min-width: 80px;
    }

    .raise-amount-row {
        gap: 0.3rem;
    }

    .btn-adjust {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .raise-input {
        width: 60px;
        padding: 0.4rem;
        font-size: 0.95rem;
    }

    .btn-tiny {
        padding: 0.35rem 0.4rem;
        font-size: 0.65rem;
    }

    .game-message {
        font-size: 0.85rem;
        margin-top: 0.5rem;
    }

    .bet-display {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
    }

    .modal-content {
        padding: 1.5rem;
        min-width: 280px;
    }

    .form-container {
        padding: 2rem 1.5rem;
    }

    .lobby-content {
        padding: 1rem;
    }

    .result-content {
        padding: 1rem 1.5rem;
    }

    .result-content h2 {
        font-size: 1.5rem;
    }
}

