/* ========================================
   ORC TAVERN — Hub + Shared Game Chrome
   ======================================== */

/* 16:9 lock */
.game-container {
    width: min(100vw, calc(100vh * 16 / 9));
    aspect-ratio: 16 / 9;
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    container-type: size;
    background: #0e0a06 url('assets/tavern-bg.jpg') center/cover no-repeat;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 5;
    overflow-y: auto;
    overflow-x: hidden;
}

.screen[style*="display: none"],
.screen[style*="display:none"] {
    pointer-events: none;
}

/* Mute button */
.mute-btn {
    position: absolute;
    top: 2%;
    right: 2%;
    z-index: 50;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--color-primary);
    color: var(--color-accent);
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mute-btn:hover {
    background: rgba(138, 106, 58, 0.3);
}

/* ---- Hub Screen ---- */
.tavern-header {
    text-align: center;
    margin-bottom: 4%;
}

.tavern-title {
    font-family: 'MedievalSharp', cursive;
    font-size: clamp(1.8rem, 5cqw, 3.5rem);
    color: var(--color-accent);
    text-shadow: 0 0 20px rgba(212, 160, 23, 0.3), 0 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.gold-display {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--color-primary);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 1.8cqw, 1.2rem);
    color: var(--color-accent);
}

.gold-icon {
    font-size: 1.1em;
}

/* Game Selection Grid */
.game-select-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(0.5rem, 1.5cqw, 1rem);
    padding: 0 4%;
    max-width: 92%;
}

.game-card {
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.04) 0%, rgba(0, 0, 0, 0.97) 100%);
    border: 1px solid rgba(138, 106, 58, 0.4);
    border-radius: var(--radius-md);
    padding: clamp(0.5rem, 2cqw, 1.2rem);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    color: var(--color-text);
    font-family: var(--font-body);
}

.game-card:hover {
    border-color: var(--color-accent);
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.1) 0%, rgba(0, 0, 0, 0.97) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 160, 23, 0.15);
}

.game-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 0.3rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: linear-gradient(90deg, rgba(30, 25, 18, 1) 25%, rgba(50, 42, 30, 1) 50%, rgba(30, 25, 18, 1) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.game-card-img.loaded {
    opacity: 0.85;
    animation: none;
    background: none;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.game-card:hover .game-card-img.loaded {
    opacity: 1;
}

.game-card h3 {
    font-family: var(--font-display);
    font-size: clamp(0.7rem, 1.5cqw, 1rem);
    color: var(--color-accent);
    margin-bottom: 0.3rem;
}

.game-card p {
    font-size: clamp(0.55rem, 1.1cqw, 0.8rem);
    color: var(--color-text);
    line-height: 1.3;
    margin-bottom: 0.3rem;
}

.game-card-difficulty {
    font-size: clamp(0.7rem, 1cqw, 0.8rem);
    color: #c4a872;
    font-style: italic;
}

/* Hub Footer */
.hub-footer {
    margin-top: 3%;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(10, 8, 4, 0.7);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-md);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.wallet-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--color-text-dim);
}

/* ---- Shared Buttons ---- */
.btn {
    font-family: var(--font-display);
    font-size: clamp(0.65rem, 1.3cqw, 0.9rem);
    padding: 0.4rem 1.2rem;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.4), rgba(138, 106, 58, 0.2));
    color: var(--color-accent);
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.6), rgba(138, 106, 58, 0.3));
    border-color: var(--color-accent);
}

.btn-secondary {
    background: rgba(0,0,0,0.3);
    color: var(--color-text-dim);
}

.btn-secondary:hover {
    background: rgba(0,0,0,0.5);
    color: var(--color-text);
}

.btn-small {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    background: rgba(0,0,0,0.3);
    color: var(--color-text-dim);
    border: 1px solid rgba(138, 106, 58, 0.3);
    cursor: pointer;
}

