/**
 * HEMA Tournament System Styles
 * Modern, elegant design with gold accents
 */

/* ============================================
   BASE STYLES
   ============================================ */

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

:root {
    /* Colors */
    --primary-gold: #d4af37;
    --dark-gold: #b8941f;
    --dark-bg: #1a1a2e;
    --darker-bg: #0a0e27;
    --mid-bg: #2d2d44;
    --light-bg: #3d3d5c;
    --accent-cyan: #64ffda;
    --accent-purple: #667eea;
    --accent-green: #228b22;
    --accent-red: #eb3349;
    --text-light: #e8e8e8;
    --text-gray: #c0c0c0;
    --text-dark: #888;

    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 15px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-gold: 0 6px 20px rgba(212, 175, 55, 0.4);
}

body {
    font-family: 'Spectral', serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #16213e 100%);
    color: var(--text-light);
    min-height: 100vh;
    line-height: 1.6;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background: linear-gradient(135deg, var(--mid-bg) 0%, var(--dark-bg) 100%);
    border-bottom: 3px solid var(--primary-gold);
    padding: var(--spacing-lg) 0;
    box-shadow: var(--shadow-md);
}

.logo {
    font-family: 'Cinzel', serif;
    font-size: 32px;
    color: var(--primary-gold);
    margin: 0;
    font-weight: 700;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* ============================================
   BUTTONS
   ============================================ */

.button {
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--dark-gold) 100%);
    color: var(--dark-bg);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    margin: 5px;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-gold);
}

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

.button.secondary {
    background: linear-gradient(135deg, #4a4a4a 0%, #2d2d2d 100%);
    color: var(--primary-gold);
}

.button.secondary:hover {
    box-shadow: 0 6px 20px rgba(100, 100, 100, 0.4);
}

.button.danger {
    background: linear-gradient(135deg, var(--accent-red) 0%, #f45c43 100%);
    color: white;
}

.button.danger:hover {
    box-shadow: 0 6px 20px rgba(235, 51, 73, 0.4);
}

.btn-small {
    padding: 5px 15px;
    font-size: 14px;
    border-radius: 5px;
    border: none;
    background: var(--accent-cyan);
    color: var(--darker-bg);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 255, 218, 0.4);
}

.btn-primary-large, .btn-secondary-large, .btn-success-large {
    padding: 18px 36px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary-large {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary-large:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary-large {
    background: rgba(100, 255, 218, 0.1);
    color: var(--accent-cyan);
    border: 2px solid var(--accent-cyan);
}

.btn-secondary-large:hover {
    background: rgba(100, 255, 218, 0.2);
    transform: translateY(-3px);
}

.btn-success-large {
    background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 176, 155, 0.4);
}

.btn-success-large:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 176, 155, 0.6);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

.btn-text {
    background: transparent;
    color: var(--text-dark);
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s ease;
}

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

.btn-primary {
    background: var(--accent-purple);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(100, 255, 218, 0.1);
    color: var(--accent-cyan);
    border: 2px solid var(--accent-cyan);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

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

.btn-success {
    background: var(--accent-green);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

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

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

.button-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* ============================================
   TOURNAMENT INFO
   ============================================ */

.tournament-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: var(--spacing-xl) 0;
    padding: var(--spacing-lg);
    background: rgba(26, 26, 46, 0.6);
    border-radius: var(--radius-lg);
    border: 2px solid rgba(100, 255, 218, 0.3);
}

.tournament-info h1 {
    margin: 0;
    font-size: 32px;
    color: var(--primary-gold);
    font-family: 'Cinzel', serif;
}

.status-badge {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid;
    transition: all 0.3s ease;
}

.status-created {
    background: rgba(128, 128, 128, 0.15);
    color: #999;
    border-color: #666;
}

.status-groups {
    background: rgba(100, 255, 218, 0.15);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.status-playoff {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border-color: #ffd700;
}

.status-finished {
    background: rgba(34, 200, 34, 0.15);
    color: #22dd22;
    border-color: #22dd22;
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    gap: 0;
    margin: var(--spacing-xl) 0 0 0;
    border-bottom: 3px solid var(--primary-gold);
}

.tab {
    background: rgba(61, 61, 92, 0.5);
    color: var(--text-gray);
    border: none;
    padding: 15px 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    transition: all 0.3s ease;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.tab:hover {
    background: rgba(61, 61, 92, 0.8);
    color: var(--primary-gold);
}

.tab.active {
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--dark-gold) 100%);
    color: var(--dark-bg);
}

.tab-content {
    display: none;
    padding: var(--spacing-xl) 0;
}

.tab-content.active {
    display: block;
}

.tab-content h2 {
    color: var(--primary-gold);
    font-family: 'Cinzel', serif;
    font-size: 32px;
    margin-bottom: var(--spacing-lg);
}

/* ============================================
   PARTICIPANTS
   ============================================ */

.participants-count {
    font-size: 18px;
    margin-bottom: var(--spacing-lg);
    color: var(--text-gray);
}

.fighter-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.fighter-card {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--mid-bg) 100%);
    border: 2px solid #555;
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.fighter-card:hover {
    border-color: var(--primary-gold);
    transform: translateY(-5px);
    box-shadow: var(--shadow-gold);
}

.fighter-name {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-gold);
    margin-bottom: var(--spacing-sm);
}

