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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

header h1 {
    text-align: center;
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 2.5em;
}

nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

.nav-btn.active {
    background: #764ba2;
}

.section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.hidden {
    display: none !important;
}

/* Upload Section */
.upload-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.upload-info p {
    margin-bottom: 10px;
    color: #495057;
}

.upload-info ul {
    margin: 0;
    padding-left: 20px;
}

.upload-info li {
    margin-bottom: 5px;
    color: #6c757d;
    font-size: 14px;
}

.drop-zone {
    border: 3px dashed #cbd5e0;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #667eea;
    background: #edf2f7;
}

.drop-zone p {
    font-size: 18px;
    color: #718096;
    margin-bottom: 15px;
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.btn-primary {
    background: #38a169;
}

.btn-primary:hover {
    background: #2f855a;
}

.btn-danger {
    background: #e53e3e;
}

.btn-danger:hover {
    background: #c53030;
}

.upload-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.preview-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.preview-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.preview-card input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    margin-bottom: 10px;
}

/* Game Section */
.game-info {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 30px;
    margin-bottom: 30px;
    align-items: start;
}

.current-card {
    text-align: center;
}

.current-card h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

.drawn-card-placeholder,
.drawn-card {
    width: 200px;
    height: 200px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    background: #f8f9fa;
}

.drawn-card {
    background: white;
    border-color: #667eea;
    flex-direction: column;
    padding: 10px;
}

.drawn-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 10px;
}

.drawn-card .card-name {
    font-weight: bold;
    color: #4a5568;
    text-align: center;
}

.drawn-card .card-number {
    font-size: 18px;
    color: #667eea;
    font-weight: bold;
}