.error-msg {
    color: var(--color-danger);
    font-size: 0.75rem;
    margin-top: 0.3rem;
    text-align: center;
    min-height: 1.2em;
}

/* ---- Pre-Game Screen ---- */
#preGameScreen,
#resultScreen,
#leaderboardScreen,
#bankerScreen {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pre-game-box {
    background: rgba(20, 16, 10, 0.9);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: clamp(1rem, 3cqw, 2rem);
    text-align: center;
    max-width: 420px;
    width: 80%;
}

.pre-game-box h2 {
    font-family: var(--font-display);
    color: var(--color-accent);
    font-size: clamp(1rem, 2.5cqw, 1.5rem);
    margin-bottom: 1rem;
}

.pre-game-box h3 {
    font-family: var(--font-display);
    color: var(--color-text);
    font-size: clamp(0.7rem, 1.4cqw, 0.9rem);
    margin-bottom: 0.5rem;
}

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

.rules-toggle {
    background: none;
    border: 1px solid rgba(138, 106, 58, 0.3);
    color: var(--color-accent);
    font-family: var(--font-display);
    font-size: clamp(0.6rem, 1.2cqw, 0.8rem);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 auto;
}

.rules-toggle:hover {
    border-color: var(--color-accent);
}

.rules-arrow {
    font-size: 0.6em;
}

.rules-content {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(138, 106, 58, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.8rem;
}

.rules-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-content li {
    font-size: clamp(0.55rem, 1cqw, 0.72rem);
    color: var(--color-text-dim, #b0a080);
    padding: 0.2rem 0;
    line-height: 1.4;
}

.rules-content li::before {
    content: '\2694  ';
    color: var(--color-accent);
}

.bet-section {
    margin-bottom: 1rem;
}

.bet-input-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.bet-quick {
    font-family: var(--font-display);
    font-size: clamp(0.55rem, 1.1cqw, 0.75rem);
    padding: 0.25rem 0.6rem;
    border: 1px solid rgba(138, 106, 58, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.3);
    color: var(--color-text-dim);
    cursor: pointer;
    transition: all 0.15s ease;
}

.bet-quick:hover {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.bet-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.bet-input {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 1.8cqw, 1.2rem);
    width: 5rem;
    text-align: center;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(138, 106, 58, 0.5);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.6);
    color: var(--color-accent);
    outline: none;
    -moz-appearance: textfield;
}

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

.bet-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.2);
}

.bet-input-flash {
    border-color: var(--color-blood) !important;
    box-shadow: 0 0 10px rgba(180, 40, 40, 0.4) !important;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.bet-input-label {
    font-family: var(--font-display);
    font-size: clamp(0.7rem, 1.3cqw, 0.9rem);
    color: var(--color-text-dim);
}

.bet-info {
    font-size: clamp(0.55rem, 1.1cqw, 0.75rem);
    color: var(--color-text-dim);
    margin-top: 0.4rem;
}

.pre-game-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    margin-top: 1rem;
}

/* ---- Result Screen ---- */
.result-box {
    background: rgba(20, 16, 10, 0.9);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: clamp(1rem, 3cqw, 2rem);
    text-align: center;
    max-width: 400px;
    width: 80%;
}

.result-box h2 {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 3cqw, 2rem);
    margin-bottom: 0.5rem;
}

.result-box h2.win {
    color: var(--color-accent);
    text-shadow: 0 0 15px rgba(212, 160, 23, 0.4);
}

.result-box h2.lose {
    color: var(--color-blood);
}

.result-box h2.draw {
    color: var(--color-text-dim);
}

#resultMessage {
    font-size: clamp(0.7rem, 1.3cqw, 0.9rem);
    color: var(--color-text-dim);
    margin-bottom: 0.8rem;
}

.result-gold {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 2cqw, 1.3rem);
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.result-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 90;
    color: var(--color-text);
    font-family: var(--font-display);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(138, 106, 58, 0.3);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.8rem;
}

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