.fighter-info {
    color: var(--text-gray);
    font-size: 14px;
    line-height: 1.6;
}

.fighter-details {
    font-size: 12px;
    color: var(--text-dark);
    margin-top: 4px;
}

.fighter-rating {
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
}

/* ============================================
   GROUPS
   ============================================ */

.groups-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.status-info {
    font-size: 14px;
    color: var(--text-dark);
}

/* Guide Panel */
.guide-panel {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.1) 0%, rgba(102, 126, 234, 0.1) 100%);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.guide-step {
    display: flex;
    gap: var(--spacing-lg);
    align-items: flex-start;
}

.step-number {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #764ba2 100%);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h3 {
    color: var(--accent-cyan);
    margin-bottom: var(--spacing-sm);
}

.step-content p {
    color: var(--text-gray);
    margin-bottom: var(--spacing-lg);
}

.step-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Auto Groups Options */
.auto-options-panel {
    background: rgba(26, 26, 46, 0.8);
    padding: 25px;
    border-radius: var(--radius-lg);
    margin-top: var(--spacing-lg);
    border: 2px solid rgba(100, 255, 218, 0.3);
}

.auto-options-panel h4 {
    color: var(--accent-cyan);
    margin-bottom: var(--spacing-lg);
}

.input-group {
    margin-bottom: var(--spacing-lg);
}

.input-group label {
    display: block;
    color: var(--text-gray);
    margin-bottom: 8px;
    font-weight: 600;
}

.input-group input {
    width: 100px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 16px;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.help-text {
    margin-top: 15px;
    color: var(--text-dark);
    font-size: 14px;
    font-style: italic;
}

.help-text-box {
    background: rgba(100, 255, 218, 0.05);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: var(--spacing-lg);
}

.help-text-box strong {
    color: var(--accent-cyan);
    display: block;
    margin-bottom: 10px;
}

.help-text-box ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-gray);
}

.help-text-box li {
    margin: 5px 0;
}

/* Groups Display */
.groups-actions {
    display: flex;
    gap: 15px;
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
}

.group-card {
    background: rgba(26, 26, 46, 0.8);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.group-card h3 {
    color: var(--accent-cyan);
    margin-bottom: 15px;
    font-size: 20px;
}

/* Group Controls */
.group-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.control-section {
    background: rgba(26, 26, 46, 0.6);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    border: 2px solid rgba(100, 255, 218, 0.3);
}

.control-section h3 {
    color: var(--accent-cyan);
    margin-bottom: 15px;
    font-size: 16px;
}

/* ============================================
   STANDINGS TABLE
   ============================================ */

.standings-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(26, 26, 46, 0.6);
    border-radius: 8px;
    overflow: hidden;
    margin: var(--spacing-lg) 0;
}

.standings-table thead {
    background: var(--primary-gold);
    color: var(--dark-bg);
}

.standings-table th,
.standings-table td {
    padding: 12px;
    text-align: center;
}

.standings-table th {
    font-weight: bold;
    font-size: 14px;
}

.standings-table tbody tr {
    border-bottom: 1px solid rgba(100, 255, 218, 0.1);
}

.standings-table tbody tr:hover {
    background: rgba(100, 255, 218, 0.05);
}

.standings-table tbody tr:nth-child(1),
.standings-table tbody tr:nth-child(2) {
    background: rgba(212, 175, 55, 0.1);
}

