/* ==========================================================================
   style-bingo-online.css
   Modo Online — tema "marquesina de bingo hall": azul tinta profundo,
   dorado latón y crema, con la bolilla numerada como elemento de firma.
   ========================================================================== */

:root {
    --ink:        #10182b;
    --ink-2:      #182444;
    --ink-3:      #212f57;
    --gold:       #e3b23c;
    --gold-soft:  #f4d98a;
    --cream:      #f6f1e3;
    --coral:      #ff5d73;
    --green-ok:   #35c98f;
    --grey-off:   #5a6480;

    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 9px;

    --font-display: 'Archivo Black', 'Arial Black', sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 50% -10%, #26326008, transparent 60%), var(--ink);
    color: var(--cream);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

button {
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    outline: none;
}

.app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 16px 40px;
}

/* ---------- Pantalla de nombre + apuesta --------------------------------- */

.screen-name {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 18px;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-ball {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--ink);
    background: radial-gradient(circle at 32% 28%, var(--gold-soft), var(--gold) 60%, #b9862a 100%);
    box-shadow: 0 6px 18px rgba(227, 178, 60, 0.35), inset 0 -4px 6px rgba(0,0,0,0.15);
}

.brand h1 {
    font-family: var(--font-display);
    font-size: 26px;
    letter-spacing: 0.5px;
    margin: 0;
}

.tagline {
    color: var(--grey-off);
    font-size: 15px;
    max-width: 320px;
    margin: 0;
}

.field {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.field > span {
    font-size: 13px;
    color: var(--gold-soft);
    font-weight: 600;
}

.field input,
.join-inline-row input {
    background: var(--ink-2);
    border: 1px solid #2c3a66;
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    color: var(--cream);
    font-size: 16px;
    width: 100%;
}

.field input:focus,
.join-inline-row input:focus {
    border-color: var(--gold);
}

.bet-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.bet-chip {
    background: var(--ink-2);
    border: 1px solid #2c3a66;
    color: var(--cream);
    border-radius: var(--radius-sm);
    padding: 11px 0;
    font-weight: 700;
    font-size: 14px;
    transition: border-color .15s ease, background .15s ease;
}

.bet-chip.active {
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--ink);
    border-color: var(--gold);
}

/* ---------- Botones ------------------------------------------------------ */

.btn {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 15px;
    transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; max-width: 320px; }

.btn-primary {
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--ink);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-secondary {
    background: var(--ink-3);
    color: var(--cream);
    border: 1px solid #33427a;
}

.btn-bingo {
    background: linear-gradient(180deg, #ff7d8f, var(--coral));
    color: #fff;
    font-family: var(--font-display);
    letter-spacing: 1px;
    font-size: 18px;
    max-width: 100%;
    margin: 18px 0;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink-3);
    color: var(--gold-soft);
    width: 38px;
    height: 38px;
    border-radius: 999px;
    flex: 0 0 auto;
    transition: background .15s ease, color .15s ease, transform .08s ease;
}

.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { background: #2a3a6e; }

.icon-btn-danger { color: #ffb4bd; }
.icon-btn-danger:hover { background: var(--coral); color: #fff; }

#btnStart:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.3);
}

/* ---------- Juego: header --------------------------------------- */

.screen-game { display: flex; flex-direction: column; gap: 16px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.room-pill,
.pot-pill {
    background: var(--ink-3);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.room-pill { color: var(--gold-soft); }
.pot-pill { color: var(--green-ok); flex: 1; text-align: center; }

/* ---------- Bolilla actual, sola y centrada ------------------------------ */

.draw-current {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 0 4px;
}

.last-ball {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 38px;
    color: var(--ink);
    background: radial-gradient(circle at 32% 28%, var(--gold-soft), var(--gold) 62%, #b9862a 100%);
    box-shadow: 0 10px 26px rgba(227,178,60,0.35), inset 0 -6px 10px rgba(0,0,0,0.18);
}

.draw-caption {
    margin: 0;
    font-size: 13px;
    color: var(--grey-off);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.draw-history {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.draw-history::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    min-width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ink-2);
    color: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid #33427a;
}

.chip:first-child {
    background: var(--ink-3);
    border-color: var(--gold);
    color: var(--gold-soft);
}

.status-banner {
    text-align: center;
    font-size: 14px;
    color: var(--grey-off);
    padding: 0 8px;
}

/* ---------- Fila de espera: iniciar + unirse a otra sala ------------------ */

.waiting-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: var(--ink-2);
    border: 1px solid #253357;
    border-radius: var(--radius-lg);
    padding: 16px;
}

.waiting-row .btn { max-width: 320px; width: 100%; }

.join-inline {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.join-inline > span {
    display: block;
    font-size: 13px;
    color: var(--grey-off);
    margin-bottom: 8px;
}

.join-inline-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: stretch;
}

.join-inline-row input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    letter-spacing: 3px;
    text-align: center;
    font-weight: 700;
    font-size: 18px;
}

.join-inline-row .btn {
    width: auto;
    max-width: none;
    white-space: nowrap;
    padding-left: 16px;
    padding-right: 16px;
}

@media (max-width: 340px) {
    .join-inline-row { grid-template-columns: 1fr; }
    .join-inline-row .btn { width: 100%; }
}

/* ---------- Cartón --------------------------------------------------------*/

.card-wrap {
    background: var(--cream);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.card-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.automark-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 4px 4px 2px;
}

.automark-toggle .switch {
    width: 32px;
    height: 18px;
    border-radius: 999px;
    background: #d8d0b8;
    position: relative;
    transition: background .15s ease;
    flex: 0 0 auto;
}

.automark-toggle .switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s ease;
}

.automark-toggle.active .switch { background: var(--green-ok); }
.automark-toggle.active .switch::after { transform: translateX(14px); }

.bingo-header {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin-bottom: 8px;
}

.bingo-header span {
    text-align: center;
    font-family: var(--font-display);
    color: var(--ink-3);
    font-size: 20px;
}

.bingo-card {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.cell {
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1.5px solid #e3dcc6;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell.callable {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(227,178,60,0.35) inset;
    animation: pulse 1.4s ease-in-out infinite;
}

.cell.marked {
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    color: var(--ink);
    border-color: var(--gold);
}

.cell.free {
    background: var(--ink-3);
    color: var(--gold-soft);
    font-size: 20px;
}

.cell:disabled { opacity: 1; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(227,178,60,0.25) inset; }
    50% { box-shadow: 0 0 0 5px rgba(227,178,60,0.45) inset; }
}

/* ---------- Jugadores ------------------------------------------------------*/

.players-panel h3 {
    font-size: 14px;
    color: var(--gold-soft);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 4px 0 10px;
}

.players-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.players-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ink-2);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 14px;
}

.players-list li.me { border: 1px solid var(--gold); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot.on { background: var(--green-ok); }
.dot.off { background: #57607a; }

.pname { flex: 1; }

.pbet {
    font-size: 12px;
    font-weight: 700;
    color: var(--green-ok);
}

.tag-win {
    background: var(--coral);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
}

/* ---------- Modales ---------------------------------------------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 24, 0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}

@media (min-width: 560px) {
    .modal-overlay { align-items: center; }
}

.modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--ink-2);
    border: 1px solid #2c3a66;
    border-radius: 24px 24px 0 0;
    padding: 28px 22px;
}

@media (min-width: 560px) {
    .modal { border-radius: var(--radius-lg); }
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 20px;
    margin: 0 0 6px;
}

.modal p { color: var(--grey-off); font-size: 14px; margin: 0 0 12px; }

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: transparent;
    color: var(--grey-off);
    font-size: 22px;
    line-height: 1;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink-3);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 6px;
}

#inviteCode {
    font-family: var(--font-display);
    font-size: 24px;
    letter-spacing: 3px;
    color: var(--gold-soft);
}

.modal-error {
    color: var(--coral);
    font-size: 13px;
    margin-top: 10px;
}

/* ---------- Modal de ganador ------------------------------------------- */

.modal-win {
    text-align: center;
}

.win-ball {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--ink);
    background: radial-gradient(circle at 32% 28%, var(--gold-soft), var(--gold) 62%, #b9862a 100%);
}

.modal-win h2 { font-size: 26px; }

.win-pot {
    color: var(--green-ok) !important;
    font-weight: 700;
    font-size: 15px !important;
}

/* ---------- Responsive ------------------------------------------------- */

@media (max-width: 360px) {
    .brand h1 { font-size: 22px; }
    .last-ball { width: 88px; height: 88px; font-size: 32px; }
    .icon-btn { width: 34px; height: 34px; }
    .room-pill, .pot-pill { padding: 7px 10px; font-size: 12px; }
}

.topbar-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 4px 0 8px;
}

.btn-pause, .btn-resume {
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    background: var(--ink-3);
    color: var(--cream);
    border: 1px solid #2c3a66;
}

.btn-pause:hover { background: #2a3a6e; }
.btn-resume { background: var(--green-ok); color: var(--ink); }