/* ---- Rotate Prompt (portrait mobile) ---- */
.rotate-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0e0a06;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    font-family: var(--font-display);
    text-align: center;
    padding: 2rem;
}

.rotate-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* ---- Responsive: hub is scrollable, games stay 16:9 ---- */

/* Hub-active: break out of 16:9 lock for menu screens */
.game-container.hub-active {
    width: 100%;
    aspect-ratio: auto;
    overflow-y: auto;
    min-height: 100vh;
    container-type: normal;
}

.game-container.hub-active .screen {
    position: relative;
    height: auto;
    min-height: 100vh;
    padding: 2% 0;
}

/* Portrait mobile — show hub, hide rotate prompt when hub is active */
@media (max-width: 768px) and (orientation: portrait) {
    .rotate-prompt { display: flex; }
    .game-container { display: none; }

    /* When on hub/menu screens, show content and hide rotate prompt */
    .game-container.hub-active { display: block; }
    .game-container.hub-active ~ .rotate-prompt { display: none; }

    .game-select-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 5%;
        max-width: 100%;
    }

    /* Banker card spans full width on 2-col (5th card) */
    .banker-card {
        grid-column: 1 / -1;
    }

    .game-card h3 {
        font-size: 1rem;
    }

    .game-card p {
        font-size: 0.75rem;
    }

    .game-card-difficulty {
        font-size: 0.75rem;
    }

    .tavern-title {
        font-size: 2rem;
    }

    .gold-display {
        font-size: 1rem;
    }

    .btn {
        font-size: 0.85rem;
        padding: 0.5rem 1.4rem;
    }

    .pre-game-box,
    .result-box,
    .leaderboard-box,
    .banker-box {
        width: 90%;
    }

    .hub-footer {
        margin-top: 1.5rem;
        padding: 0.8rem 1rem;
    }

    .game-card p {
        display: none;
    }
}

/* Small landscape (tablets, phones in landscape) */
@media (max-width: 1024px) and (orientation: landscape) {
    .game-container {
        width: 100vw;
        aspect-ratio: auto;
        height: 100vh;
    }

    .game-select-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 95%;
    }

    .banker-card {
        grid-column: auto;
    }
}

/* ---- Wallet Modal (injected by wallet.js) ---- */
.wallet-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wallet-modal-card {
    background: #1a1208;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    min-width: 280px;
    max-width: 360px;
    overflow: hidden;
}

.wallet-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(138, 106, 58, 0.3);
    font-family: var(--font-display);
    color: var(--color-accent);
}

.wallet-modal-close {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 1.4rem;
    cursor: pointer;
}

.wallet-modal-list {
    display: flex;
    flex-direction: column;
}

.wallet-modal-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    background: none;
    border: none;
    border-top: 1px solid rgba(138, 106, 58, 0.15);
    color: var(--color-text);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.wallet-modal-option:first-child {
    border-top: none;
}

.wallet-modal-option:hover {
    background: rgba(138, 106, 58, 0.2);
}

.wallet-modal-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

/* ---- Leaderboard Screen ---- */
.leaderboard-box {
    background: rgba(20, 16, 10, 0.92);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: clamp(0.8rem, 2.5cqw, 1.5rem);
    width: 80%;
    max-width: 440px;
    max-height: 85%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.leaderboard-title {
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.5cqw, 1.5rem);
    color: var(--color-accent);
    text-align: center;
}

.lb-tabs {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.lb-tab {
    font-family: var(--font-display);
    font-size: clamp(0.6rem, 1.2cqw, 0.8rem);
    padding: 0.3rem 0.9rem;
    border: 1px solid rgba(138, 106, 58, 0.4);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.3);
    color: var(--color-text-dim);
    cursor: pointer;
    transition: all 0.15s ease;
}