/* ============================================
   INLINE SCORE EDITOR (used in group matrix, playoff bracket, ring view)
   ============================================ */

.score-view {
    cursor: pointer;
}

.score-view.hidden {
    display: none;
}

.score-edit {
    display: none;
}

.score-edit.open {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.score-edit-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.score-edit-label {
    font-size: 13px;
    color: var(--text-dark, #c0c0c0);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-edit-actions {
    display: inline-flex;
    gap: 4px;
}

.score-input {
    width: 64px;
    padding: 8px 4px;
    text-align: center;
    border: 2px solid var(--primary-gold);
    border-radius: 6px;
    background: rgba(26, 26, 46, 0.9);
    color: var(--text-light, #e8e8e8);
    font-size: 22px;
    font-weight: bold;
}

.score-sep {
    color: #888;
    font-size: 18px;
}

.btn-tiny {
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-transform: none;
    letter-spacing: 0;
}

.score-save {
    background: var(--accent-green, #228b22);
    color: white;
}

.score-cancel {
    background: #555;
    color: #ddd;
}

/* Group matrix's edit form is a floating popover, not inline, since table cells are narrow */
.matrix-cell {
    position: relative;
}

.score-edit.matrix-score-edit.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    background: #1a1a2e;
    border: 2px solid var(--primary-gold);
    border-radius: 6px;
    padding: 10px;
    min-width: 170px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
}

.matrix-score-edit .score-edit-row {
    justify-content: space-between;
}

.matrix-score-edit .score-edit-label {
    max-width: 110px;
}

.matrix-score-edit .score-edit-actions {
    justify-content: flex-end;
}

/* ============================================
   GROUP ROUND-ROBIN MATRIX
   ============================================ */

.matrix-wrapper {
    overflow-x: auto;
    margin: var(--spacing-lg) 0;
}

.group-matrix {
    border-collapse: collapse;
    background: rgba(26, 26, 46, 0.6);
    border-radius: 8px;
    font-size: 13px;
    min-width: 100%;
}

.group-matrix th,
.group-matrix td {
    border: 1px solid rgba(100, 255, 218, 0.15);
    padding: 6px 8px;
    text-align: center;
    white-space: nowrap;
}

.group-matrix thead th {
    background: var(--primary-gold);
    color: var(--dark-bg);
    font-size: 12px;
}

.matrix-corner {
    background: var(--primary-gold);
}

.matrix-row-header {
    background: rgba(212, 175, 55, 0.15);
    color: var(--primary-gold);
    text-align: left;
    font-weight: bold;
}

.matrix-diagonal {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.03),
        rgba(255, 255, 255, 0.03) 4px,
        transparent 4px,
        transparent 8px
    );
}

.matrix-empty {
    background: rgba(255, 255, 255, 0.02);
}

.matrix-cell.matrix-pending {
    color: #555;
}

.matrix-result.win {
    background: rgba(34, 139, 34, 0.2);
    color: #90ee90;
    font-weight: bold;
}

.matrix-result.loss {
    background: rgba(139, 0, 0, 0.15);
    color: #ff6b6b;
}

.matrix-result.draw {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

.matrix-metric {
    color: var(--text-dark, #c0c0c0);
    font-weight: bold;
}

.matrix-metric.positive {
    color: #90ee90;
}

.matrix-metric.negative {
    color: #ff6b6b;
}

/* ============================================
   GROUP SCHEDULE (round-by-round bout order)
   ============================================ */

.group-schedule {
    margin-top: var(--spacing-lg);
}

.group-schedule h4 {
    color: var(--accent-cyan);
    margin-bottom: 15px;
    font-size: 16px;
}

.schedule-round {
    margin-bottom: 18px;
}

.schedule-round-title {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.schedule-match {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 15px;
    margin: 6px 0;
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid rgba(100, 255, 218, 0.2);
    border-radius: 8px;
}

.schedule-match.completed {
    opacity: 0.8;
    border-color: rgba(34, 139, 34, 0.4);
}

.schedule-match-number {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 13px;
    min-width: 22px;
}

.schedule-match-fighters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.schedule-match-fighters .winner {
    color: var(--primary-gold);
    font-weight: bold;
}

.schedule-match-fighter-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Always its own full-width row, regardless of how much space the fighter
   names above took up - otherwise the wrap point (and so the buttons'
   position) depends on name length and differs from bout to bout. */
.schedule-match-score {
    flex: 1 0 100%;
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.schedule-match-score .match-status {
    color: #888;
    font-size: 13px;
}

/* ============================================
   MATCHES
   ============================================ */

.match {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--mid-bg) 100%);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.match:hover {
    border-color: var(--primary-gold);
    transform: translateX(5px);
}

.match.completed {
    border-color: var(--accent-green);
}

.fighter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: rgba(26, 26, 46, 0.5);
    border-radius: 4px;
}

.fighter.winner {
    background: rgba(212, 175, 55, 0.2);
    border: 2px solid var(--primary-gold);
    font-weight: bold;
}

.fighter-score {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-gold);
    margin-left: 15px;
    font-family: 'Cinzel', serif;
}

.vs {
    text-align: center;
    color: var(--text-dark);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 5px 0;
}

/* Group Matches */
.group-matches {
    margin-top: var(--spacing-lg);
}

.group-matches h4 {
    color: var(--accent-cyan);
    margin-bottom: 15px;
    font-size: 16px;
}

.group-match {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin: 8px 0;
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid rgba(100, 255, 218, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.group-match:hover {
    background: rgba(26, 26, 46, 0.9);
    border-color: rgba(100, 255, 218, 0.5);
    transform: translateX(5px);
}

.group-match.completed {
    opacity: 0.8;
}

.group-match.pending {
    border-color: rgba(255, 215, 0, 0.3);
}

.match-fighters {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.match-fighters .vs {
    color: var(--text-dark);
    font-size: 12px;
    font-weight: bold;
}

.match-fighters .winner {
    color: var(--accent-cyan);
    font-weight: bold;
}

.match-score {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent-cyan);
    min-width: 60px;
    text-align: center;
}

.match-status {
    color: var(--text-dark);
    font-style: italic;
    font-size: 13px;
}

/* ============================================
   PLAYOFF BRACKET
   ============================================ */

.playoff-bracket {
    display: flex;
    gap: 60px;
    overflow-x: auto;
    padding: var(--spacing-xl) var(--spacing-lg);
    margin: var(--spacing-xl) 0;
    background: rgba(26, 26, 46, 0.3);
    border-radius: var(--radius-lg);
}

.playoff-swap-hint {
    text-align: center;
    color: var(--text-dark);
    font-size: 13px;
    margin-bottom: var(--spacing-md);
}

.playoff-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 280px;
}

.playoff-round-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-gold);
    text-align: center;
    margin-bottom: var(--spacing-xl);
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 10px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
}

.bracket-match {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--mid-bg) 100%);
    border: 3px solid #555;
    border-radius: var(--radius-md);
    padding: 12px;
    margin: var(--spacing-xl) 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.bracket-match:hover {
    border-color: var(--primary-gold);
    transform: scale(1.05);
    box-shadow: var(--shadow-gold);
}

