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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #111827, #1f2937);
    color: white;
    min-height: 100vh;
    padding: 20px;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    max-width: 400px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #666aff, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 6px 9px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.settings-view {
    display: none;
}

.management-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.management-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.management-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.management-item-name {
    flex: 1;
    color: #e5e7eb;
    font-size: 14px;
}

.management-item-date {
    color: #9ca3af;
    font-size: 12px;
    margin-right: 10px;
}

.delete-btn {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.add-item-form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.add-item-form input {
    flex: 1;
    margin-bottom: 0;
}

.add-btn {
    background: linear-gradient(45deg, #10b981, #059669);
    border: none;
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.history-btn {
    background: linear-gradient(45deg, #8b5cf6, #7c3aed);
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.header-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 15px;
}

.history-btn, .rankings-btn {
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 145px;
    height: 42px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
    padding: 0;
    margin: 0;
    vertical-align: top;
}

.history-btn {
    background: linear-gradient(45deg, #8b5cf6, #7c3aed);
}

.rankings-btn {
    background: linear-gradient(45deg, #f59e0b, #d97706);
}

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

.rankings-btn:hover {
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.rankings-view {
    display: none;
}

.rankings-view .section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rankings-view .section-title {
    font-size: 14px;
    margin-bottom: 8px;
    color: #e5e7eb;
}

.rankings-view .button-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.rankings-view .btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 50px;
}

.rankings-view .ranking-description {
    margin-top: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border-left: 2px solid #666aff;
}

.rankings-view .ranking-description div {
    color: #d1d5db;
    font-size: 11px;
    font-style: italic;
}

.rankings-container {
    max-height: 500px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.ranking-item.top-rank {
    background: linear-gradient(45deg, #fbbf24, #f59e0b);
    color: #1f2937;
    font-weight: bold;
}

.ranking-item.top-rank .ranking-stats {
    color: #1f2937;
}

.ranking-position {
    font-size: 18px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.ranking-info {
    flex: 1;
    margin-left: 15px;
}

.ranking-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.ranking-stats {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.ranking-score {
    font-size: 20px;
    font-weight: bold;
    color: #666aff;
    min-width: 60px;
    text-align: right;
}

.ranking-item.top-rank .ranking-score {
    color: #1f2937;
}

.trophy-icon {
    font-size: 24px;
    margin-right: 10px;
}

.section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: #e5e7eb;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

select {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(31, 41, 55, 0.8);
    color: white;
    font-size: 16px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

select option {
    background: #1f2937;
    color: white;
    padding: 10px;
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 60px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn.active {
    background: linear-gradient(45deg, #666aff, #ff6b9d);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102, 106, 255, 0.3);
}

.tournament-description {
    margin-top: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid #666aff;
}

.tournament-description div {
    color: #d1d5db;
    font-size: 14px;
    font-style: italic;
    line-height: 1.4;
}

.player-input {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.player-input input {
    margin-bottom: 0;
}

.player-name-dropdown {
    position: relative;
    flex: 1;
    margin-bottom: 8px;
}

.name-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.name-suggestion {
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s ease;
}

.name-suggestion:hover {
    background: rgba(255, 255, 255, 0.1);
}

.name-suggestion:last-child {
    border-bottom: none;
}

.player-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.add-player-btn {
    background: linear-gradient(45deg, #10b981, #059669);
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    flex: 1;
}

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

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

.remove-player-btn {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    flex: 1;
}

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

.primary-btn {
    width: 100%;
    background: linear-gradient(45deg, #666aff, #ff6b9d);
    padding: 18px;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(102, 106, 255, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 106, 255, 0.4);
}

.tournament-view, .history-view {
    display: none;
}

.back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 16px;
}

.tournament-info {
    text-align: center;
    margin-bottom: 30px;
}

.tournament-info h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.tournament-info p {
    color: #9ca3af;
    margin-bottom: 5px;
}

.round-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.round-tab {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.round-tab.active {
    background: linear-gradient(45deg, #666aff, #ff6b9d);
}

.match {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 25px 20px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    touch-action: manipulation;
}

.team {
    flex: 1;
    text-align: center;
}

.team-name {
    font-size: 14px;
    margin-bottom: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.2;
}

.score-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.score-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.score-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.score {
    font-size: 24px;
    font-weight: bold;
    min-width: 40px;
}

.vs {
    color: #9ca3af;
    font-weight: 500;
}

.end-round-btn {
    background: linear-gradient(45deg, #f59e0b, #d97706);
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    font-size: 16px;
}

.hidden {
    display: none;
}

.results-view {
    display: none;
}

.results-table {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.results-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.results-row:last-child {
    border-bottom: none;
}

.winner {
    background: linear-gradient(45deg, #10b981, #059669);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    margin-left: 10px;
}

.download-btn {
    background: linear-gradient(45deg, #8b5cf6, #7c3aed);
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    margin: 10px 0;
    width: 100%;
    font-size: 16px;
}

.save-btn {
    background: linear-gradient(45deg, #10b981, #059669);
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    margin: 10px 0;
    width: 100%;
    font-size: 16px;
    transition: all 0.3s ease;
}

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

.save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.history-container {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #e5e7eb;
}

.history-item-date {
    font-size: 12px;
    color: #9ca3af;
}

.history-item-details {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: #d1d5db;
}

.history-item-detail {
    display: flex;
    align-items: center;
    gap: 5px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, #1f2937, #374151);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: white;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
}

.tournament-details {
    margin-bottom: 20px;
}

.tournament-details p {
    margin: 8px 0;
    color: #d1d5db;
}

.tournament-details strong {
    color: #e5e7eb;
}

.final-standings h4 {
    color: #e5e7eb;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.standing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: #d1d5db;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.standing-item:last-child {
    border-bottom: none;
}

.tournament-management-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.tournament-management-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tournament-info-left {
    flex: 1;
}

.tournament-name {
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.tournament-details {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #9ca3af;
}

.tournament-date {
    color: #9ca3af;
    font-size: 12px;
    margin-right: 10px;
}

.danger-zone {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(239, 68, 68, 0.3);
}

.danger-btn {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 100%;
}

.pin-input-container {
    margin: 20px 0;
}

.pin-input-container input {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    font-family: monospace;
    letter-spacing: 2px;
}

.pin-input-container input::placeholder {
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: normal;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-primary {
    background: linear-gradient(45deg, #666aff, #ff6b9d);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-link {
    background: none;
    border: none;
    color: #666aff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    margin-top: 15px;
    transition: color 0.3s ease;
}

.btn-link:hover {
    color: #ff6b9d;
}

.pin-options {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.security-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.security-info p {
    margin: 0;
    color: #d1d5db;
    font-size: 14px;
}

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

/* Add this to your styles.css file */

.tournament-filter-description {
    margin-top: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border-left: 2px solid #666aff;
}

.tournament-filter-description div {
    color: #d1d5db;
    font-size: 11px;
    font-style: italic;
}

.rankings-header-info {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid #666aff;
}

.rankings-filter-info {
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 500;
}

.rankings-filter-info span {
    display: block;
    text-align: center;
}