.lb-tab:hover {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.lb-tab.active {
    background: rgba(138, 106, 58, 0.3);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.leaderboard-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(138, 106, 58, 0.12);
}

.leaderboard-entry.lb-top {
    background: rgba(212, 160, 23, 0.06);
}

.lb-rank {
    width: 2rem;
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(0.7rem, 1.3cqw, 0.9rem);
    color: var(--color-text-dim);
    flex-shrink: 0;
}

.lb-top .lb-rank {
    font-size: clamp(0.9rem, 1.6cqw, 1.1rem);
}

.lb-player {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    overflow: hidden;
}

.lb-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lb-name {
    font-family: var(--font-body);
    font-size: clamp(0.65rem, 1.2cqw, 0.85rem);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-wallet {
    color: var(--color-text-dim);
    font-family: monospace;
    font-size: clamp(0.6rem, 1.1cqw, 0.75rem);
}

.lb-score {
    font-family: var(--font-display);
    font-size: clamp(0.65rem, 1.2cqw, 0.85rem);
    color: var(--color-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---- Banker Card ---- */
.banker-card {
    background: linear-gradient(135deg, rgba(212, 160, 23, 0.05) 0%, rgba(0, 0, 0, 0.97) 100%);
    border-color: rgba(212, 160, 23, 0.5);
}

.banker-card:hover {
    border-color: var(--color-accent);
    background: linear-gradient(135deg, rgba(212, 160, 23, 0.1) 0%, rgba(0, 0, 0, 0.97) 100%);
    box-shadow: 0 6px 20px rgba(212, 160, 23, 0.25);
}

/* ---- Banker Screen ---- */
.banker-box {
    background: rgba(20, 16, 10, 0.92);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: clamp(1rem, 3cqw, 2rem);
    text-align: center;
    max-width: 400px;
    width: 80%;
}

.banker-title {
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.5cqw, 1.5rem);
    color: var(--color-accent);
    margin-bottom: 0.8rem;
}

.banker-portrait {
    width: clamp(80px, 15cqw, 120px);
    height: clamp(80px, 15cqw, 120px);
    margin: 0 auto 1rem;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--color-primary);
}

.banker-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banker-breakdown {
    margin-bottom: 1rem;
}

.banker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.5rem;
    font-size: clamp(0.65rem, 1.3cqw, 0.85rem);
    color: var(--color-text-dim);
}

.banker-row + .banker-row {
    border-top: 1px solid rgba(138, 106, 58, 0.15);
}

.banker-total-row {
    border-top: 1px solid rgba(138, 106, 58, 0.4) !important;
    margin-top: 0.2rem;
    padding-top: 0.5rem;
}

.banker-gold-value {
    font-family: var(--font-display);
    color: var(--color-accent);
}

.banker-total {
    font-size: clamp(0.8rem, 1.5cqw, 1rem);
}

.banker-fee-notice {
    font-size: clamp(0.5rem, 1cqw, 0.65rem);
    color: var(--color-text-dim);
    font-style: italic;
    margin: 0.3rem 0 0.6rem;
    opacity: 0.7;
}

.banker-bank-row {
    background: rgba(212, 160, 23, 0.06);
    border: 1px solid rgba(212, 160, 23, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 0.8rem;
    padding: 0.4rem 0.6rem;
}

.banker-bank-row .banker-gold-value {
    font-size: clamp(0.75rem, 1.4cqw, 0.95rem);
}

.banker-message {
    font-size: clamp(0.6rem, 1.2cqw, 0.8rem);
    color: var(--color-text-dim);
    min-height: 1.4em;
    margin-bottom: 0.8rem;
}

.banker-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

/* ---- Floating Gold Animation ---- */
.floating-gold {
    position: absolute;
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.5cqw, 1.8rem);
    color: var(--color-accent);
    text-shadow: 0 0 10px rgba(212, 160, 23, 0.6), 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 100;
    animation: floatUp 1.2s ease-out forwards;
    transform: translateX(-50%);
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 3px; }