.bracket-match.completed {
    border-color: var(--accent-green);
}

.third-place-title {
    font-size: 14px;
    margin-top: var(--spacing-xl);
    opacity: 0.8;
}

.bracket-match {
    position: relative;
}

.ring-badge {
    display: inline-block;
    background: rgba(100, 255, 218, 0.15);
    color: #64ffda;
    border: 1px solid #64ffda;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    margin-bottom: 6px;
}

.ring-badge:hover {
    background: rgba(100, 255, 218, 0.3);
}

.secretary-badge {
    display: inline-block;
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    border: 1px solid #d4af37;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    margin-bottom: 6px;
    margin-left: 6px;
}

.edit-fighter-btn {
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    color: #d4af37;
    border-radius: 4px;
    font-size: 10px;
    padding: 1px 4px;
    cursor: pointer;
    margin-left: 4px;
}

.edit-fighter-btn:hover {
    background: rgba(212, 175, 55, 0.4);
}

.edit-fighter-btn.active {
    background: #d4af37;
    color: #1a1a2e;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
}

.bracket-fighter.slot-selected {
    outline: 2px dashed #d4af37;
    outline-offset: 2px;
}

.group-match .ring-badge {
    margin-bottom: 0;
    margin-right: 8px;
}

.bracket-match.clickable {
    cursor: pointer;
}

.bracket-match.clickable:hover {
    background: rgba(26, 26, 46, 0.9);
    border-color: rgba(100, 255, 218, 0.5);
}

