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

:root {
    --felt:       #1e5c1e;
    --felt-dark:  #164d16;
    --felt-light: #256625;
    --gold:       #f0c040;
    --white:      #ffffff;
    --red:        #cc2200;
}

body {
    background: var(--felt-dark);
    color: var(--white);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Login ───────────────────────────────────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: auto;
}

.login-box {
    background: var(--felt);
    padding: 2rem;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-box h1 { text-align: center; font-size: 2rem; margin-bottom: 1.5rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; opacity: 0.8; }
.field input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.25);
    color: var(--white);
    font-size: 1rem;
}

.login-box button {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--gold);
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.error { color: #ff6b6b; margin-bottom: 1rem; font-size: 0.9rem; }

/* ── App shell ───────────────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────── */

header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.25rem;
    background: rgba(0,0,0,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    z-index: 10;
}

.header-left, .header-right { display: flex; align-items: center; gap: 0.85rem; }
header h1 { font-size: 1.2rem; }

#phase-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.18rem 0.55rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#my-chips { font-weight: 700; color: var(--gold); font-size: 0.95rem; }

.btn-logout {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* ── Message bar ─────────────────────────────────────────────────── */

#message-bar {
    flex-shrink: 0;
    padding: 0.5rem 1.25rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}
#message-bar.error  { background: rgba(180,0,0,0.5); }
#message-bar.info   { background: rgba(0,80,180,0.5); }
#message-bar.hidden { display: none; }

/* ── Table ───────────────────────────────────────────────────────── */

#table {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
}

/* ── Dealer area ─────────────────────────────────────────────────── */

#dealer-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 0.5rem;
}

#dealer-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
    margin-bottom: 0.5rem;
}

#dealer-value { font-size: 0.75rem; opacity: 0.5; margin-left: 0.3rem; }

/* ── Opponents area ──────────────────────────────────────────────── */

#opponents-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    overflow-x: auto;
}

.empty-opponents {
    font-size: 0.85rem;
    opacity: 0.35;
    font-style: italic;
}

.opponent-box {
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    min-width: 140px;
    max-width: 200px;
    flex-shrink: 0;
    transition: box-shadow 0.2s;
}

.opponent-box.active {
    box-shadow: 0 0 0 2px #4caf50, 0 0 12px rgba(76,175,80,0.3);
    border-color: #4caf50;
}

.opp-name  { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.15rem; display: flex; align-items: center; gap: 0.4rem; }
.opp-chips { font-size: 0.72rem; color: var(--gold); margin-bottom: 0.5rem; }

.turn-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    background: #4caf50;
    color: white;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.out-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.opponent-box.sitting-out { opacity: 0.5; }

.waiting-bet { font-size: 0.75rem; opacity: 0.4; font-style: italic; }

/* ── My area ─────────────────────────────────────────────────────── */

#my-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem 0.85rem;
    background: rgba(0,0,0,0.25);
    border-top: 1px solid rgba(255,255,255,0.07);
    gap: 0.5rem;
}

#my-info {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

#my-name-label {
    font-weight: 700;
    font-size: 0.95rem;
}

#my-chips-label {
    font-size: 0.8rem;
    color: var(--gold);
}

#my-hands {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.my-hand { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }

#my-status {
    font-size: 0.8rem;
    font-style: italic;
    min-height: 1.1rem;
}

.waiting-status { opacity: 0.5; }

/* ── Cards ───────────────────────────────────────────────────────── */

.card-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.card-row.centered { justify-content: center; }

.card {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #111;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 5px;
    box-shadow: 1px 2px 5px rgba(0,0,0,0.35);
    flex-shrink: 0;
}

.card.red { color: var(--red); }

.card.card-back {
    background: #1a3a8a;
    color: transparent;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px,
        transparent 2px, transparent 8px
    );
}

/* Size variants */
.card-sm  { width: 44px; height: 62px; font-size: 0.82rem; border-radius: 4px; }
.card-md  { width: 58px; height: 82px; font-size: 1rem; }
.card-lg  { width: 70px; height: 98px; font-size: 1.2rem; border-radius: 7px; }

/* ── Hand info ───────────────────────────────────────────────────── */

.hand      { margin-bottom: 0.4rem; }
.hand-info { font-size: 0.72rem; opacity: 0.6; margin-bottom: 0.3rem; }

.status-label {
    font-weight: 700;
    font-size: 0.65rem;
    padding: 0.08rem 0.3rem;
    border-radius: 3px;
    vertical-align: middle;
}
.status-bust      { background: #b71c1c; color: white; }
.status-blackjack { background: var(--gold); color: #111; }
.status-stood     { background: rgba(255,255,255,0.15); }
.status-doubled   { background: #1565c0; color: white; }

/* ── Controls ────────────────────────────────────────────────────── */

#controls { display: flex; justify-content: center; }

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.chip-buttons { display: flex; gap: 0.4rem; }

.bet-input-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.bet-input-row input {
    width: 80px;
    padding: 0.45rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.3);
    color: white;
    text-align: center;
    font-size: 0.95rem;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--gold);
    color: #1a1a1a;
    transition: opacity 0.12s;
    white-space: nowrap;
}

button:hover:not(:disabled) { opacity: 0.82; }
button:disabled { opacity: 0.25; cursor: not-allowed; }

.btn-secondary { background: rgba(255,255,255,0.14); color: white; }
.chip-btn      { background: rgba(255,255,255,0.1); color: white; font-size: 0.8rem; padding: 0.4rem 0.65rem; }

#btn-start  { font-size: 1rem; padding: 0.65rem 2rem; }
#btn-hit    { background: #388e3c; color: white; }
#btn-stand  { background: #c62828; color: white; }
#btn-double { background: #1565c0; color: white; }
#btn-split  { background: #e65100; color: white; }

.hidden { display: none !important; }
