* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: #fff;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 50px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none !important;
}

/* Setup Panel */
.setup-panel {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.setup-panel h2 {
    text-align: center;
    margin-bottom: 25px;
}

.team-setup-container {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.team-setup {
    flex: 1;
    min-width: 250px;
    padding: 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.team1-setup {
    border: 2px solid rgba(102, 126, 234, 0.5);
}

.team2-setup {
    border: 2px solid rgba(245, 87, 108, 0.5);
}

.team-setup h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.team1-setup h3 {
    color: #667eea;
}

.team2-setup h3 {
    color: #f5576c;
}

.team-input {
    margin-bottom: 12px;
}

.team-input:last-child {
    margin-bottom: 0;
}

.team-input label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.team-input input {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    box-sizing: border-box;
}

.team-input input::placeholder {
    color: #999;
}

.team-input-row {
    display: flex;
    gap: 10px;
}

.team-input-row .team-input {
    flex: 1;
}

.team-input input[type="number"] {
    -moz-appearance: textfield;
}

.team-input input[type="number"]::-webkit-outer-spin-button,
.team-input input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.setup-error {
    background: rgba(245, 87, 108, 0.2);
    border: 1px solid #f5576c;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    color: #f5576c;
    font-size: 0.9rem;
}

.setup-error.hidden {
    display: none;
}

.setup-error ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.setup-error li {
    margin-bottom: 4px;
}

.match-type {
    margin-bottom: 25px;
}

.match-type > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: scale(0.98);
}

@media (hover: none) {
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    width: 100%;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.btn-score {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #fff;
    margin-top: 15px;
    width: 100%;
}

/* Scoreboard */
.scoreboard {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.match-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.9rem;
}

.current-set {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.team {
    flex: 1;
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
}

.team1 {
    border: 3px solid #667eea;
}

.team2 {
    border: 3px solid #f5576c;
}

.team-name {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.timeout-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.timeout-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.timeout-btn:active {
    transform: scale(0.95);
}

.timeout-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.timeout-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.1);
}

.timeout-icon {
    width: 24px;
    height: 24px;
    filter: invert(1);
    opacity: 0.9;
}

.timeout-dots {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeout-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.3s, box-shadow 0.3s;
}

.timeout-dot.active {
    background: #ffd700;
    box-shadow: 0 0 8px #ffd700;
}

/* Rotation Grid */
.rotation-grid.hidden {
    display: none;
}

.rotation-grid {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
}

.rotation-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.rotation-row:last-child {
    margin-bottom: 0;
}

.rotation-pos {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s, transform 0.2s;
    cursor: pointer;
    position: relative;
}

.rotation-pos:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.rotation-pos .player-num {
    display: inline-block;
}

.rotation-pos .player-num.captain {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rotation-pos .sub-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 0.6rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: none;
    align-items: center;
    justify-content: center;
}

.rotation-pos .sub-indicator.visible {
    display: flex;
}

.rotation-pos.server {
    background: rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.rotation-pos.libero-in {
    background: rgba(76, 175, 80, 0.4);
}

.team1 .rotation-pos {
    border-color: rgba(102, 126, 234, 0.5);
}

.team2 .rotation-pos {
    border-color: rgba(245, 87, 108, 0.5);
}

.front-row {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    padding-bottom: 6px;
}

.rotation-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    margin-bottom: 5px;
}

/* Rotation Setup */
.rotation-setup {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.rotation-setup h2 {
    text-align: center;
    margin-bottom: 10px;
}

.rotation-setup-score {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
}

.rotation-setup-score.hidden {
    display: none;
}

.rotation-setup-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.rotation-setup-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.rotation-setup-team {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    text-align: center;
}

.rotation-setup-team h3 {
    margin-bottom: 15px;
}

.rotation-setup-team:first-child h3 {
    color: #667eea;
}

.rotation-setup-team:last-child h3 {
    color: #f5576c;
}

.rotation-setup-grid {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.rotation-setup-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.rotation-setup-row:last-child {
    margin-bottom: 0;
}

.rotation-setup-pos {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}

.rotation-setup-pos:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.rotation-setup-pos.filled {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 1rem;
}

.rotation-setup-pos.selected {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.available-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.available-player {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.available-player:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.available-player.used {
    opacity: 0.3;
    cursor: not-allowed;
}

.available-player.captain {
    border: 2px solid #ffd700;
}

.rotation-setup-team:first-child .available-player {
    background: rgba(102, 126, 234, 0.3);
}

.rotation-setup-team:last-child .available-player {
    background: rgba(245, 87, 108, 0.3);
}

/* Timeout Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.timer-display {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 30px;
}

.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 8;
}

.timer-ring-progress {
    fill: none;
    stroke: #ffd700;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.modal .btn-primary {
    max-width: 200px;
}

/* Substitution Modal */
.sub-modal-content {
    min-width: 280px;
}

.sub-modal-content h2 {
    margin-bottom: 15px;
}

.sub-modal-content p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

.sub-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.sub-option {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sub-option:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.sub-option.libero {
    background: rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0.8);
}

.sub-option.libero:hover {
    background: rgba(76, 175, 80, 0.6);
}

.sub-option.return-player {
    background: rgba(255, 193, 7, 0.3);
    border-color: rgba(255, 193, 7, 0.8);
}

.sub-option.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sub-option.disabled:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.1);
}

.score {
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
}

.team1 .score {
    color: #667eea;
}

.team2 .score {
    color: #f5576c;
}

.vs-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.undo-btn {
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.undo-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.undo-btn:active {
    transform: scale(0.95);
}

.undo-icon {
    width: 24px;
    height: 24px;
}

.swap-teams {
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.swap-teams:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.swap-teams:active {
    transform: scale(0.95);
}

.swap-icon {
    width: 32px;
    height: 32px;
}

.vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
}

.sets-score-center {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.set-score-item {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 5px 15px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
}

.set-score-item.team1-set-win {
    border-left: 3px solid #667eea;
}

.set-score-item.team2-set-win {
    border-right: 3px solid #f5576c;
}

.set-score-item.teamA-set-win {
    border-left: 3px solid #667eea;
}

.set-score-item.teamB-set-win {
    border-right: 3px solid #f5576c;
}

.no-sets {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
}

.serve-indicator {
    width: 80px;
    height: 40px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: background 0.2s;
}

.serve-indicator:hover {
    background: rgba(255, 255, 255, 0.2);
}

.serve-ball {
    width: 30px;
    height: 30px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.3s ease;
    left: 5px;
}

.serve-ball.right {
    left: calc(100% - 35px);
}

/* Point Timeline */
.point-timeline {
    margin-bottom: 25px;
}

.point-timeline h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.timeline-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.timeline-team {
    display: flex;
    align-items: center;
    min-height: 40px;
}

.timeline-team:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.timeline-label {
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.first-serve-icon {
    width: 18px;
    height: 18px;
}

.timeline-team:first-child .timeline-label {
    color: #667eea;
}

.timeline-team:last-child .timeline-label {
    color: #f5576c;
}

/* Dynamic timeline colors based on team identity */
.timeline-team[data-team-color="blue"] .timeline-label {
    color: #667eea;
}

.timeline-team[data-team-color="red"] .timeline-label {
    color: #f5576c;
}

.timeline-team[data-team-color="blue"] .timeline-cell.scored {
    background: rgba(102, 126, 234, 0.4);
    color: #a8b5f0;
}

.timeline-team[data-team-color="red"] .timeline-cell.scored {
    background: rgba(245, 87, 108, 0.4);
    color: #f9a8b5;
}

.timeline-row {
    display: flex;
    flex: 1;
}

.timeline-cell {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 4px;
    margin: 0 2px;
}

.timeline-cell.scored {
    background: rgba(255, 255, 255, 0.15);
}

.timeline-cell.empty {
    color: transparent;
}

.timeline-empty {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    font-size: 0.9rem;
}


/* Controls */
.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.controls .btn {
    flex: 1;
    min-width: 150px;
}

/* Match Result */
.match-result {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 40px;
    backdrop-filter: blur(10px);
    text-align: center;
}

.match-result h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.winner {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-score {
    margin-bottom: 30px;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
}

.final-score .set-result {
    display: inline-block;
    margin: 5px;
}

#playAgain {
    max-width: 300px;
}

/* Credits Footer */
.credits {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        padding-bottom: 50px;
    }

    h1 {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }

    .setup-panel, .scoreboard, .rotation-setup, .match-result {
        padding: 20px 15px;
        border-radius: 12px;
    }

    .team-setup-container {
        flex-direction: column;
        gap: 15px;
    }

    .team-setup {
        min-width: unset;
        padding: 15px;
    }

    .team-input input {
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .rotation-setup-container {
        flex-direction: column;
        gap: 20px;
    }

    .rotation-setup-team {
        max-width: unset;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.4rem;
    }

    .current-set {
        flex-direction: column;
        gap: 15px;
    }

    .team {
        padding: 15px;
        width: 100%;
    }

    .vs-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
        padding: 10px 0;
    }

    .vs {
        display: none;
    }

    .score {
        font-size: 3.5rem;
    }

    .team-name {
        font-size: 1.1rem;
    }

    .match-info {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        font-size: 0.85rem;
    }

    .btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    .btn-score {
        padding: 16px 20px;
    }

    .rotation-grid {
        padding: 8px;
    }

    .rotation-pos {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }

    .rotation-row {
        gap: 6px;
    }

    .timeout-container {
        gap: 6px;
    }

    .timeout-btn {
        padding: 6px;
    }

    .timeout-icon {
        width: 20px;
        height: 20px;
    }

    .timeout-dot {
        width: 8px;
        height: 8px;
    }

    .undo-btn {
        width: 40px;
        height: 40px;
    }

    .undo-icon {
        width: 20px;
        height: 20px;
    }

    .swap-teams {
        width: 50px;
        height: 50px;
    }

    .swap-icon {
        width: 28px;
        height: 28px;
    }

    .serve-indicator {
        width: 70px;
        height: 36px;
    }

    .serve-ball {
        width: 26px;
        height: 26px;
    }

    .sets-score-center {
        gap: 4px;
    }

    .set-score-item {
        font-size: 0.95rem;
        padding: 4px 12px;
    }

    .point-timeline h3 {
        font-size: 1rem;
    }

    .timeline-container {
        padding: 10px;
    }

    .timeline-cell {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        margin: 0 1px;
    }

    .timeline-label {
        min-width: 20px;
    }

    .first-serve-icon {
        width: 14px;
        height: 14px;
    }

    .controls {
        flex-direction: column;
    }

    .controls .btn {
        width: 100%;
    }

    /* Modal adjustments */
    .modal-content {
        padding: 25px 20px;
        margin: 15px;
        max-width: calc(100vw - 30px);
    }

    .timer-display {
        width: 150px;
        height: 150px;
    }

    .timer-text {
        font-size: 2.5rem;
    }

    .sub-modal-content {
        min-width: unset;
        width: 100%;
    }

    .sub-option {
        width: 45px;
        height: 45px;
    }

    .credits {
        font-size: 0.7rem;
        bottom: 5px;
        right: 10px;
    }
}

@media (max-width: 360px) {
    h1 {
        font-size: 1.2rem;
    }

    .score {
        font-size: 3rem;
    }

    .rotation-pos {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .timeline-cell {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .available-player {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }

    .rotation-setup-pos {
        width: 42px;
        height: 42px;
        font-size: 0.75rem;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 5px 15px;
        padding-bottom: 30px;
    }

    h1 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .scoreboard {
        padding: 10px;
    }

    .match-info {
        padding: 5px 10px;
        margin-bottom: 10px;
        font-size: 0.75rem;
    }

    .current-set {
        flex-direction: row;
        gap: 8px;
        align-items: stretch;
    }

    .team {
        padding: 8px;
        flex: 1;
    }

    .team-name {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }

    .score {
        font-size: 2rem;
        margin-bottom: 5px;
    }

    .btn-score {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .vs-container {
        gap: 5px;
        min-width: 60px;
    }

    .undo-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .undo-icon {
        width: 16px;
        height: 16px;
    }

    .swap-teams {
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    .swap-icon {
        width: 22px;
        height: 22px;
    }

    .serve-indicator {
        width: 55px;
        height: 28px;
    }

    .serve-ball {
        width: 20px;
        height: 20px;
    }

    .sets-score-center {
        gap: 2px;
    }

    .set-score-item {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .vs {
        display: none;
    }

    .timeout-container {
        margin-bottom: 5px;
        gap: 4px;
    }

    .timeout-btn {
        padding: 4px;
    }

    .timeout-icon {
        width: 16px;
        height: 16px;
    }

    .timeout-dots {
        gap: 2px;
    }

    .timeout-dot {
        width: 6px;
        height: 6px;
    }

    .rotation-grid {
        padding: 4px;
        margin-bottom: 5px;
    }

    .rotation-row {
        gap: 4px;
        margin-bottom: 3px;
    }

    .rotation-pos {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    .rotation-pos .sub-indicator {
        width: 12px;
        height: 12px;
        font-size: 0.5rem;
    }

    .front-row {
        padding-bottom: 3px;
    }

    .point-timeline {
        margin-bottom: 8px;
    }

    .point-timeline h3 {
        font-size: 0.8rem;
        margin-bottom: 5px;
    }

    .timeline-container {
        padding: 6px;
    }

    .timeline-team {
        min-height: 24px;
    }

    .timeline-cell {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
        margin: 0 1px;
    }

    .timeline-label {
        min-width: 16px;
    }

    .first-serve-icon {
        width: 12px;
        height: 12px;
    }

    .controls {
        margin-top: 8px;
    }

    .controls .btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }

    .modal-content {
        padding: 12px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .timer-display {
        width: 80px;
        height: 80px;
        margin: 0 auto 10px;
    }

    .timer-text {
        font-size: 1.5rem;
    }

    .modal-content h2 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .modal .btn-primary {
        padding: 8px 20px;
        font-size: 0.85rem;
    }

    .credits {
        font-size: 0.6rem;
        bottom: 3px;
        right: 8px;
    }
}

/* Extra wide landscape (tablets in landscape) */
@media (min-width: 600px) and (max-height: 500px) and (orientation: landscape) {
    .current-set {
        max-width: 900px;
        margin: 0 auto;
    }

    .team {
        padding: 10px 15px;
    }

    .score {
        font-size: 2.5rem;
    }

    .rotation-pos {
        width: 30px;
        height: 30px;
        font-size: 0.7rem;
    }
}