.bracket-match.bye {
    opacity: 0.5;
    cursor: default;
    border-style: dashed;
}

.bracket-match.bye:hover {
    transform: none;
    box-shadow: none;
}

.bracket-match.auto-complete {
    opacity: 0.8;
    border-style: dashed !important;
    position: relative;
}

.bracket-match.auto-complete::after {
    content: "⚡ AUTO";
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--accent-green);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
}

.bracket-fighter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin: 4px 0;
    background: rgba(26, 26, 46, 0.6);
    border-radius: 6px;
    border: 2px solid transparent;
}

.bracket-fighter.winner {
    background: rgba(212, 175, 55, 0.25);
    border: 2px solid var(--primary-gold);
    font-weight: bold;
}

.bracket-fighter.loser {
    opacity: 0.5;
}

.bracket-fighter.bye-fighter {
    background: rgba(34, 139, 34, 0.2);
    border: 2px solid var(--accent-green);
    font-weight: bold;
}

.bracket-fighter.ghost-fighter {
    opacity: 0.4;
    font-style: italic;
    background: rgba(139, 0, 0, 0.15);
    border: 2px dashed #8b0000;
}

.bracket-fighter-name {
    flex: 1;
    color: var(--text-light);
    font-size: 16px;
}

.bracket-fighter-score {
    font-size: 22px;
    font-weight: bold;
    color: var(--primary-gold);
    margin-left: 15px;
    font-family: 'Cinzel', serif;
}

/* Tournament Complete Banner */
.tournament-complete {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-xl);
    text-align: center;
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xl);
    font-size: 28px;
    font-weight: bold;
    animation: pulse 2s infinite;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--dark-bg);
    margin: 2% auto;
    padding: var(--spacing-xl);
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-lg);
    width: 80%;
    max-width: 1200px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.modal-content.large {
    width: 90%;
    max-width: 1400px;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(100, 255, 218, 0.3);
}

.modal-header h2 {
    margin: 0;
    color: var(--accent-cyan);
}

.modal-body {
    margin-bottom: var(--spacing-lg);
}

.modal-footer {
    border-top: 2px solid rgba(100, 255, 218, 0.3);
    padding-top: var(--spacing-lg);}

/* ============================================
   SHARED TOAST / ALERT / CONFIRM (js/dialogs.js)
   - replaces native alert()/confirm() everywhere so every browser looks
     the same and nothing blocks the tab.
   ============================================ */

.ui-toast-container {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.ui-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(90vw, 480px);
    background: var(--dark-bg);
    color: var(--text-light);
    border: 1px solid var(--rule, rgba(212, 175, 55, 0.3));
    border-left: 4px solid var(--accent-cyan);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow-md);
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ui-toast.ui-toast-in {
    opacity: 1;
    transform: translateY(0);
}

.ui-toast-success { border-left-color: var(--accent-green); }
.ui-toast-error { border-left-color: var(--accent-red); }
.ui-toast-info { border-left-color: var(--accent-cyan); }

.ui-toast-msg { flex: 1; white-space: pre-line; }

.ui-toast-close {
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.ui-toast-close:hover { color: var(--text-light); }

.ui-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.ui-modal-overlay.ui-modal-in { opacity: 1; }

.ui-modal {
    background: var(--dark-bg);
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-lg) var(--spacing-xl);
    max-width: min(90vw, 460px);
    transform: translateY(-16px);
    transition: transform 0.15s ease;
}
.ui-modal-overlay.ui-modal-in .ui-modal { transform: translateY(0); }

.ui-modal-danger { border-color: var(--accent-red); }
.ui-modal-error { border-color: var(--accent-red); }

.ui-modal-message {
    margin: 0 0 var(--spacing-lg);
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-line;
}

.ui-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================
   ADDITIONAL STYLES FOR IMPROVED GROUPS UI
   ============================================ */

/* Quick Actions Panel */
.quick-actions {
    background: rgba(100, 255, 218, 0.05);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.quick-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Fighter Card with Checkbox */
.fighter-card {
    position: relative;
    transition: all 0.2s ease;
}

.fighter-card.selected {
    background: rgba(100, 255, 218, 0.15) !important;
    border-color: var(--accent-cyan) !important;
    transform: translateX(5px);
}

.fighter-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-cyan);
}

/* Group Box Improvements */
.group-box {
    position: relative;
    min-height: 200px;
}