.game-stats {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.game-stats p {
    margin-bottom: 10px;
    font-size: 16px;
}

.game-stats span {
    font-weight: bold;
    color: #667eea;
}

/* Tabla (Game Board) - Optimized for 3:4 aspect ratio and printing */
.tabla {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 600px;
    margin: 0 auto 20px;
    background: white;
    padding: 15px;
    border: 2px solid #333;
}

.tabla-cell {
    aspect-ratio: 3/4;
    border: 2px solid #333;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 8px;
    position: relative;
    page-break-inside: avoid;
}

.tabla-cell img {
    width: 100%;
    height: 70%;
    object-fit: contain;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.tabla-cell .cell-info {
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

.tabla-cell .cell-name {
    font-size: 12px;
    font-weight: bold;
    line-height: 1.1;
    color: #333;
    margin-bottom: 2px;
    word-wrap: break-word;
    hyphens: auto;
}

.tabla-cell .cell-number {
    font-size: 10px;
    color: #666;
    font-weight: bold;
}

/* Deck View */
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.deck-card {
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.deck-card:hover {
    transform: translateY(-5px);
}

.deck-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 10px;
}

.deck-card .card-name {
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 5px;
}

/* Print All Cards Section */
.print-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.print-info p {
    margin-bottom: 10px;
    color: #495057;
}

.print-info ul {
    margin: 0;
    padding-left: 20px;
}

.print-info li {
    margin-bottom: 5px;
    color: #6c757d;
    font-size: 14px;
}

.print-cards-controls {
    text-align: center;
    margin-bottom: 30px;
}

.all-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 100%;
    margin: 0 auto;
    background: white;
    padding: 15px;
    border: 2px solid #333;
}

.print-card {
    aspect-ratio: 3/4;
    border: 2px solid #333;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 8px;
    position: relative;
    page-break-inside: avoid;
}

.print-card img {
    width: 100%;
    height: 70%;
    object-fit: contain;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.print-card .card-info {
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

.print-card .card-name {
    font-size: 12px;
    font-weight: bold;
    line-height: 1.1;
    color: #333;
    margin-bottom: 2px;
    word-wrap: break-word;
    hyphens: auto;
}

.print-card .card-number {
    font-size: 10px;
    color: #666;
    font-weight: bold;
}

/* Card Draw Presentation Section - iPad Optimized */
.card-draw-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.card-draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.card-draw-header h2 {
    color: #4a5568;
    margin: 0;
    font-size: 2em;
}

.card-draw-status {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.draw-progress {
    background: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    color: #667eea;
    border: 2px solid #667eea;
    font-size: 16px;
}

.current-drawn-card-display {
    text-align: center;
    margin-bottom: 40px;
}

.main-drawn-card {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    border: 4px solid #333;
}

.card-placeholder {
    aspect-ratio: 3/4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #6c757d;
    padding: 40px 20px;
}

.card-placeholder h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
}

.card-placeholder p {
    margin: 0;
    font-size: 18px;
}

.drawn-card-display {
    aspect-ratio: 3/4;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

.drawn-card-display img {
    width: 100%;
    height: 75%;
    object-fit: cover;
}

.drawn-card-info {
    padding: 15px;
    text-align: center;
    background: white;
    height: 25%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.drawn-card-name {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.2;
}

.drawn-card-number {
    font-size: 20px;
    color: #667eea;
    font-weight: bold;
}

.draw-controls {
    margin: 20px 0;
}

.btn-draw {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
    border: none;
    padding: 20px 60px;
    border-radius: 50px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(56, 161, 105, 0.3);
    min-height: 80px;
    min-width: 200px;
}

.btn-draw:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(56, 161, 105, 0.4);
}

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

.btn-draw:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.drawn-cards-history {
    margin-top: 40px;
}

.drawn-cards-history h3 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.drawn-cards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
}

.history-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    transition: transform 0.2s ease;
    aspect-ratio: 3/4;
    display: flex;
    flex-direction: column;
}

.history-card:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.history-card img {
    width: 100%;
    height: 70%;
    object-fit: cover;
}

.history-card-info {
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    height: 30%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.history-card-name {
    font-size: 11px;
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
    line-height: 1.1;
}

.history-card-number {
    font-size: 10px;
    color: #667eea;
    font-weight: bold;
}

/* Fullscreen mode */
.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a202c;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.fullscreen-mode .card-draw-header {
    color: white;
    margin-bottom: 20px;
}

.fullscreen-mode .card-draw-header h2 {
    color: white;
}

.fullscreen-mode .main-drawn-card {
    max-width: 600px;
    margin: auto;
    flex: 1;
    display: flex;
    align-items: center;
}

.fullscreen-mode .draw-controls {
    text-align: center;
    margin-top: 20px;
}

.fullscreen-mode .drawn-cards-history {
    display: none;
}

.deck-card .card-number {
    color: #667eea;
    font-size: 14px;
}

.deck-actions {
    text-align: center;
    margin-top: 20px;
}

.deck-primary-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
}

.deck-secondary-actions {
    display: flex;
    justify-content: center;
}

.btn-success {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(56, 161, 105, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 161, 105, 0.4);
}

/* Import Options Modal */
.import-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.import-deck-info {
    font-size: 14px;
    color: #495057;
}

.import-deck-info h4 {
    margin: 0 0 10px 0;
    color: #343a40;
}

.import-options {
    text-align: left;
    margin-bottom: 20px;
}

.import-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.import-option:hover {
    background: #f8f9fa;
}

.import-option input[type="radio"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

.import-option span {
    font-size: 14px;
    color: #495057;
}

/* Import Progress */
.import-progress {
    margin: 15px 0;
    padding: 10px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    display: none;
}

.import-progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.import-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196f3 0%, #1976d2 100%);
    transition: width 0.3s ease;
    width: 0%;
}

.import-progress-text {
    font-size: 14px;
    color: #1565c0;
    text-align: center;
}

/* Export feedback */
.export-success {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    z-index: 1500;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Drag and drop import styling */
.drag-over-import {
    border: 3px dashed #667eea !important;
    background: rgba(102, 126, 234, 0.1) !important;
    border-radius: 15px;
}

.drag-over-import::after {
    content: "Drop JSON file here to import deck";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    z-index: 1000;
    pointer-events: none;
}

#deck-section {
    position: relative;
    min-height: 200px;
}

/* PWA and Offline Styling */
.offline-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    animation: slideInRight 0.3s ease;
}

.offline-indicator.hidden {
    display: none;
}

.offline-icon {
    filter: grayscale(1);
}

.offline-mode .nav-btn {
    position: relative;
}

.offline-mode .nav-btn::after {
    content: "";
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    border: 2px solid white;
}

/* PWA Install Banner */
.install-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 1400;
    animation: slideInUp 0.3s ease;
}

.install-banner.hidden {
    display: none;
}

.install-content {
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 15px;
}

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

.install-text {
    flex: 1;
}

.install-text strong {
    display: block;
    color: #333;
    font-size: 16px;
    margin-bottom: 4px;
}

.install-text small {
    color: #666;
    font-size: 14px;
}

.install-actions {
    display: flex;
    gap: 10px;
}

.install-actions .btn {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 20px;
}

/* PWA Splash Screen Simulation */
.pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.5s ease;
}

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

.pwa-splash-icon {
    font-size: 4rem;
    color: white;
    margin-bottom: 20px;
}

.pwa-splash-title {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
}

/* Offline mode adaptations */
.offline-mode .btn:not(.btn-primary):not(.btn-success):not(.btn-danger) {
    opacity: 0.7;
}

.offline-mode .upload-tips::before {
    content: "📶 Offline Mode: ";
    color: #dc3545;
    font-weight: bold;
}

/* Animation for offline/online transitions */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Update notification */
.update-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    font-weight: bold;
    z-index: 1500;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Enhanced cache status indicator */
.cache-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 1300;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cache-status.visible {
    opacity: 1;
}

