* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 8px;
    font-size: 16px;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow-x: hidden;
}

h1 {
    text-align: center;
    color: #1a1a1a;
    margin-bottom: 16px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
}

h2 {
    color: #667eea;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

h3 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

.section {
    margin-bottom: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
}

/* Configuración de Equipos */
.teams-config {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.team-config {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.team-config select,
.team-config input {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    appearance: none;
    background: white;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-config select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.team-config input:focus,
.team-config select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.team-config button {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-config button:active {
    transform: scale(0.98);
    background: #5568d3;
}

/* Marcador */
.scoreboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.team-score {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.team-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-preview {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
    flex-shrink: 0;
}

.team-info h3 {
    flex: 1;
    margin: 0;
    font-size: 1.1rem;
    color: #1a1a1a;
}

.vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    text-align: center;
    padding: 8px 0;
}

.score-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.score-controls button {
    width: 56px;
    height: 56px;
    font-size: 28px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    flex-shrink: 0;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.score-controls button:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.3);
}

.score, .cards-count {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a1a1a;
    min-width: 80px;
    text-align: center;
}

/* Tarjetas */
.cards-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.cards-control {
    background: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cards-control h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.cards-count {
    color: #dc3545;
    font-size: 2rem;
}

/* Tiempo Extra */
.extra-time-section {
    display: flex;
    justify-content: center;
}

.extra-time-control {
    background: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 200px;
}

.extra-time-control h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #667eea;
}

.extra-time-control .cards-count {
    color: #667eea;
}

/* Tiempo */
.time-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-section input,
.time-section select {
    width: 100%;
    max-width: 100%;
    padding: 12px 10px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.time-section input {
    text-align: center;
    font-weight: 600;
}

.time-section select {
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat;
    background-position: calc(100% - 10px) center;
    padding-right: 35px;
    white-space: normal;
    overflow: visible;
    line-height: 1.3;
}

.time-section input:focus,
.time-section select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.time-section button {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    box-sizing: border-box;
}

.time-section button:active {
    transform: scale(0.98);
    background: #5568d3;
}

/* Acciones */
.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.actions button {
    width: 100%;
    max-width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-reset {
    background: #dc3545;
    color: white;
}

.btn-reset:active {
    background: #c82333;
    transform: scale(0.98);
}

.btn-info {
    background: #28a745;
    color: white;
}

.btn-info:active {
    background: #218838;
    transform: scale(0.98);
}

/* Instrucciones */
.instructions {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.instructions ol {
    margin-left: 16px;
    line-height: 1.8;
}

.instructions li {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.instructions code {
    background: #f0f4ff;
    padding: 4px 8px;
    border-radius: 4px;
    color: #667eea;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
    display: inline-block;
}

/* Logo Upload */
.logo-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.logo-upload .separator {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    padding: 4px 0;
}

.btn-upload {
    width: 100%;
    padding: 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-upload:active {
    background: #5a6268;
    transform: scale(0.98);
}

/* Cronómetro */
.timer-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.timer-display {
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    border-radius: 12px;
}

.timer-time {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    display: block;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.timer-status {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
    display: block;
}

.timer-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.timer-controls button {
    padding: 12px 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-start {
    background: #28a745;
    color: white;
}

.btn-start:active {
    background: #218838;
    transform: scale(0.98);
}

.btn-pause {
    background: #ffc107;
    color: #1a1a1a;
}

.btn-pause:active {
    background: #e0a800;
    transform: scale(0.98);
}

.btn-resume {
    background: #17a2b8;
    color: white;
}

.btn-resume:active {
    background: #138496;
    transform: scale(0.98);
}

.btn-stop {
    background: #dc3545;
    color: white;
}

.btn-stop:active {
    background: #c82333;
    transform: scale(0.98);
}

/* Selector de Templates */
.template-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.template-selector select {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
    padding-right: 40px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-preview {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-preview:active {
    background: #5568d3;
    transform: scale(0.98);
}

/* Subida de logos */
.logo-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.logo-upload .separator {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    padding: 4px 0;
}

.btn-upload {
    width: 100%;
    padding: 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-upload:active {
    background: #5a6268;
    transform: scale(0.98);
}

/* Instrucciones */
.instructions {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.instructions ol {
    margin-left: 16px;
    line-height: 1.8;
}

.instructions li {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.instructions code {
    background: #f0f4ff;
    padding: 4px 8px;
    border-radius: 4px;
    color: #667eea;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
    display: inline-block;
}

/* Nav Menu */
.nav-menu {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 20px !important;
    padding: 8px !important;
    background: #f8f9fa !important;
    border-radius: 12px !important;
}

.nav-menu a {
    padding: 10px 6px !important;
    background: #667eea !important;
    color: white !important;
    text-decoration: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    transition: all 0.2s !important;
    text-align: center !important;
    touch-action: manipulation !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.nav-menu a:active {
    background: #5568d3 !important;
    transform: scale(0.98) !important;
}

/* Media Queries Adicionales */
@media (max-width: 360px) {
    body {
        padding: 6px;
        font-size: 15px;
    }

    .container {
        padding: 10px;
        border-radius: 10px;
    }

    h1 {
        font-size: 1.35rem;
        margin-bottom: 12px;
    }

    h2 {
        font-size: 1.1rem;
    }

    .nav-menu {
        gap: 4px !important;
        padding: 6px !important;
    }

    .nav-menu a {
        padding: 8px 4px !important;
        font-size: 0.75rem !important;
    }

    .timer-time {
        font-size: 2.5rem;
    }

    .timer-controls button {
        padding: 10px 6px;
        font-size: 12px;
    }

    .score-controls button {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .score, .cards-count {
        font-size: 2rem;
    }
}

/* Media Queries - Tablets y Desktop */
@media (min-width: 640px) {
    body {
        padding: 20px;
    }

    .container {
        padding: 24px;
    }

    h1 {
        font-size: 2.25rem;
    }

    .nav-menu {
        gap: 12px !important;
        padding: 12px !important;
    }

    .nav-menu a {
        padding: 12px !important;
        font-size: 0.95rem !important;
    }

    .teams-config {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .cards-section {
        grid-template-columns: 1fr 1fr;
    }

    .scoreboard {
        flex-direction: row;
        align-items: center;
    }

    .logo-upload {
        flex-direction: row;
        align-items: center;
    }

    .logo-upload .separator {
        padding: 0 8px;
    }

    .time-section {
        flex-direction: row;
    }

    .timer-controls {
        grid-template-columns: repeat(4, 1fr);
    }

    .timer-controls button {
        padding: 14px;
        font-size: 15px;
    }

    .actions {
        flex-direction: row;
        justify-content: center;
    }

    .actions button {
        flex: 0 1 auto;
        min-width: 200px;
    }

    .template-selector {
        flex-direction: row;
    }

    .template-selector select {
        flex: 1;
    }

    .btn-preview {
        width: auto;
        min-width: 150px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        padding: 30px;
    }

    h1 {
        font-size: 2.5rem;
    }
}
