:root {
    --primary: #1f6feb;
    --primary-hover: #1558bc;
    --accent: #d97706;
    --accent-hover: #b45309;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --secondary: #475569;
    --secondary-hover: #334155;
    --bg-page: #eef2f7;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --hit-red: #e74c3c;
    --miss-blue: #2980b9;
    --cell-size: clamp(24px, 6.8vw, 34px);
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    overflow-x: clip;
    display: block;
}

.main-wrapper {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(10px, 2.5vw, 20px);
}

.game-wrapper {
    max-width: 1380px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
    padding: clamp(12px, 2.5vw, 20px);
    margin-bottom: 16px;
    width: 100%;
}

/* --- Encabezado con Logo y Leyenda --- */
.school-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: clamp(14px, 2.5vw, 20px);
    border-radius: 14px;
    margin-bottom: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
    flex-wrap: wrap;
    text-align: center;
    width: 100%;
}

.school-logo {
    width: clamp(64px, 14vw, 86px);
    height: clamp(64px, 14vw, 86px);
    max-width: 86px;
    max-height: 86px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 50%;
    padding: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s;
}

.school-logo:hover, .school-logo-sm:hover {
    transform: scale(1.06);
}

.school-titles {
    min-width: 0;
}

.school-titles h1 {
    margin: 0;
    font-size: clamp(1.35rem, 4vw, 2.1rem);
    letter-spacing: 0.5px;
    color: #f8fafc;
    line-height: 1.2;
}

.school-subtitle {
    margin: 4px 0 3px;
    font-size: clamp(1rem, 2.8vw, 1.35rem);
    font-weight: 800;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.school-name {
    margin: 0;
    font-size: clamp(0.8rem, 2.2vw, 0.92rem);
    color: #cbd5e1;
}

.learn-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.82rem;
    font-weight: 400;
    color: #94a3b8;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.learn-link:hover {
    color: #e2e8f0;
}

.learn-link-sm {
    margin-top: 3px;
    font-size: 0.76rem;
}

/* --- Login (Estilo Among Us: Personaje + Rasgo) --- */
.login-card {
    max-width: 520px;
    margin: 18px auto;
    text-align: center;
    padding: clamp(18px, 4vw, 28px);
}

.login-card h2 {
    margin-top: 0;
    font-size: clamp(1.2rem, 3.5vw, 1.5rem);
    color: #0f172a;
}

.muted-text {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 6px 0;
}

.name-preview-box {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 14px 0;
    border: 2px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.name-preview-box.spinning {
    border-color: #f59e0b;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.45);
    animation: reelPulse 0.16s infinite alternate;
}

.name-preview-box.spin-landed {
    border-color: #22c55e;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.5);
    animation: landedPop 0.32s ease-out;
}

@keyframes reelPulse {
    from { transform: scale(0.99); }
    to { transform: scale(1.015); }
}

@keyframes landedPop {
    0% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.name-preview-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
}

.name-preview-text {
    font-size: clamp(1.15rem, 3.5vw, 1.45rem);
    color: #f59e0b;
    letter-spacing: 0.4px;
    min-height: 1.6em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.amongus-selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    text-align: left;
}

@media (max-width: 480px) {
    .amongus-selectors {
        grid-template-columns: 1fr;
    }
}

.selector-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selector-col label {
    font-size: 0.84rem;
    font-weight: 700;
    color: #334155;
}

.selector-col select {
    width: 100%;
    height: 42px;
    padding: 8px 10px;
    font-size: 0.96rem;
    font-weight: 600;
    color: #0f172a;
    background-color: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
}

.selector-col select:focus {
    border-color: var(--primary);
}

.selector-col select option:disabled {
    color: #94a3b8;
    background-color: #f1f5f9;
}

.login-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
    width: 100%;
}

.login-form input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 42px;
    padding: 9px 14px;
    font-size: 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    margin: 0;
}

.login-form input:focus {
    border-color: var(--primary);
}

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    color: #ffffff;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    max-width: 100%;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary { background-color: var(--primary); }
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-accent { background-color: var(--accent); }
.btn-accent:hover { background-color: var(--accent-hover); }

.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: var(--success-hover); }

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

.btn-secondary { background-color: var(--secondary); }
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-sm {
    padding: 7px 13px;
    font-size: 0.86rem;
}

/* --- Salón de Juego --- */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    min-width: 0;
    word-break: break-word;
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.section-header h2 {
    margin: 0;
    font-size: clamp(1.05rem, 3vw, 1.25rem);
    color: #0f172a;
}

.badge-info, .badge-neutral, .badge-gold {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}

.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-gold { background: #fef3c7; color: #92400e; }

.games-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.game-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.game-item-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.table-responsive {
    width: 100%;
    overflow-x: visible;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto;
}

.data-table th, .data-table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    word-break: break-word;
}

.data-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
}

.data-table tr:hover td {
    background: #f8fafc;
}