.group-box.drag-over {
    background: rgba(100, 255, 218, 0.1) !important;
    border-color: var(--accent-cyan) !important;
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.3);
}

.group-name-input {
    font-family: 'Cinzel', serif;
}

.group-name-input:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Group Fighter Card */
.group-fighter-card {
    transition: all 0.2s ease;
}

.group-fighter-card:hover {
    transform: translateX(5px);
    background: rgba(61, 61, 92, 0.8) !important;
}

.remove-fighter-btn {
    transition: all 0.2s ease;
}

.remove-fighter-btn:hover {
    background: #ff4444 !important;
    transform: scale(1.1);
}

/* Club Selection Details */
details summary {
    padding: 10px;
    background: rgba(26, 26, 46, 0.5);
    border-radius: 6px;
    transition: all 0.2s ease;
}

details summary:hover {
    background: rgba(26, 26, 46, 0.8);
    color: #ffd700;
}

details[open] summary {
    margin-bottom: 10px;
    border-bottom: 2px solid rgba(100, 255, 218, 0.3);
}

/* Modal Improvements */
.modal-content .fighters-pool {
    flex: 1;
    min-width: 350px;
}

.modal-content .groups-builder {
    flex: 1.5;
    min-width: 400px;
}

.pool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(100, 255, 218, 0.3);
}

.pool-header h3 {
    margin: 0;
    color: var(--accent-cyan);
}

.pool-header .badge {
    background: rgba(100, 255, 218, 0.2);
    color: var(--accent-cyan);
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
}

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

.groups-header h3 {
    margin: 0;
    color: var(--accent-cyan);
}

/* Validation Info */
.validation-info {
    flex: 1;
    font-size: 14px;
    font-weight: bold;
}

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

/* Empty State Improvements */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dark);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-gray);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-dark);
    font-style: italic;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .manual-groups-container {
        flex-direction: column;
    }

    .fighters-pool,
    .groups-builder {
        width: 100% !important;
        min-width: unset !important;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions button {
        width: 100%;
    }
}

/* Animation for adding fighters */
@keyframes fighter-added {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.group-fighter-card.just-added {
    animation: fighter-added 0.3s ease;
}

/* Loading State */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 100;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(100, 255, 218, 0.2);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   LIVE BOUT PANEL
   ============================================ */

.live-bout-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 39, 0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.live-bout-panel {
    background: linear-gradient(135deg, var(--mid-bg) 0%, var(--dark-bg) 100%);
    border: 2px solid var(--primary-gold);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 900px;
    height: 95vh;
    max-height: 95vh;
    overflow-y: auto;
}

@media (min-width: 700px) {
    .live-bout-timer {
        font-size: 88px;
    }

    .live-bout-timer-controls .button,
    .live-bout-exchange-form .btn-tiny,
    .live-bout-cards-row .btn-tiny {
        padding: 14px 22px;
        font-size: 16px;
    }

    .live-bout-points-input {
        width: 90px;
        padding: 10px;
        font-size: 20px;
    }
}

.live-bout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.live-bout-header h2 {
    font-size: 20px;
    color: var(--primary-gold);
}

.live-bout-vs {
    color: var(--text-dark);
    font-weight: normal;
    font-size: 14px;
}

.live-bout-round-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-gray);
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
}

.live-bout-rounds-won {
    color: var(--primary-gold);
    font-weight: bold;
}

.live-bout-timer {
    text-align: center;
    font-size: 56px;
    font-weight: bold;
    font-family: 'Cinzel', serif;
    color: var(--text-light);
    padding: var(--spacing-md) 0;
}

.live-bout-timer.running {
    color: var(--accent-green);
}

.live-bout-break {
    text-align: center;
    color: var(--accent-cyan);
    margin-bottom: var(--spacing-sm);
}

.live-bout-priority-banner {
    text-align: center;
    color: #1a1a2e;
    background: var(--primary-gold);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: var(--spacing-sm);
    font-weight: bold;
}

/* Marks the priority fighter's name wherever it shows up (header, exchange
   form, cards) - see nameOfMarked() in live-bout.js. */
.live-bout-priority-name {
    color: #1a1a2e;
    background: var(--primary-gold);
    border-radius: 4px;
    padding: 1px 6px;
    font-weight: bold;
}

.live-bout-timer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-bottom: var(--spacing-md);
}