/* Connection status notifications */
.connection-status {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 14px;
    z-index: 1400;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.connection-status.success {
    background: #28a745;
    color: white;
}

.connection-status.warning {
    background: #ffc107;
    color: #333;
}

.connection-status.info {
    background: #17a2b8;
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #4a5568;
}

.modal-content img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 16px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .game-info {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .tabla {
        max-width: 300px;
    }
    
    .upload-previews {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .tabla {
        max-width: 500px;
    }
    
    /* Card Draw mobile adjustments */
    .card-draw-header {
        flex-direction: column;
        text-align: center;
    }
    
    .main-drawn-card {
        max-width: 400px;
    }
    
    .btn-draw {
        padding: 15px 40px;
        font-size: 20px;
        min-height: 70px;
        min-width: 180px;
    }
    
    .drawn-cards-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* iPad-specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Touch-friendly interface for tablets */
    .nav-btn {
        padding: 15px 25px;
        font-size: 18px;
        min-height: 60px;
    }
    
    .btn {
        min-height: 60px;
        padding: 15px 30px;
        font-size: 18px;
    }
    
    .card-draw-container {
        padding: 30px;
    }
    
    .main-drawn-card {
        max-width: 600px;
    }
    
    .btn-draw {
        padding: 25px 70px;
        font-size: 28px;
        min-height: 100px;
        min-width: 250px;
    }
    
    .drawn-card-name {
        font-size: 28px;
    }
    
    .drawn-card-number {
        font-size: 24px;
    }
    
    .card-draw-header h2 {
        font-size: 2.5em;
    }
    
    .draw-progress {
        font-size: 18px;
        padding: 12px 25px;
    }
    
    /* Import/Export iPad optimizations */
    .deck-primary-actions {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }
    
    .btn-success, .deck-primary-actions .btn {
        min-height: 60px;
        padding: 15px 30px;
        font-size: 18px;
        min-width: 200px;
    }
    
    .import-option {
        padding: 15px;
        font-size: 16px;
    }
    
    .import-option input[type="radio"] {
        width: 20px;
        height: 20px;
    }
    
    .modal-content {
        max-width: 500px;
        padding: 40px;
    }
}

/* Landscape iPad optimization */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .card-draw-container {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 30px;
        align-items: start;
    }
    
    .card-draw-header {
        grid-column: 1 / -1;
    }
    
    .current-drawn-card-display {
        margin-bottom: 0;
    }
    
    .drawn-cards-history {
        margin-top: 0;
    }
    
    .drawn-cards-list {
        max-height: 500px;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
}

/* Print Styles - Optimized for printing tablas */
@media print {
    body {
        background: white;
        color: black;
        font-family: 'Times New Roman', serif;
    }
    
    .container {
        max-width: none;
        padding: 0;
        margin: 0;
    }
    
    header, .nav-btn, .btn, .game-info, .game-stats, 
    #upload-section, #deck-section, .section.hidden, .print-info, .print-cards-controls, .no-print {
        display: none !important;
    }
    
    #game-section {
        display: block !important;
        margin-bottom: 0;
        padding-bottom: 0 !important;
        background: white;
        padding: 20px;
        box-shadow: none;
    }
    
    /* Show only the section being printed */
    body.printing-tabla #print-cards-section {
        display: none !important;
    }
    
    body.printing-cards #game-section {
        display: none !important;
    }
    
    /* All cards print layout */
    #print-cards-section h2 {
        display: none;
    }
    
    .all-cards-grid {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0;
        border: none;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        page-break-inside: avoid;
    }
    
    .print-card {
        border: 2px solid black;
        border-radius: 2px;
        padding: 4px;
        background: white;
        page-break-inside: avoid;
    }
    
    .print-card img {
        border: 1px solid black;
    }
    
    .print-card .card-name {
        font-size: 10px;
        color: black;
    }
    
    .print-card .card-number {
        font-size: 8px;
        color: black;
    }
    
    .game-board h3 {
        text-align: center;
        margin-bottom: 20px;
        font-size: 24px;
        font-weight: bold;
        color: black;
    }
    
    .tabla {
        max-width: none;
        width: 100%;
        margin: 0 auto;
        gap: 6px;
        padding: 10px;
        border: 3px solid black;
        page-break-inside: avoid;
    }
    
    .tabla-cell {
        border: 2px solid black;
        border-radius: 2px;
        padding: 6px;
        background: white;
    }
    
    .tabla-cell img {
        border: 1px solid black;
    }
    
    .tabla-cell .cell-name {
        font-size: 11px;
        color: black;
    }
    
    .tabla-cell .cell-number {
        font-size: 9px;
        color: black;
    }
    
    .tabla-controls {
        display: none !important;
    }
    
    /* Print button specifically for tablas */
    .print-tabla-btn {
        display: inline-block !important;
        background: #4CAF50;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        cursor: pointer;
    }
}

/* Tabla controls styling */
.tabla-controls {
    text-align: center;
    margin-top: 20px;
}

.tabla-controls .btn {
    margin: 0 10px;
}