@media (max-width: 680px) {
    .data-table,
    .data-table tbody {
        display: block;
        width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        display: block;
        background: #f8fafc;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        padding: 8px 12px;
        margin-bottom: 10px;
    }

    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 10px;
        padding: 5px 0;
        border-bottom: 1px dashed #e2e8f0;
        text-align: right;
    }

    .data-table tbody td:last-child {
        border-bottom: none;
    }

    .data-table tbody td.empty-msg {
        display: block;
        text-align: center;
        padding: 10px;
    }

    .data-table tbody td[data-label]::before {
        content: attr(data-label) ":";
        font-weight: 700;
        color: #475569;
        text-align: left;
        flex-shrink: 0;
    }
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 14px;
    margin: 0;
}

/* --- Pantalla de Juego --- */
.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #0f172a;
    color: #ffffff;
}

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

.school-logo-sm {
    width: 46px;
    height: 46px;
    max-width: 46px;
    max-height: 46px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 50%;
    padding: 3px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s;
}

.brand-compact h1 {
    margin: 0;
    font-size: clamp(1.05rem, 3vw, 1.25rem);
    color: #ffffff;
}

.school-subtitle-sm {
    margin: 2px 0 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #f59e0b;
}

.status-banner {
    position: sticky;
    top: 8px;
    z-index: 600;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: clamp(0.8rem, 2.7vw, 0.96rem);
    background: #1e293b;
    color: #f8fafc;
    border: 1.5px solid #334155;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.22);
}

.status-banner.my-turn {
    background: #16a34a;
    color: #ffffff;
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.status-banner.other-turn {
    background: #b45309;
    color: #ffffff;
    border-color: #f59e0b;
}

.status-banner.waiting {
    background: #1d4ed8;
    color: #ffffff;
    border-color: #3b82f6;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Tira de Jugadores --- */
.players-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
}

.strip-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #334155;
}

.players-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
}

.player-chip.active-turn {
    border-color: #16a34a;
    background: #dcfce7;
    color: #14532d;
}

.player-chip.eliminated {
    opacity: 0.6;
    text-decoration: line-through;
    background: #fee2e2;
    border-color: #fca5a5;
}

.player-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.25);
    display: inline-block;
    flex-shrink: 0;
}

/* --- Panel de Configuración de Flota --- */
.setup-panel {
    border-left: 5px solid var(--primary);
}

.setup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.setup-header h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
}

.setup-help {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.fleet-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fleet-pill {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
}

.setup-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.color-picker-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.color-swatches {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.12);
}

.color-swatch.selected {
    border-color: #0f172a;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #0f172a;
}

#board-color-input {
    width: 34px;
    height: 30px;
    padding: 0;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    background: none;
}

.setup-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Layout de Tableros --- */
.boards-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 960px) {
    .boards-layout {
        grid-template-columns: 1fr;
    }
}