.live-bout-exchange-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.live-bout-exchange-form.disabled {
    opacity: 0.5;
}

.live-bout-exchange-hint {
    color: var(--text-dark);
    font-size: 13px;
    font-style: italic;
    margin-bottom: var(--spacing-sm);
}

.live-bout-exchange-fighter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.live-bout-key-hint {
    color: var(--text-dark);
    font-size: 12px;
    align-self: center;
}

.live-bout-end-row {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-sm);
}

.button.danger.armed {
    animation: liveBoutArmedPulse 0.9s ease-in-out infinite;
}

@keyframes liveBoutArmedPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(235, 51, 73, 0.55); }
    50% { box-shadow: 0 0 0 8px rgba(235, 51, 73, 0); }
}

.live-bout-spectator-note {
    text-align: center;
    color: var(--text-dark);
    font-size: 13px;
    font-style: italic;
    margin-bottom: var(--spacing-md);
}

.live-bout-points-input {
    width: 60px;
    padding: 6px;
    text-align: center;
    border: 2px solid var(--primary-gold);
    border-radius: var(--radius-sm);
    background: rgba(26, 26, 46, 0.9);
    color: var(--text-light);
    font-weight: bold;
}

.live-bout-cards-row {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.live-bout-fighter-cards {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-tiny.card-yellow {
    background: #f4c430;
    color: #1a1a2e;
}

.btn-tiny.card-red {
    background: var(--accent-red);
    color: white;
}

.card-dot {
    display: inline-block;
    width: 12px;
    height: 16px;
    border-radius: 2px;
    margin-left: 4px;
}

.card-dot.card-yellow {
    background: #f4c430;
}

.card-dot.card-red {
    background: var(--accent-red);
}

.live-bout-current-score {
    text-align: center;
    color: var(--text-gray);
    margin-bottom: var(--spacing-md);
}

.live-bout-finished {
    text-align: center;
    font-size: 22px;
    color: var(--accent-green);
    padding: var(--spacing-md) 0;
}

.live-bout-editable-note {
    display: block;
    font-size: 13px;
    color: var(--text-dark);
    font-weight: normal;
    margin-top: 4px;
}

.live-bout-lock-override-warning {
    background: rgba(244, 196, 48, 0.15);
    border: 1px solid #f4c430;
    color: #f4c430;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: var(--spacing-sm);
}

.live-bout-status-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: var(--spacing-sm);
}

.live-bout-status-badge.synced {
    background: rgba(34, 139, 34, 0.12);
    border: 1px solid var(--accent-green);
    color: #6fcf6f;
}

.live-bout-status-badge.pending {
    background: rgba(244, 196, 48, 0.15);
    border: 1px solid #f4c430;
    color: #f4c430;
}

.live-bout-status-badge.error {
    background: rgba(235, 51, 73, 0.15);
    border: 1px solid var(--accent-red);
    color: #ff8a94;
}

.live-bout-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.live-bout-status-badge.pending .live-bout-status-dot {
    animation: live-badge-pulse 1.4s ease-in-out infinite;
}

.live-bout-pending-tag {
    color: #f4c430;
    font-style: italic;
    font-weight: normal;
}

.live-bout-history {
    margin-top: var(--spacing-lg);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding-top: var(--spacing-md);
}

.live-bout-history h4 {
    color: var(--primary-gold);
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.live-bout-history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-gray);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.live-bout-history-row.voided {
    opacity: 0.4;
    text-decoration: line-through;
}

.live-bout-history-empty {
    color: var(--text-dark);
    font-size: 13px;
    font-style: italic;
}

.bracket-live-row {
    margin-top: 6px;
    text-align: center;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(235, 51, 73, 0.15);
    border: 1px solid var(--accent-red);
    color: #ff8a94;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
}

.live-badge:hover {
    background: rgba(235, 51, 73, 0.3);
}

.live-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: live-badge-pulse 1.4s ease-in-out infinite;
}

.live-badge-time {
    color: var(--text-gray);
    font-weight: normal;
}

@keyframes live-badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.bout-settings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.secretary-assignment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
    padding: 8px 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.bout-settings-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 8px var(--spacing-sm);
}

.bout-settings-stage-name {
    min-width: 140px;
    color: var(--text-light);
    font-weight: bold;
}

.bout-settings-row label {
    color: var(--text-gray);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}