.board-card {
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.board-card-header {
    width: 100%;
    height: 42px;
    min-height: 42px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
}

.board-card-header h3 {
    margin: 0;
    font-size: clamp(0.82rem, 2.5vw, 0.96rem);
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.board-badge {
    font-size: clamp(0.7rem, 2.2vw, 0.75rem);
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    white-space: nowrap;
    flex-shrink: 0;
}

.board-badge.turn-target {
    background: #dcfce7;
    color: #166534;
}

.board-badge.eliminated {
    background: #fee2e2;
    color: #991b1b;
}

.board-scroll-wrap {
    max-width: 100%;
    overflow-x: auto;
    padding: 2px;
}

/* --- Tablero 11x11 (Coordenadas A-J y 1-10 + Grilla 10x10) --- */
.board-with-coords {
    display: grid;
    grid-template-columns: calc(var(--cell-size) * 0.88) repeat(10, var(--cell-size));
    grid-template-rows: calc(var(--cell-size) * 0.85) repeat(10, var(--cell-size));
    gap: 1px;
    background-color: #64748b;
    border: 2px solid #334155;
    border-radius: 6px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.coord-cell {
    background-color: #1e293b;
    color: #f8fafc;
    font-size: clamp(0.68rem, 2vw, 0.78rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.coord-corner {
    background-color: #0f172a;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--board-theme-color, #d6eaf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(0.75rem, 2.2vw, 0.9rem);
    color: #ffffff;
    position: relative;
    transition: background-color 0.12s;
}

.enemy-board-grid .cell.targetable {
    cursor: crosshair;
}

.enemy-board-grid .cell.targetable:hover {
    filter: brightness(0.88);
    outline: 2px solid #0f172a;
    z-index: 2;
}

/* Barcos propios en el tablero */
.cell.ship {
    background-color: #475569 !important;
    color: #f8fafc;
    border: 1px solid #1e293b;
}

.cell.ship-Editable {
    cursor: grab;
    touch-action: none;
}

.cell.ship-Editable:active {
    cursor: grabbing;
}

/* Previsualización durante arrastre de barcos */
.cell.drag-valid {
    background-color: rgba(22, 163, 74, 0.75) !important;
    outline: 2px dashed #14532d;
    z-index: 3;
}

.cell.drag-invalid {
    background-color: rgba(220, 38, 38, 0.75) !important;
    outline: 2px dashed #7f1d1d;
    z-index: 3;
}

/* Estados de disparo: Rojo para tocado/hundido, Azul para agua */
.cell.hit {
    background-color: var(--hit-red) !important;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.cell.sunk {
    background-color: #c0392b !important;
    color: #ffffff;
    box-shadow: inset 0 0 0 2px #7f1d1d;
}

.cell.miss {
    background-color: var(--miss-blue) !important;
    color: rgba(255, 255, 255, 0.85);
}

.cell.miss::after {
    content: "•";
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
}

/* --- Sección de Tableros Oponentes --- */
.opponents-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

.opponents-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.opponents-toolbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.opponents-heading {
    margin: 0;
    font-size: 1.05rem;
}

.opponent-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.opp-filter-btn {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
}

.opp-filter-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.opponents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
    gap: 14px;
    width: 100%;
}

/* --- Mensajes Temporales Flotantes (Agua / Tocado / Hundido) --- */
.toast-container {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: 92vw;
}

.game-toast {
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 800;
    font-size: clamp(0.9rem, 2.8vw, 1.05rem);
    letter-spacing: 0.3px;
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    animation: toastPop 0.22s ease-out;
    text-align: center;
}

.game-toast.toast-agua {
    background: linear-gradient(135deg, #2980b9, #1d4ed8);
    border: 2px solid #93c5fd;
}

.game-toast.toast-tocado {
    background: linear-gradient(135deg, #e74c3c, #dc2626);
    border: 2px solid #fca5a5;
}

.game-toast.toast-hundido {
    background: linear-gradient(135deg, #b91c1c, #7f1d1d);
    border: 2px solid #fde047;
    color: #fef08a;
}

.game-toast.toast-info {
    background: #1e293b;
    border: 2px solid #64748b;
}

@keyframes toastPop {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Cuadros de Diálogo Draggable Personalizados (Sin Blur, Sin Desplazamiento al Arrastrar) --- */
.custom-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 10000;
}

.custom-dialog {
    position: fixed;
    margin: 0;
    transform: none;
    width: min(420px, 92vw);
    background: #ffffff;
    border-radius: 12px;
    border: 1.5px solid #334155;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.32);
    z-index: 10001;
    overflow: hidden;
}

.custom-dialog-titlebar {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: #ffffff;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-dialog-titlebar span {
    pointer-events: none;
}

.custom-dialog-body {
    padding: 18px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #1e293b;
}

.custom-dialog-footer {
    padding: 12px 16px 14px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.qr-dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.qr-dialog-img {
    width: min(280px, 72vw);
    max-height: 55vh;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    padding: 6px;
}

.qr-dialog-url {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary);
    word-break: break-all;
}

/* --- Ajustes Responsivos para Móviles --- */
@media (max-width: 540px) {
    .school-header {
        flex-direction: column;
        gap: 8px;
        padding: 14px 12px;
    }
    .login-form {
        flex-direction: column;
    }
    .login-form input {
        flex: 0 0 auto;
        height: 42px;
    }
    .login-form .btn {
        width: 100%;
    }
    .user-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .user-info {
        justify-content: center;
    }
    .user-actions {
        width: 100%;
        justify-content: center;
    }
    .user-actions .btn {
        flex: 1 1 auto;
    }
    .game-topbar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .brand-compact {
        justify-content: center;
    }
    .topbar-actions {
        justify-content: center;
    }
    .setup-buttons {
        width: 100%;
    }
    .setup-buttons .btn {
        flex: 1 1 100%;
    }
}

/* --- Página Didáctica: Coordenadas Cartesianas --- */
.learn-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.learn-card h2 {
    margin-top: 0;
    color: #0f172a;
    font-size: clamp(1.15rem, 3vw, 1.4rem);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}

.learn-card p, .learn-list li {
    line-height: 1.6;
    color: #334155;
    font-size: 0.96rem;
}

.learn-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 14px 0;
}

.learn-box {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 14px;
}

.learn-box h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: #0f172a;
}

.learn-box p {
    margin: 0;
}

.learn-highlight {
    background: #eff6ff;
    border-left: 4px solid var(--primary);
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #1e3a8a;
}

.learn-list {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.demo-interactive-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
}

.demo-readout {
    flex: 1 1 260px;
    max-width: 420px;
    margin-bottom: 0;
    background: #f8fafc;
}

.demo-readout h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.demo-coord-big {
    display: inline-block;
    background: #0f172a;
    color: #f59e0b;
    font-size: 1.7rem;
    font-weight: 800;
    padding: 6px 18px;
    border-radius: 10px;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.cell.demo-axis-hl {
    background-color: #93c5fd !important;
}

.cell.demo-point-hl {
    background-color: #f59e0b !important;
    color: #0f172a !important;
    outline: 2px solid #0f172a;
    z-index: 2;
}

.demo-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #475569;
}

.demo-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-swatch {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid #334155;
}

.demo-swatch.axis { background: #93c5fd; }
.demo-swatch.point { background: #f59e0b; }
.demo-swatch.ship { background: #475569; }
