/* match_detail.css — รวม CSS ที่เคยฝังในไฟล์ match_detail.php */
/* สร้างจากการ refactor; ลำดับเหมือนเดิม */


/* ==== Block 1: original lines 653-3724 ==== */
        body {
            margin: 0;
            font-family: 'Outfit', 'Kanit', sans-serif;
            background-color: var(--bg-page);
            color: var(--text-main);
            padding-top: 72px;
        }

        .container {
            max-width: 1250px;
            margin: 40px auto;
            background: var(--bg-card);
            padding: 35px;
            border-radius: 24px;
            box-shadow: var(--shadow-md);
            border: 1px solid var(--glass-border);
        }

        /* Navbar */
        .navbar {
            background: var(--navbar-bg);
            backdrop-filter: blur(20px);
            padding: 14px 6%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 2000;
            border-bottom: 1px solid var(--glass-border);
        }

        .logo {
            font-size: 22px;
            font-weight: 900;
            color: var(--text-main);
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .logo .logo-mark {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            background: linear-gradient(135deg, var(--primary), #ff4d4d);
            color: #fff;
            display: grid;
            place-items: center;
            font-weight: 900;
            font-size: 18px;
            box-shadow: 0 6px 14px rgba(230, 0, 0, 0.35);
        }

        .logo span.accent {
            color: var(--primary);
        }

        .nav-links {
            list-style: none;
            margin: 0;
            padding: 0;
            display: flex;
            gap: 28px;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }

        .nav-links a {
            color: var(--text-dim);
            text-decoration: none;
            font-size: 14px;
            font-weight: 700;
            transition: 0.3s;
            position: relative;
            letter-spacing: 0.3px;
        }

        .nav-links a:hover,
        .nav-links a.active {
            color: var(--primary);
        }

        .nav-links a.active::after {
            content: '';
            position: absolute;
            bottom: -8px;
            left: 50%;
            transform: translateX(-50%);
            width: 20px;
            height: 3px;
            border-radius: 2px;
            background: var(--primary);
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .btn-auth {
            padding: 10px 15px;
            border-radius: 10px;
            text-decoration: none;
            font-weight: 700;
            font-size: 13px;
            color: var(--text-main);
            border: 1px solid var(--glass-border);
            background: var(--bg-card);
        }

        .btn-auth:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        /* Admin Dropdown */
        .nav-item-dropdown {
            position: relative;
            display: inline-block;
        }

        .dropdown-trigger {
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            color: var(--text-dim) !important;
        }

        .dropdown-trigger:hover {
            color: var(--primary) !important;
        }

        .dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            background: var(--bg-card);
            min-width: 220px;
            border-radius: 16px;
            box-shadow: var(--shadow-md);
            border: 1px solid var(--glass-border);
            padding: 12px 0;
            display: none;
            z-index: 3000;
            margin-top: 10px;
            animation: fadeInUp 0.3s ease;
        }

        /* สะพานเชื่อมล่องหนอุดช่องโหว่ระหว่างปุ่มกับเมนู 10px */
        .dropdown-menu::after {
            content: '';
            position: absolute;
            top: -15px;
            left: 0;
            width: 100%;
            height: 15px;
            background: transparent;
        }

        .dropdown-menu::before {
            content: '';
            position: absolute;
            top: -6px;
            right: 20px;
            width: 12px;
            height: 12px;
            background: var(--bg-card);
            border-left: 1px solid var(--glass-border);
            border-top: 1px solid var(--glass-border);
            transform: rotate(45deg);
        }

        .nav-item-dropdown:hover .dropdown-menu {
            display: block;
        }

        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 20px;
            color: var(--text-main);
            text-decoration: none;
            font-size: 14px;
            font-weight: 600;
            transition: 0.2s;
        }

        .dropdown-item:hover {
            background: var(--primary-soft);
            color: var(--primary);
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Basic mobile resets — detailed overrides are in the comprehensive mobile block below */

        .header-box {
            padding-bottom: 20px;
            margin-bottom: 25px;
            position: relative;
            border-bottom: 2px solid var(--glass-border);
        }

        .header-box h2 {
            font-size: 28px;
            font-weight: 800;
            color: var(--text-main);
            letter-spacing: -0.5px;
        }

        .header-box p {
            font-size: 15px;
            color: var(--text-dim);
            line-height: 1.8;
        }

        .admin-action-group {
            position: absolute;
            top: 0;
            right: 0;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .btn-edit-admin {
            background: #ffc107;
            color: #333;
            padding: 10px 20px;
            text-decoration: none;
            font-weight: 700;
            border-radius: 12px;
            border: none;
            cursor: pointer;
            font-size: 13px;
            transition: 0.3s;
        }

        .btn-edit-admin:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(255, 193, 7, 0.3);
        }

        .btn-add-result {
            background: var(--text-main);
            color: var(--bg-card);
            padding: 10px 20px;
            text-decoration: none;
            font-weight: 700;
            border-radius: 12px;
            font-size: 13px;
            transition: 0.3s;
        }

        .btn-add-result:hover {
            transform: translateY(-2px);
        }

        .btn-live-score {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: white;
            padding: 10px 20px;
            text-decoration: none;
            font-weight: 700;
            border-radius: 12px;
            font-size: 13px;
            animation: pulse 1.5s infinite;
            box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
            transition: 0.3s;
        }

        /* Live entrance shown inline next to the status badge when กำลังแข่งขัน */
        .btn-live-entry {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            margin-left: 8px;
            vertical-align: middle;
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: #fff !important;
            padding: 5px 14px;
            border-radius: 10px;
            font-weight: 800;
            font-size: 12px;
            text-decoration: none;
            box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .btn-live-entry:hover {
            transform: translateY(-1px);
            box-shadow: 0 8px 16px rgba(220, 38, 38, 0.4);
        }

        .btn-live-entry .live-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: #fff;
            animation: blink 1s infinite;
            flex: 0 0 auto;
        }

        @keyframes pulse {
            0% {
                transform: scale(1);
            }

            50% {
                transform: scale(1.05);
            }

            100% {
                transform: scale(1);
            }
        }

        /* Info + registration side-by-side inside one card */
        .info-split {
            display: grid;
            grid-template-columns: minmax(0, 1fr) 320px;
            gap: 28px;
            align-items: start;
        }

        .info-split-left {
            min-width: 0;
        }

        .info-split-right {
            position: sticky;
            top: 90px;
        }

        .register-card {
            background: linear-gradient(135deg, rgba(34, 197, 94, 0.06), rgba(16, 163, 74, 0.03));
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 22px;
            text-align: center;
        }

        .register-card .btn-register-cta,
        .register-card .btn-login-cta {
            display: flex;
            width: 100%;
            padding: 14px 18px;
            font-size: 15px;
            box-sizing: border-box;
        }

        .register-card {
            box-sizing: border-box;
            max-width: 100%;
        }

        /* Registration CTA Button */
        .btn-register-cta {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: white !important;
            text-decoration: none;
            padding: 18px 36px;
            font-size: 18px;
            font-weight: 800;
            border-radius: 16px;
            box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3);
            transition: all 0.3s ease;
            border: none;
            animation: pulse-green 2s infinite;
        }

        .btn-register-cta:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 30px rgba(34, 197, 94, 0.4);
        }

        /* Login CTA */
        .btn-login-cta {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background: linear-gradient(135deg, var(--primary), #b91c1c);
            color: white !important;
            text-decoration: none;
            padding: 16px 32px;
            font-size: 17px;
            font-weight: 800;
            border-radius: 16px;
            box-shadow: 0 8px 25px rgba(230, 0, 0, 0.2);
            transition: all 0.3s ease;
        }

        .btn-login-cta:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 30px rgba(230, 0, 0, 0.3);
        }

        @keyframes pulse-green {
            0% {
                box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
            }

            70% {
                box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
            }

            100% {
                box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
            }
        }

        /* Tab Menu - Pill Style */
        .tab-menu {
            display: flex;
            gap: 5px;
            margin-bottom: 25px;
            overflow-x: auto;
            white-space: nowrap;
            flex-wrap: nowrap;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            background: var(--bg-page);
            padding: 6px;
            border-radius: 16px;
            border: 1px solid var(--glass-border);
        }

        .tab-menu::-webkit-scrollbar {
            display: none;
        }

        .tab-btn {
            background: none;
            border: none;
            padding: 12px 18px;
            font-size: 14px;
            font-weight: 700;
            color: var(--text-dim);
            cursor: pointer;
            border-radius: 12px;
            flex-shrink: 0;
            transition: 0.3s;
        }

        .tab-btn:hover {
            color: var(--primary);
            background: var(--primary-soft);
        }

        .tab-btn.active {
            color: white;
            background: var(--primary);
            box-shadow: 0 4px 12px rgba(230, 0, 0, 0.2);
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
            animation: fadeIn 0.3s;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(5px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Category Pills */
        .cat-menu {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        .cat-btn {
            background: var(--bg-page);
            border: 1px solid var(--glass-border);
            padding: 10px 20px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
            transition: 0.3s;
            color: var(--text-dim);
            font-size: 14px;
        }

        .cat-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .cat-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
            box-shadow: 0 4px 12px rgba(230, 0, 0, 0.2);
        }

        .cat-count {
            color: var(--primary);
            margin-left: 4px;
            transition: color 0.3s;
        }

        .cat-btn.active .cat-count {
            color: white;
        }

        /* Category Dropdown (when more than 6 items) */
        .cat-menu.cat-menu-dropdown {
            display: block;
        }

        .cat-menu.cat-menu-dropdown .cat-btn {
            display: none;
        }

        .cat-select-wrap {
            position: relative;
            display: inline-block;
            max-width: 260px;
            width: auto;
        }

        .cat-select-wrap::after {
            content: '▾';
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            pointer-events: none;
            color: var(--primary);
            font-size: 12px;
        }

        .cat-select {
            width: 100%;
            padding: 7px 30px 7px 14px;
            border-radius: 10px;
            background: white;
            color: var(--primary);
            border: 2px solid var(--primary);
            font-weight: 700;
            font-size: 13px;
            cursor: pointer;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            box-shadow: 0 2px 6px rgba(230, 0, 0, 0.10);
            font-family: inherit;
        }

        .cat-select:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(230, 0, 0, 0.25);
        }

        .cat-select option {
            background: white;
            color: var(--text-main);
            font-weight: 600;
        }

        .sub-content {
            display: none;
            animation: fadeIn 0.3s;
        }

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

        /* Bracket Type Pills */
        .bracket-menu {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
            background: var(--bg-page);
            padding: 10px 15px;
            border-radius: 16px;
            border: 1px solid var(--glass-border);
        }

        .bracket-btn {
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            padding: 8px 18px;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
            transition: 0.3s;
            color: var(--text-dim);
            font-size: 13px;
        }

        .bracket-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .bracket-btn.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
            box-shadow: 0 4px 12px rgba(230, 0, 0, 0.2);
        }

        /* View Toggle */
        .view-toggle-container {
            display: flex;
            gap: 0;
        }

        .view-btn {
            background: var(--bg-page);
            border: 1px solid var(--glass-border);
            padding: 10px 18px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 700;
            color: var(--text-dim);
            transition: 0.3s;
        }

        .view-btn.active {
            background: var(--text-main);
            color: var(--bg-card);
            border-color: var(--text-main);
        }

        .view-btn:first-child {
            border-top-left-radius: 12px;
            border-bottom-left-radius: 12px;
            border-right: none;
        }

        .view-btn:last-child {
            border-top-right-radius: 12px;
            border-bottom-right-radius: 12px;
            border-left: none;
        }

        /* Live Courts Panel */
        .order-day-row {
            display: flex;
            align-items: center;
            gap: 14px;
            margin-bottom: 14px;
            flex-wrap: wrap;
        }

        .order-day-row .order-day-tabs {
            margin-bottom: 0;
            flex-shrink: 0;
        }

        .live-courts-area {
            flex: 0 1 auto;
            margin-left: auto;
            min-width: 0;
            position: relative;
        }

        .live-courts-panel .live-courts-grid {
            justify-content: flex-end;
        }

        .live-courts-panel {
            display: none;
        }

        .live-courts-panel.active {
            display: block;
        }

        .live-courts-panel[data-empty="1"] {
            display: none !important;
        }

        .live-courts-panel {
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            padding: 6px 8px;
            box-shadow: var(--shadow-sm);
            box-sizing: border-box;
        }

        .live-courts-header {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 4px;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.6px;
            text-transform: uppercase;
            color: var(--text-dim);
        }

        .live-courts-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--primary);
            box-shadow: 0 0 0 0 rgba(230, 0, 0, 0.55);
            animation: lc-pulse 1.6s ease-in-out infinite;
        }

        @keyframes lc-pulse {
            0% {
                box-shadow: 0 0 0 0 rgba(230, 0, 0, 0.55);
            }

            70% {
                box-shadow: 0 0 0 6px rgba(230, 0, 0, 0);
            }

            100% {
                box-shadow: 0 0 0 0 rgba(230, 0, 0, 0);
            }
        }

        .live-courts-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            justify-content: flex-end;
        }

        .live-court-card {
            min-width: 78px;
        }

        .live-court-card {
            position: relative;
            background: var(--bg-page);
            border: 1px solid var(--glass-border);
            border-radius: 7px;
            padding: 4px 6px 5px;
            text-align: center;
            transition: 0.2s;
            line-height: 1;
        }

        .live-court-card.is-live {
            border-color: rgba(230, 0, 0, 0.45);
            background: var(--primary-soft, rgba(230, 0, 0, 0.05));
        }

        .live-court-card.is-finished {
            opacity: 0.7;
        }

        .lc-court-label {
            font-size: 9px;
            font-weight: 700;
            color: var(--text-dim);
            margin-bottom: 1px;
        }

        .lc-match-no {
            font-size: 17px;
            font-weight: 800;
            line-height: 1;
            letter-spacing: -0.5px;
            color: var(--text-main);
            margin: 0;
        }

        .live-court-card.is-live .lc-match-no {
            color: var(--primary);
        }

        .lc-status {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            font-size: 9px;
            font-weight: 700;
            color: var(--text-dim);
            letter-spacing: 0.2px;
        }

        .lc-status-dot {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: #94a3b8;
        }

        .live-court-card.is-live .lc-status {
            color: var(--primary);
        }

        .live-court-card.is-live .lc-status-dot {
            background: var(--primary);
            animation: lc-pulse 1.6s ease-in-out infinite;
        }

        @media (max-width: 768px) {
            .live-courts-area {
                flex: 1 1 100%;
                margin-left: 0;
                width: 100%;
            }

            .live-courts-panel .live-courts-grid,
            .live-courts-grid {
                justify-content: stretch;
            }

            .live-courts-grid .live-court-card {
                flex: 1 1 0;
                min-width: 70px;
            }
        }

        @media (max-width: 600px) {
            .live-courts-grid {
                gap: 5px;
            }

            .lc-match-no {
                font-size: 18px;
            }

            .live-court-card {
                padding: 6px 5px 5px;
                min-width: 60px;
            }
        }

        .view-mode-list {
            display: none;
        }

        .view-mode-grid {
            display: none;
        }

        .view-mode-list.active {
            display: block;
            animation: fadeIn 0.3s;
        }

        .view-mode-grid.active {
            display: grid !important;
            grid-template-columns: repeat(3, 1fr) !important;
            gap: 20px;
            animation: fadeIn 0.3s;
        }

        @media (max-width: 900px) {
            .view-mode-grid.active {
                grid-template-columns: repeat(2, 1fr) !important;
            }
        }

        @media (max-width: 600px) {
            .view-mode-grid.active {
                grid-template-columns: 1fr !important;
            }
        }

        /* Tables */
        .table-responsive {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin-bottom: 15px;
            border-radius: 16px;
            border: 1px solid var(--glass-border);
        }

        .order-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
            background: var(--bg-card);
            overflow: hidden;
            min-width: 800px;
        }

        .order-table th,
        .order-table td {
            padding: 12px 10px;
            text-align: center;
            border-bottom: 1px solid var(--glass-border);
        }

        .order-table th {
            background: var(--bg-page) !important;
            color: var(--text-dim) !important;
            font-weight: 700;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .team-win-text {
            color: #16a34a !important;
            font-weight: 800;
        }

        .court-badge {
            background-color: var(--primary);
            color: white;
            padding: 5px 12px;
            border-radius: 8px;
            font-weight: 700;
            font-size: 12px;
            box-shadow: 0 2px 6px rgba(230, 0, 0, 0.2);
            display: inline-block;
        }

        /* === Editing Presence Indicator === */
        .editing-highlight {
            outline: 2px solid #e60000 !important;
            outline-offset: -1px;
            background: rgba(230, 0, 0, 0.06) !important;
            transition: outline 0.3s, background 0.3s;
            animation: presence-pulse 1.5s ease-in-out infinite;
        }

        @keyframes presence-pulse {

            0%,
            100% {
                outline-color: #e60000;
            }

            50% {
                outline-color: rgba(230, 0, 0, 0.3);
            }
        }

        /* Grid Cards */
        .grid-card {
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            box-shadow: var(--shadow-sm);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            transition: 0.3s;
        }

        .grid-card:hover {
            border-color: rgba(230, 0, 0, 0.2);
            box-shadow: var(--shadow-md);
            transform: translateY(-3px);
        }

        /* On-court highlight — red border for matches assigned to a court */
        .grid-card.on-court,
        .m-match-card.on-court {
            border: 2px solid #e60000 !important;
            box-shadow: 0 4px 14px rgba(230, 0, 0, 0.18) !important;
        }

        .grid-header-dark {
            background: var(--text-main);
            color: var(--bg-card);
            padding: 12px 15px;
            font-size: 12px;
            font-weight: 700;
            display: flex;
            justify-content: space-between;
            align-items: center;
            letter-spacing: 0.5px;
        }

        .grid-header-sub {
            background: var(--bg-page);
            font-size: 11px;
            padding: 8px 15px;
            color: var(--text-dim);
            border-bottom: 1px solid var(--glass-border);
            display: flex;
            align-items: center;
            font-weight: 700;
        }

        .grid-body {
            display: flex;
            flex-direction: column;
            flex: 1;
            padding: 5px 0;
        }

        .grid-team-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 15px;
            border-bottom: 1px solid var(--glass-border);
            flex: 1;
        }

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

        .grid-team-info {
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1;
            padding-right: 10px;
            overflow: hidden;
        }

        .g-t-name {
            font-weight: 700;
            font-size: 13px;
            color: var(--text-main);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .g-p-name {
            font-size: 11px;
            color: var(--text-dim);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .grid-scores {
            display: flex;
            gap: 4px;
            flex-shrink: 0;
        }

        .grid-box {
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-page);
            border-radius: 6px;
            font-size: 12px;
            font-weight: 800;
            color: var(--text-dim);
            border: 1px solid var(--glass-border);
        }

        .grid-box.set-winner {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .grid-winner {
            background-color: rgba(34, 197, 94, 0.06);
        }

        .grid-winner .g-t-name {
            color: #16a34a;
        }

        /* Group Tables */
        .group-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
            background: var(--bg-card);
            overflow: hidden;
            min-width: 800px;
        }

        .group-table th,
        .group-table td {
            padding: 12px;
            text-align: center;
            border-bottom: 1px solid var(--glass-border);
        }

        .group-table th {
            background: var(--bg-page);
            color: var(--text-dim);
            font-weight: 700;
            text-transform: uppercase;
            font-size: 11px;
            letter-spacing: 0.5px;
        }

        .group-box {
            border: 1px solid var(--glass-border);
            border-radius: 20px;
            overflow: hidden;
            margin-bottom: 25px;
            box-shadow: var(--shadow-sm);
        }

        .group-header {
            background: linear-gradient(135deg, #0f172a, #1e293b);
            color: white;
            padding: 14px 20px;
            font-weight: 800;
            font-size: 17px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        /* Bracket / Knockout */
        .bracket-dots {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin: 0 0 14px 0;
            padding: 0;
        }

        .bracket-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #cbd5e1;
            cursor: pointer;
            transition: transform 0.2s, background 0.2s;
            border: none;
            padding: 0;
        }

        .bracket-dot:hover {
            background: #94a3b8;
        }

        .bracket-dot.active {
            background: #1a1a1a;
            transform: scale(1.4);
        }

        .bracket-container {
            display: flex;
            overflow-x: auto;
            padding: 30px 40px;
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 20px;
            margin-bottom: 30px;
            box-shadow: var(--shadow-sm);
            scroll-behavior: smooth;
        }

        .bracket-round {
            display: flex;
            flex-direction: column;
            min-width: 270px;
            margin-right: 40px;
        }

        .bracket-round:last-child {
            margin-right: 0;
        }

        .round-title {
            text-align: center;
            font-weight: 800;
            background: linear-gradient(135deg, #0f172a, #334155);
            color: white;
            padding: 10px;
            border-radius: 12px;
            margin-bottom: 20px;
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .matches-list {
            display: flex;
            flex-direction: column;
            flex: 1;
            justify-content: space-around;
        }

        .match-pair {
            position: relative;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            flex: 1;
            min-height: 120px;
        }

        .match-wrapper {
            position: relative;
            padding: 15px 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        /* Original U-shape ::after disabled; replaced with .ko-arm-top + .ko-arm-bottom for per-arm highlighting */
        .bracket-round:not(:last-child) .match-pair:not(.single-match)::after {
            content: none;
        }

        .bracket-round:not(:last-child) .match-pair.single-match .match-wrapper::after {
            content: '';
            position: absolute;
            right: -20px;
            top: 50%;
            width: 20px;
            border-top: 2px solid #cbd5e1;
        }

        .bracket-round:not(:first-child) .match-wrapper::before {
            content: '';
            position: absolute;
            left: -20px;
            top: 50%;
            width: 20px;
            border-top: 2px solid #cbd5e1;
        }

        .ko-card {
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            box-shadow: var(--shadow-sm);
            overflow: hidden;
            position: relative;
            z-index: 2;
            transition: 0.3s;
        }

        .ko-card:hover {
            border-color: rgba(230, 0, 0, 0.2);
            box-shadow: var(--shadow-md);
        }

        .ko-header {
            background: var(--bg-page);
            font-size: 11px;
            padding: 8px 12px;
            color: var(--text-dim);
            border-bottom: 1px solid var(--glass-border);
            display: flex;
            justify-content: space-between;
            font-weight: 700;
        }

        .ko-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            border-bottom: 1px solid var(--glass-border);
        }

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

        .ko-info {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .ko-tname {
            font-weight: 700;
            font-size: 13px;
            color: var(--text-main);
        }

        .ko-pname {
            font-size: 11px;
            color: var(--text-dim);
        }

        .ko-score {
            font-size: 16px;
            font-weight: 800;
            color: var(--text-dim);
            width: 30px;
            text-align: right;
        }

        .ko-winner {
            background-color: rgba(34, 197, 94, 0.06);
        }

        .ko-winner .ko-tname,
        .ko-winner .ko-score {
            color: #16a34a;
        }

        .admin-score {
            background: rgba(255, 249, 196, 0.5);
            color: #665c00;
            font-size: 11px;
            padding: 6px;
            text-align: center;
            font-weight: 700;
            border-top: 1px dashed #ffeeba;
        }

        .status-select {
            padding: 8px 12px;
            font-size: 13px;
            border-radius: 10px;
            font-weight: 700;
            border: 1px solid var(--glass-border);
            cursor: pointer;
            outline: none;
            background: var(--bg-card);
            color: var(--text-main);
        }

        .edit-input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            font-size: 13px;
            font-family: 'Outfit', 'Kanit', sans-serif;
            background: var(--bg-card);
            color: var(--text-main);
        }

        #live-toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .live-toast {
            background: var(--bg-card);
            color: var(--text-main);
            padding: 15px 20px;
            border-radius: 16px;
            box-shadow: var(--shadow-md);
            border-left: 5px solid var(--primary);
            animation: slideIn 0.5s ease-out;
            min-width: 260px;
            font-family: 'Outfit', 'Kanit', sans-serif;
        }

        /* Back Link */
        .back-link {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: var(--text-dim);
            text-decoration: none;
            font-weight: 700;
            font-size: 14px;
            transition: 0.3s;
            padding: 8px 0;
        }

        .back-link:hover {
            color: var(--primary);
        }

        /* === Photo Tab Styles === */
        .photo-consent-box {
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 20px 25px;
            margin-bottom: 20px;
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }

        .photo-consent-box input[type=checkbox] {
            width: 20px;
            height: 20px;
            margin-top: 3px;
            accent-color: var(--primary);
            cursor: pointer;
            flex-shrink: 0;
        }

        .photo-consent-box label {
            font-size: 14px;
            color: var(--text-main);
            cursor: pointer;
            line-height: 1.6;
        }

        .photo-consent-box a {
            color: var(--primary);
            text-decoration: underline;
            font-weight: 700;
        }

        .photo-consent-box a:hover {
            opacity: 0.8;
        }

        .photo-upload-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            padding: 16px;
            background: var(--bg-page);
            color: var(--text-dim);
            border: 2px dashed var(--glass-border);
            border-radius: 16px;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            transition: 0.3s;
            font-family: 'Outfit', 'Kanit', sans-serif;
        }

        .photo-upload-btn:hover:not(:disabled) {
            border-color: var(--primary);
            color: var(--primary);
            background: var(--primary-soft);
        }

        .photo-upload-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .photo-upload-btn.active-upload {
            border-color: var(--primary);
            color: var(--primary);
            background: var(--primary-soft);
        }

        .photo-admin-toggle {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--bg-page);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 16px 20px;
            margin-bottom: 20px;
        }

        .toggle-switch {
            position: relative;
            width: 52px;
            height: 28px;
            flex-shrink: 0;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: var(--glass-border);
            transition: 0.3s;
            border-radius: 28px;
        }

        .toggle-slider:before {
            position: absolute;
            content: '';
            height: 22px;
            width: 22px;
            left: 3px;
            bottom: 3px;
            background: white;
            transition: 0.3s;
            border-radius: 50%;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
        }

        .toggle-switch input:checked+.toggle-slider {
            background: #22c55e;
        }

        .toggle-switch input:checked+.toggle-slider:before {
            transform: translateX(24px);
        }

        .photo-status-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 800;
        }

        .photo-status-open {
            background: rgba(34, 197, 94, 0.15);
            color: #16a34a;
        }

        .photo-status-closed {
            background: rgba(220, 53, 69, 0.1);
            color: #dc3545;
        }

        .photo-gallery-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            margin-top: 20px;
        }

        .photo-gallery-item {
            border-radius: 12px;
            overflow: hidden;
            aspect-ratio: 1;
            position: relative;
            border: 1px solid var(--glass-border);
        }

        .photo-gallery-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: 0.3s;
        }

        .photo-gallery-item:hover img {
            transform: scale(1.05);
        }

        /* === Live Tab Styles === */
        .live-embed-container {
            position: relative;
            width: 100%;
            padding-bottom: 56.25%;
            height: 0;
            overflow: hidden;
            border-radius: 20px;
            box-shadow: var(--shadow-md);
            background: #000;
        }

        .live-embed-container iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: 0;
            border-radius: 20px;
        }

        .live-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
            padding: 8px 18px;
            border-radius: 20px;
            font-weight: 800;
            font-size: 14px;
            animation: pulse 1.5s infinite;
            margin-bottom: 20px;
        }

        .live-badge .dot {
            width: 10px;
            height: 10px;
            background: white;
            border-radius: 50%;
            animation: blink 1s infinite;
        }

        @keyframes blink {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.3;
            }
        }

        .live-no-stream {
            text-align: center;
            padding: 60px 30px;
            background: var(--bg-page);
            border-radius: 20px;
            border: 1px solid var(--glass-border);
        }

        .live-no-stream .icon {
            font-size: 48px;
            margin-bottom: 15px;
            display: block;
        }

        .live-no-stream .msg {
            font-size: 16px;
            color: var(--text-dim);
            font-weight: 600;
        }

        /* Rules tab — view rendering (HTML from Quill) */
        .rules-content {
            background: var(--bg-page);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 24px 28px;
            font-size: 15px;
            line-height: 1.85;
            color: var(--text-main);
            word-break: break-word;
            font-family: 'Outfit', 'Kanit', sans-serif;
        }

        .rules-content p {
            margin: 0;
        }

        .rules-content p:empty::after {
            content: '\00a0';
        }

        .rules-content h1,
        .rules-content h2,
        .rules-content h3 {
            margin: 18px 0 10px;
            line-height: 1.3;
        }

        .rules-content h1 {
            font-size: 22px;
            font-weight: 800;
        }

        .rules-content h2 {
            font-size: 19px;
            font-weight: 800;
        }

        .rules-content h3 {
            font-size: 17px;
            font-weight: 800;
        }

        .rules-content ol,
        .rules-content ul {
            padding-left: 28px;
            margin: 8px 0 14px;
        }

        .rules-content li {
            margin-bottom: 4px;
        }

        .rules-content blockquote {
            border-left: 4px solid var(--primary);
            margin: 12px 0;
            padding: 6px 14px;
            background: var(--bg-card);
            border-radius: 0 10px 10px 0;
            color: var(--text-dim);
        }

        .rules-content a {
            color: var(--primary);
            text-decoration: underline;
        }

        .rules-content u {
            text-decoration: underline;
        }

        .rules-content s {
            text-decoration: line-through;
        }

        .rules-content strong,
        .rules-content b {
            font-weight: 800;
        }

        .rules-content em,
        .rules-content i {
            font-style: italic;
        }

        .rules-content .ql-align-center {
            text-align: center;
        }

        .rules-content .ql-align-right {
            text-align: right;
        }

        .rules-content .ql-align-justify {
            text-align: justify;
        }

        /* Quill font-size class mappings (snow theme uses size class on span) */
        .rules-content .ql-size-small {
            font-size: 0.78em;
        }

        .rules-content .ql-size-large {
            font-size: 1.5em;
        }

        .rules-content .ql-size-huge {
            font-size: 2.2em;
        }

        /* รูปในกติกา (จากปุ่ม image ใน Quill) */
        .rules-content img {
            max-width: 100%;
            height: auto;
            border-radius: 10px;
            margin: 12px 0;
            display: block;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
        }

        #rules-quill-wrap .ql-editor img {
            max-width: 100%;
            height: auto;
            border-radius: 8px;
            margin: 8px 0;
            cursor: pointer;
        }

        /* ===== Image resize overlay (Word/Google Docs style) ===== */
        #rules-img-overlay {
            position: fixed;
            z-index: 4500;
            display: none;
            border: 2px solid #6b7280;
            pointer-events: none;
            box-sizing: border-box;
        }

        #rules-img-overlay .handle {
            position: absolute;
            width: 12px;
            height: 12px;
            background: #fff;
            border: 2px solid #6b7280;
            border-radius: 2px;
            pointer-events: auto;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        }

        #rules-img-overlay .handle.nw {
            top: -7px;
            left: -7px;
            cursor: nwse-resize;
        }

        #rules-img-overlay .handle.ne {
            top: -7px;
            right: -7px;
            cursor: nesw-resize;
        }

        #rules-img-overlay .handle.sw {
            bottom: -7px;
            left: -7px;
            cursor: nesw-resize;
        }

        #rules-img-overlay .handle.se {
            bottom: -7px;
            right: -7px;
            cursor: nwse-resize;
        }

        #rules-img-overlay .handle.n {
            top: -7px;
            left: 50%;
            transform: translateX(-50%);
            cursor: ns-resize;
        }

        #rules-img-overlay .handle.s {
            bottom: -7px;
            left: 50%;
            transform: translateX(-50%);
            cursor: ns-resize;
        }

        #rules-img-overlay .handle.w {
            top: 50%;
            left: -7px;
            transform: translateY(-50%);
            cursor: ew-resize;
        }

        #rules-img-overlay .handle.e {
            top: 50%;
            right: -7px;
            transform: translateY(-50%);
            cursor: ew-resize;
        }

        #rules-img-overlay .img-toolbar {
            position: absolute;
            top: -38px;
            right: 0;
            background: var(--bg-card);
            border: 1px solid var(--glass-border);
            border-radius: 8px;
            padding: 4px 6px;
            display: flex;
            align-items: center;
            gap: 6px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            pointer-events: auto;
            font-family: 'Outfit', 'Kanit', sans-serif;
        }

        #rules-img-overlay .size-readout {
            font-size: 11px;
            font-weight: 700;
            color: var(--text-dim);
            padding: 2px 6px;
            background: var(--bg-page);
            border-radius: 4px;
            min-width: 80px;
            text-align: center;
        }

        #rules-img-overlay .img-del {
            background: var(--bg-page);
            border: 1px solid rgba(220, 38, 38, 0.3);
            color: #dc2626;
            padding: 4px 9px;
            border-radius: 6px;
            font-weight: 800;
            font-size: 12px;
            cursor: pointer;
            font-family: inherit;
            transition: 0.15s;
        }

        #rules-img-overlay .img-del:hover {
            background: #dc2626;
            color: #fff;
        }

        /* Touch-friendly bigger handles on mobile */
        @media (max-width: 768px) {
            #rules-img-overlay .handle {
                width: 18px;
                height: 18px;
                border-width: 2px;
            }

            #rules-img-overlay .handle.nw {
                top: -10px;
                left: -10px;
            }

            #rules-img-overlay .handle.ne {
                top: -10px;
                right: -10px;
            }

            #rules-img-overlay .handle.sw {
                bottom: -10px;
                left: -10px;
            }

            #rules-img-overlay .handle.se {
                bottom: -10px;
                right: -10px;
            }

            #rules-img-overlay .handle.n,
            #rules-img-overlay .handle.s,
            #rules-img-overlay .handle.w,
            #rules-img-overlay .handle.e {
                display: none;
            }

            /* keep only corners on mobile */
        }

        .rules-empty {
            text-align: center;
            padding: 60px 30px;
            background: var(--bg-page);
            border-radius: 20px;
            border: 1px dashed var(--glass-border);
        }

        .rules-empty .icon {
            font-size: 44px;
            margin-bottom: 12px;
            display: block;
        }

        .rules-empty .msg {
            font-size: 15px;
            color: var(--text-dim);
            font-weight: 600;
        }

        .btn-rules-edit {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: #ffc107;
            color: #333;
            padding: 9px 18px;
            border: none;
            border-radius: 10px;
            font-weight: 800;
            font-size: 13px;
            cursor: pointer;
            font-family: inherit;
            transition: 0.2s;
        }

        .btn-rules-edit:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 14px rgba(255, 193, 7, 0.35);
        }

        .btn-rules-save {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: #fff;
            padding: 11px 22px;
            border: none;
            border-radius: 10px;
            font-weight: 800;
            font-size: 14px;
            cursor: pointer;
            font-family: inherit;
            transition: 0.2s;
            box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
        }

        .btn-rules-save:hover {
            transform: translateY(-1px);
            box-shadow: 0 8px 18px rgba(34, 197, 94, 0.4);
        }

        .btn-rules-cancel {
            background: var(--bg-page);
            color: var(--text-main);
            padding: 11px 22px;
            border: 1px solid var(--glass-border);
            border-radius: 10px;
            font-weight: 700;
            font-size: 14px;
            cursor: pointer;
            font-family: inherit;
            transition: 0.2s;
        }

        .btn-rules-cancel:hover {
            background: var(--bg-card);
        }

        /* Quill editor surface */
        /* Active-state highlight on toolbar buttons (B / I / U / S / lists / blockquote / link / align) */
        #rules-quill-wrap .ql-snow.ql-toolbar button,
        #rules-quill-wrap .ql-snow .ql-toolbar button {
            border-radius: 6px;
            transition: background 0.15s, box-shadow 0.15s;
            margin: 0 1px;
        }

        #rules-quill-wrap .ql-snow.ql-toolbar button:hover,
        #rules-quill-wrap .ql-snow .ql-toolbar button:hover {
            background: rgba(120, 120, 120, 0.10);
        }

        #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active,
        #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active,
        #rules-quill-wrap .ql-snow.ql-toolbar .ql-picker-label.ql-active,
        #rules-quill-wrap .ql-snow .ql-toolbar .ql-picker-label.ql-active {
            background: rgba(120, 120, 120, 0.18);
            box-shadow: inset 0 0 0 1.5px #6b7280;
            color: #374151;
        }

        #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke,
        #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active .ql-stroke {
            stroke: #374151;
            stroke-width: 2.4;
        }

        #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active .ql-fill,
        #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active .ql-fill {
            fill: #374151;
        }

        /* Bold gets an extra-strong cue since it's the most common toggle */
        #rules-quill-wrap .ql-snow.ql-toolbar button.ql-bold.ql-active,
        #rules-quill-wrap .ql-snow .ql-toolbar button.ql-bold.ql-active {
            background: rgba(120, 120, 120, 0.24);
        }

        /* Dark-mode contrast tweak for active buttons */
        [data-theme="dark"] #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active,
        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active,
        [data-theme="dark"] #rules-quill-wrap .ql-snow.ql-toolbar .ql-picker-label.ql-active,
        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-toolbar .ql-picker-label.ql-active {
            background: rgba(255, 255, 255, 0.14);
            box-shadow: inset 0 0 0 1.5px #d1d5db;
            color: #f3f4f6;
        }

        [data-theme="dark"] #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke,
        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active .ql-stroke {
            stroke: #f3f4f6;
        }

        [data-theme="dark"] #rules-quill-wrap .ql-snow.ql-toolbar button.ql-active .ql-fill,
        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-toolbar button.ql-active .ql-fill {
            fill: #f3f4f6;
        }

        /* Numeric font-size picker (Word-style) */
        #rules-quill-wrap .ql-snow .ql-picker.ql-size {
            width: 70px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-label::before,
        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item::before {
            content: attr(data-value);
        }

        /* Render each item at its actual size, like Word's preview */
        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="10px"]::before {
            font-size: 10px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="11px"]::before {
            font-size: 11px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="12px"]::before {
            font-size: 12px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14px"]::before {
            font-size: 14px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16px"]::before {
            font-size: 16px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="18px"]::before {
            font-size: 18px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="20px"]::before {
            font-size: 20px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="24px"]::before {
            font-size: 22px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="28px"]::before {
            font-size: 24px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="32px"]::before {
            font-size: 26px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="36px"]::before {
            font-size: 28px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="48px"]::before {
            font-size: 30px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="64px"]::before {
            font-size: 32px;
        }

        #rules-quill-wrap .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="72px"]::before {
            font-size: 34px;
        }

        #rules-quill-wrap {
            background: var(--bg-page);
            border-radius: 16px;
            overflow: hidden;
            border: 1px solid var(--glass-border);
        }

        #rules-quill-wrap .ql-toolbar.ql-snow {
            border: none;
            border-bottom: 1px solid var(--glass-border);
            background: var(--bg-card);
            border-radius: 16px 16px 0 0;
            padding: 10px 12px;
        }

        #rules-quill-wrap .ql-container.ql-snow {
            border: none;
            min-height: 320px;
            font-family: 'Outfit', 'Kanit', sans-serif;
            font-size: 15px;
        }

        #rules-quill-wrap .ql-editor {
            min-height: 320px;
            padding: 20px 24px;
            line-height: 1.85;
            color: var(--text-main);
        }

        #rules-quill-wrap .ql-editor.ql-blank::before {
            color: var(--text-dim);
            font-style: normal;
            opacity: 0.7;
        }

        /* Dark-mode tweaks for toolbar icons/labels */
        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-stroke {
            stroke: var(--text-main);
        }

        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-fill {
            fill: var(--text-main);
        }

        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-picker {
            color: var(--text-main);
        }

        [data-theme="dark"] #rules-quill-wrap .ql-snow .ql-picker-options {
            background: var(--bg-card);
            border-color: var(--glass-border);
        }

        @media (max-width: 768px) {
            .rules-content {
                padding: 16px 18px;
                font-size: 14px;
                line-height: 1.7;
                border-radius: 14px;
            }

            .rules-empty {
                padding: 40px 20px;
            }

            .rules-empty .icon {
                font-size: 36px;
            }

            .rules-empty .msg {
                font-size: 14px;
            }

            #rules-quill-wrap .ql-toolbar.ql-snow {
                padding: 8px 8px;
            }

            #rules-quill-wrap .ql-editor {
                padding: 14px 16px;
                min-height: 260px;
                font-size: 14px;
            }

            #rules-quill-wrap .ql-container.ql-snow {
                min-height: 260px;
                font-size: 14px;
            }
        }

        /* ============================================================
           📱 MOBILE UI — match_detail.php
           Premium mobile-first redesign
           ============================================================ */
        @media (max-width: 768px) {

            /* --- Shell & Layout --- */
            body {
                padding-top: 70px !important;
                padding-bottom: 90px !important;
            }

            .navbar {
                display: none !important;
            }

            .container {
                margin: 0;
                padding: 12px 16px;
                border: none;
                box-shadow: none;
                border-radius: 0;
                background: transparent;
            }

            /* --- Back Link --- */
            .back-link {
                font-size: 13px;
                padding: 6px 0;
                gap: 6px;
                color: var(--text-dim);
                opacity: 0.8;
            }

            /* --- Header Section --- */
            .header-box {
                border-bottom: none;
                margin-bottom: 12px;
                text-align: left;
                padding-bottom: 14px;
                position: relative;
            }

            .header-box h2 {
                font-size: 20px;
                margin-top: 4px;
                line-height: 1.3;
                letter-spacing: -0.3px;
            }

            .header-box p {
                font-size: 12px;
                line-height: 1.6;
                color: var(--text-dim);
                margin: 4px 0;
            }

            .header-box p:first-of-type {
                display: flex;
                flex-wrap: wrap;
                gap: 4px 12px;
            }

            .header-box span[style*="background: var(--primary)"] {
                font-size: 11px !important;
                padding: 3px 10px !important;
                border-radius: 8px !important;
            }

            /* Role badge compact */
            .header-box span[style*="border-radius:15px"] {
                font-size: 10px !important;
                padding: 3px 8px !important;
                margin-bottom: 4px !important;
                margin-top: 6px !important;
            }

            /* --- Admin Action Group --- */
            .admin-action-group {
                position: static !important;
                width: 100%;
                margin-top: 12px;
                gap: 8px;
                display: grid !important;
                grid-template-columns: 1fr 1fr;
            }

            .admin-action-group a {
                font-size: 11px;
                padding: 10px 8px;
                text-align: center;
                border-radius: 10px !important;
                white-space: nowrap;
            }

            .admin-action-group a:only-child,
            .admin-action-group a:nth-child(3) {
                grid-column: 1 / -1;
            }

            .btn-live-score {
                font-size: 11px !important;
                padding: 10px 8px !important;
            }

            /* --- Sticky Tab Menu --- */
            .tab-menu {
                position: sticky;
                top: 70px;
                z-index: 1000;
                margin: 0 -16px;
                padding: 5px 12px;
                background: var(--navbar-bg);
                backdrop-filter: blur(15px);
                -webkit-backdrop-filter: blur(15px);
                border-top: 1px solid var(--glass-border);
                border-bottom: 1px solid var(--glass-border);
                border-radius: 0;
                gap: 3px;
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
            }

            .tab-btn {
                padding: 8px 12px;
                font-size: 11px;
                border-radius: 10px;
                letter-spacing: -0.2px;
            }

            .tab-btn.active {
                box-shadow: 0 2px 8px rgba(230, 0, 0, 0.15);
            }

            /* --- Category Pills --- */
            .cat-menu {
                overflow-x: auto;
                white-space: nowrap;
                flex-wrap: nowrap;
                padding: 4px 0 10px;
                gap: 6px;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
            }

            .cat-menu::-webkit-scrollbar {
                display: none;
            }

            .cat-btn {
                font-size: 12px;
                padding: 8px 14px;
                border-radius: 10px;
                flex-shrink: 0;
            }

            /* --- Bracket Type Pills --- */
            .bracket-menu {
                padding: 6px 10px;
                border-radius: 12px;
                gap: 6px;
                overflow-x: auto;
                flex-wrap: nowrap;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
            }

            .bracket-menu::-webkit-scrollbar {
                display: none;
            }

            .bracket-btn {
                font-size: 11px;
                padding: 6px 14px;
                flex-shrink: 0;
            }

            /* --- View Toggle: hidden on mobile, grid is native --- */
            .view-toggle-container {
                display: none !important;
            }

            .view-btn {
                font-size: 12px;
                padding: 8px 14px;
            }

            .view-mode-list {
                display: none !important;
            }

            .view-mode-grid {
                display: grid !important;
                grid-template-columns: 1fr !important;
                gap: 12px !important;
                animation: fadeIn 0.3s;
            }

            /* --- Header Flex Mobile --- */
            .header-flex-mobile {
                flex-direction: column;
                align-items: flex-start !important;
                gap: 8px;
            }

            .header-flex-mobile h3 {
                font-size: 17px;
                margin: 0;
            }

            /* --- Info Tab (Detail) --- */
            .info-grid {
                grid-template-columns: 1fr !important;
                gap: 14px !important;
            }

            .info-grid>div {
                padding: 18px !important;
                border-radius: 16px !important;
            }

            .info-grid table {
                font-size: 13px !important;
            }

            .info-grid table td:first-child {
                width: 100px !important;
                font-size: 12px !important;
                padding-right: 8px !important;
            }

            .info-grid h3 {
                font-size: 15px !important;
            }

            /* Info + registration stacks vertically on mobile; registration comes first */
            .info-split {
                grid-template-columns: 1fr !important;
                gap: 16px !important;
            }

            .info-split-right {
                position: static !important;
                order: -1;
            }

            .register-card {
                padding: 16px !important;
            }

            .register-card h3 {
                font-size: 15px !important;
            }

            /* Registration CTA compact */
            .btn-register-cta {
                padding: 14px 24px !important;
                font-size: 16px !important;
                border-radius: 14px !important;
            }

            .btn-login-cta {
                padding: 12px 24px !important;
                font-size: 15px !important;
                border-radius: 14px !important;
            }

            /* Poster image */
            .info-grid img,
            #tab-info img {
                max-height: 280px !important;
                border-radius: 16px !important;
            }

            /* --- Registration Tab --- */
            .order-table {
                min-width: 600px;
            }

            /* Registration table: convert rows to mobile cards */
            #tab-registrations .table-responsive {
                overflow-x: visible;
                border: none;
                border-radius: 0;
                background: transparent;
            }

            #tab-registrations .order-table {
                min-width: 0;
                width: 100%;
                background: transparent;
                border-collapse: separate;
                border-spacing: 0;
                display: block;
            }

            #tab-registrations .order-table tbody,
            #tab-registrations .order-table thead {
                display: block;
            }

            /* hide column-header row (the first tr that has th) */
            #tab-registrations .order-table tr:first-child th {
                display: none;
            }
            #tab-registrations .order-table tr:first-child {
                display: none;
            }

            /* status group header (📌 ผ่านชำระแล้ว ...) */
            #tab-registrations .reg-status-header {
                display: block;
                margin: 14px 0 8px;
                background: transparent !important;
            }
            #tab-registrations .reg-status-header td {
                display: block;
                padding: 10px 14px !important;
                background: var(--bg-page);
                border: 1px solid var(--glass-border);
                border-radius: 10px;
                font-size: 13px;
                border-bottom: 1px solid var(--glass-border) !important;
            }

            /* player row as card */
            #tab-registrations .reg-player-row {
                display: grid;
                grid-template-columns: 38px 1fr;
                grid-template-areas:
                    "no    team"
                    "no    status"
                    "p1    p1"
                    "p2    p2"
                    "phone phone"
                    "slip  actions"
                    "userslip userslip";
                gap: 6px 12px;
                background: var(--bg-card);
                border: 1px solid var(--glass-border);
                border-radius: 14px;
                padding: 12px 14px;
                margin-bottom: 10px;
                box-shadow: var(--shadow-sm);
            }

            #tab-registrations .reg-player-row td {
                display: block;
                padding: 0;
                border: none;
                text-align: left !important;
                font-size: 13px;
                min-width: 0;
            }

            #tab-registrations .reg-td-no       { grid-area: no; align-self: start; }
            #tab-registrations .reg-td-team     { grid-area: team; }
            #tab-registrations .reg-td-status   { grid-area: status; }
            #tab-registrations .reg-td-p1       { grid-area: p1; }
            #tab-registrations .reg-td-p2       { grid-area: p2; }
            #tab-registrations .reg-td-phone    { grid-area: phone; }
            #tab-registrations .reg-td-slip     { grid-area: slip; }
            #tab-registrations .reg-td-actions  { grid-area: actions; justify-self: end; }
            #tab-registrations .reg-td-userslip { grid-area: userslip; }

            /* number badge */
            #tab-registrations .reg-td-no .reg-no-cell {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                width: 32px;
                height: 32px;
                background: var(--primary);
                color: #fff !important;
                border-radius: 50%;
                font-size: 13px !important;
                font-weight: 800;
            }

            /* team name a bit larger */
            #tab-registrations .reg-td-team {
                font-size: 15px;
                line-height: 1.35;
            }

            /* "นักกีฬา N:" label before player cells */
            #tab-registrations .reg-td-p1::before,
            #tab-registrations .reg-td-p2::before,
            #tab-registrations .reg-td-phone::before {
                content: attr(data-label) ": ";
                color: var(--text-dim);
                font-size: 11px;
                font-weight: 700;
                margin-right: 6px;
                text-transform: uppercase;
                letter-spacing: 0.3px;
            }

            /* hide empty player 2 cell */
            #tab-registrations .reg-td-empty {
                display: none;
            }

            /* status select / badge fits cell */
            #tab-registrations .reg-td-status .reg-status-select,
            #tab-registrations .reg-td-status .status-select {
                width: auto;
                max-width: 100%;
                padding: 6px 10px;
                font-size: 12px;
                border-radius: 8px;
            }

            /* admin edit-row: when JS makes it visible, render as block card */
            #tab-registrations tr[id^="edit_row_"][style*="table-row"] {
                display: block !important;
                margin-bottom: 10px;
            }
            #tab-registrations tr[id^="edit_row_"] td {
                display: block;
                padding: 12px !important;
                border-radius: 12px;
            }

            #importBox {
                border-radius: 16px;
                padding: 15px;
            }

            #importBox h4 {
                font-size: 14px !important;
            }

            /* --- Order of Play: Hide table, show mobile cards --- */
            .mobile-match-list {
                display: flex !important;
                flex-direction: column;
                gap: 10px;
            }

            .grid-card {
                border-radius: 14px;
            }

            .grid-header-dark {
                font-size: 11px;
                padding: 10px 14px;
            }

            .grid-header-sub {
                font-size: 10px;
                padding: 6px 14px;
            }

            .grid-team-row {
                padding: 10px 14px;
            }

            .g-t-name {
                font-size: 13px;
            }

            .g-p-name {
                font-size: 10px;
            }

            /* --- Group Standings — Mobile Card Transform --- */
            .group-box {
                border-radius: 16px;
                margin-bottom: 16px;
            }

            .group-header {
                font-size: 14px;
                padding: 12px 16px;
                border-radius: 16px 16px 0 0;
            }

            .group-header button {
                font-size: 11px !important;
                padding: 3px 8px !important;
            }

            .group-header .group-header-hint {
                font-size: 10px !important;
                text-align: right;
                line-height: 1.3;
                max-width: 55%;
            }

            .group-table {
                min-width: auto;
            }

            .group-table th:nth-child(n+2):nth-child(-n+4) {
                display: none;
            }

            .group-table td:nth-child(n+2):nth-child(-n+4) {
                display: none;
            }

            .group-table th:nth-child(5),
            .group-table td:nth-child(5) {
                display: none;
            }

            .group-table th:nth-child(6),
            .group-table td:nth-child(6) {
                display: none;
            }

            .group-table th,
            .group-table td {
                font-size: 12px;
                padding: 10px 6px;
            }

            .group-table td:first-child {
                text-align: left;
                padding-left: 12px;
                font-size: 13px;
            }

            .group-table td:first-child b {
                font-size: 13px !important;
            }

            .group-table td:first-child span {
                font-size: 11px !important;
            }

            /* Points column highlight — now col 9 because we inserted "แข่ง" at col 7 */
            .group-table td:nth-child(9) {
                font-size: 15px !important;
            }

            /* Rank badge */
            .group-table td:last-child span {
                width: 22px !important;
                height: 22px !important;
                line-height: 22px !important;
                font-size: 12px !important;
            }

            /* --- Best 3rd Table Mobile --- */
            .group-box[style*="border: 2px solid #e60000"] .group-table {
                min-width: 600px;
            }

            /* --- Knockout Bracket Mobile --- */
            .bracket-container {
                padding: 16px 12px;
                border-radius: 16px;
                flex-direction: column;
                overflow-x: visible;
                gap: 16px;
            }

            .bracket-round {
                min-width: 100%;
                margin-right: 0;
            }

            .round-title {
                font-size: 12px;
                padding: 8px 12px;
                border-radius: 10px;
                letter-spacing: 0.5px;
            }

            .ko-card {
                border-radius: 12px;
            }

            .ko-header {
                font-size: 10px;
                padding: 7px 12px;
            }

            .ko-row {
                padding: 10px 12px;
            }

            .ko-tname {
                font-size: 12px;
            }

            .ko-pname {
                font-size: 10px;
            }

            .ko-score {
                font-size: 15px;
                width: 28px;
            }

            .admin-score {
                font-size: 10px;
                padding: 5px;
            }

            /* Hide bracket connecting lines on mobile */
            .bracket-round:not(:last-child) .match-pair:not(.single-match)::after {
                display: none;
            }

            .bracket-round:not(:last-child) .match-pair.single-match .match-wrapper::after {
                display: none;
            }

            .bracket-round:not(:first-child) .match-wrapper::before {
                display: none;
            }

            .match-pair .ko-arm {
                display: none;
            }

            .match-pair {
                min-height: auto;
            }

            .match-wrapper {
                padding: 6px 0;
            }

            /* --- Result Tab Mobile --- */
            #tab-result .table-responsive {
                border-radius: 14px;
            }

            #tab-result .order-table {
                min-width: 500px;
            }

            /* --- Shuttlecocks Tab Mobile --- */
            #tab-shuttlecocks .table-responsive {
                border-radius: 14px;
            }

            /* --- Photo Tab Mobile --- */
            .photo-gallery-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 8px;
            }

            .photo-gallery-item {
                border-radius: 10px;
            }

            .photo-consent-box {
                padding: 14px;
                gap: 10px;
                border-radius: 14px;
            }

            .photo-consent-box label {
                font-size: 13px;
            }

            .photo-admin-toggle {
                flex-direction: column;
                gap: 12px;
                align-items: flex-start;
                border-radius: 14px;
                padding: 14px 16px;
            }

            .photo-admin-toggle .toggle-switch {
                align-self: flex-end;
            }

            .photo-upload-btn {
                border-radius: 14px;
                padding: 14px;
                font-size: 14px;
            }

            /* --- Live Tab Mobile --- */
            .live-embed-container {
                border-radius: 14px;
            }

            .live-embed-container iframe {
                border-radius: 14px;
            }

            .live-badge {
                font-size: 12px;
                padding: 6px 14px;
                border-radius: 16px;
            }

            .live-no-stream {
                border-radius: 16px;
                padding: 40px 20px;
            }

            .live-no-stream .icon {
                font-size: 36px;
            }

            .live-no-stream .msg {
                font-size: 14px;
            }

            /* --- Tables General Mobile --- */
            .table-responsive {
                border-radius: 14px;
            }

            /* --- Toast Mobile --- */
            #live-toast-container {
                top: 80px;
                right: 12px;
                left: 12px;
            }

            .live-toast {
                border-radius: 14px;
                padding: 12px 16px;
                font-size: 13px;
                min-width: auto;
            }

            /* --- Court Badge Mobile --- */
            .court-badge {
                font-size: 11px;
                padding: 3px 8px;
                border-radius: 6px;
            }

            /* --- Admin Print/Upload Buttons --- */
            .header-flex-mobile>div[style*="display:flex"][style*="gap:10px"] {
                width: 100%;
                flex-wrap: wrap;
            }

            .header-flex-mobile>div[style*="display:flex"][style*="gap:10px"] a,
            .header-flex-mobile>div[style*="display:flex"][style*="gap:10px"] button {
                flex: 1;
                text-align: center;
                min-width: 120px;
                border-radius: 8px !important;
                font-size: 11px !important;
            }

            /* --- Notification Toggle Mobile --- */
            #notif-switch-wrap {
                margin-left: 0 !important;
                margin-top: 4px;
            }

            /* --- Hide desktop tab-menu, show mobile selector --- */
            .tab-menu {
                display: none !important;
            }

            .mobile-tab-selector {
                display: block !important;
            }

            /* --- Mobile Tab Selector --- */
            .mobile-tab-selector {
                position: sticky;
                top: 70px;
                z-index: 1000;
                margin: 0 -16px 16px;
                padding: 8px 16px;
                background: var(--navbar-bg);
                backdrop-filter: blur(15px);
                -webkit-backdrop-filter: blur(15px);
                border-bottom: 1px solid var(--glass-border);
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
            }

            .mobile-tab-trigger {
                display: flex;
                align-items: center;
                justify-content: space-between;
                width: 100%;
                padding: 12px 16px;
                background: var(--bg-card);
                border: 1px solid var(--glass-border);
                border-radius: 14px;
                cursor: pointer;
                font-family: 'Outfit', 'Kanit', sans-serif;
                font-size: 14px;
                font-weight: 700;
                color: var(--text-main);
                box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
                transition: all 0.2s ease;
            }

            .mobile-tab-trigger:active {
                transform: scale(0.98);
            }

            .mobile-tab-trigger.open {
                border-color: var(--primary);
                box-shadow: 0 2px 12px rgba(230, 0, 0, 0.1);
            }

            .mobile-tab-chevron {
                transition: transform 0.3s ease;
                color: var(--text-dim);
                flex-shrink: 0;
            }

            .mobile-tab-trigger.open .mobile-tab-chevron {
                transform: rotate(180deg);
                color: var(--primary);
            }

            .mobile-tab-current {
                flex: 1;
                text-align: left;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .mobile-tab-dropdown {
                display: none;
                flex-direction: column;
                gap: 4px;
                margin-top: 8px;
                padding: 8px;
                background: var(--bg-card);
                border: 1px solid var(--glass-border);
                border-radius: 16px;
                box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
                animation: mtdSlideDown 0.25s ease;
            }

            .mobile-tab-dropdown.show {
                display: flex;
            }

            @keyframes mtdSlideDown {
                from {
                    opacity: 0;
                    transform: translateY(-8px);
                }

                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            .mobile-tab-option {
                display: flex;
                align-items: center;
                gap: 12px;
                padding: 12px 14px;
                border: none;
                background: transparent;
                border-radius: 12px;
                cursor: pointer;
                font-family: 'Outfit', 'Kanit', sans-serif;
                font-size: 14px;
                font-weight: 600;
                color: var(--text-main);
                transition: all 0.15s ease;
                text-align: left;
            }

            .mobile-tab-option:active {
                transform: scale(0.97);
            }

            .mobile-tab-option:hover {
                background: var(--bg-page);
            }

            .mobile-tab-option.active {
                background: var(--primary);
                color: white;
                font-weight: 700;
                box-shadow: 0 2px 8px rgba(230, 0, 0, 0.15);
            }

            .mto-icon {
                font-size: 18px;
                width: 28px;
                text-align: center;
                flex-shrink: 0;
            }

            .mto-text {
                flex: 1;
            }
        }

        /* Hide mobile tab selector on desktop */
        .mobile-tab-selector {
            display: none;
        }

        /* === DARK MODE — Mobile Overrides === */
        @media (max-width: 768px) {
            [data-theme="dark"] .m-match-card {
                background: var(--bg-card);
                border-color: var(--glass-border);
            }

            [data-theme="dark"] .m-match-header {
                color: var(--text-dim);
                border-bottom-color: var(--glass-border);
            }

            [data-theme="dark"] .m-avatar {
                background: var(--bg-page);
                color: var(--text-main);
                border-color: var(--glass-border);
            }

            [data-theme="dark"] .m-team-name {
                color: var(--text-main);
            }

            [data-theme="dark"] .m-players {
                color: var(--text-dim);
            }

            [data-theme="dark"] .m-score-badge {
                background: var(--bg-page);
                color: var(--text-main);
            }

            [data-theme="dark"] .m-score-badge.winner {
                background: var(--primary);
                color: white;
            }

            /* Dark mode mobile tab selector */
            [data-theme="dark"] .mobile-tab-selector {
                background: rgba(15, 23, 42, 0.9);
                border-bottom-color: var(--glass-border);
            }

            [data-theme="dark"] .mobile-tab-trigger {
                background: var(--bg-card);
                color: var(--text-main);
                border-color: var(--glass-border);
            }

            [data-theme="dark"] .mobile-tab-dropdown {
                background: var(--bg-card);
                border-color: var(--glass-border);
                box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
            }

            [data-theme="dark"] .mobile-tab-option {
                color: var(--text-main);
            }

            [data-theme="dark"] .mobile-tab-option:hover {
                background: var(--bg-page);
            }

            [data-theme="dark"] .mobile-tab-option.active {
                background: var(--primary);
                color: white;
            }
        }

/* ==== Block 2: original lines 4707-4896 ==== */
                        #reg-search-input:focus {
                            outline: none;
                            border-color: #10b981;
                            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
                        }

                        .cat-btn.btn-reg.reg-has-match {
                            box-shadow: 0 0 0 2px #10b981, 0 4px 10px rgba(16, 185, 129, 0.3);
                        }

                        .cat-btn.btn-reg.reg-has-match .cat-count {
                            color: #10b981;
                            font-weight: 800;
                        }

                        #reg-status-toast {
                            position: fixed;
                            bottom: 24px;
                            left: 50%;
                            transform: translateX(-50%) translateY(20px);
                            background: #1f2937;
                            color: #fff;
                            padding: 10px 18px;
                            border-radius: 10px;
                            font-size: 13px;
                            font-weight: 700;
                            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
                            opacity: 0;
                            pointer-events: none;
                            transition: opacity .25s, transform .25s;
                            z-index: 9999;
                        }

                        #reg-status-toast.show {
                            opacity: 1;
                            transform: translateX(-50%) translateY(0);
                        }

                        .slip-btn {
                            border: none;
                            padding: 6px 10px;
                            border-radius: 8px;
                            cursor: pointer;
                            font-weight: 700;
                            font-size: 11px;
                            color: #fff;
                            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
                        }

                        .slip-btn.slip-upload {
                            background: linear-gradient(135deg, #0ea5e9, #38bdf8);
                        }

                        .slip-btn.slip-view {
                            background: linear-gradient(135deg, #16a34a, #22c55e);
                        }

                        .slip-btn:hover {
                            filter: brightness(1.05);
                            transform: translateY(-1px);
                        }

                        #slipModal {
                            position: fixed;
                            inset: 0;
                            background: rgba(0, 0, 0, 0.6);
                            display: none;
                            align-items: center;
                            justify-content: center;
                            z-index: 10001;
                            padding: 20px;
                        }

                        #slipModal.show {
                            display: flex;
                        }

                        .slip-card {
                            background: #fff;
                            border-radius: 16px;
                            max-width: 560px;
                            width: 100%;
                            box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
                            overflow: hidden;
                            max-height: 90vh;
                            display: flex;
                            flex-direction: column;
                        }

                        .slip-head {
                            padding: 16px 20px;
                            background: linear-gradient(135deg, #1e3a8a, #3b82f6);
                            color: #fff;
                            display: flex;
                            justify-content: space-between;
                            align-items: center;
                        }

                        .slip-head h3 {
                            margin: 0;
                            font-size: 16px;
                            font-weight: 800;
                        }

                        .slip-close {
                            background: rgba(255, 255, 255, 0.2);
                            border: none;
                            color: #fff;
                            width: 30px;
                            height: 30px;
                            border-radius: 50%;
                            cursor: pointer;
                            font-size: 18px;
                            font-weight: 700;
                        }

                        .slip-body {
                            padding: 20px;
                            overflow-y: auto;
                        }

                        .slip-img {
                            max-width: 100%;
                            max-height: 65vh;
                            display: block;
                            margin: 0 auto;
                            border-radius: 8px;
                            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
                        }

                        .slip-drop {
                            display: block;
                            box-sizing: border-box;
                            width: 100%;
                            border: 2px dashed #cbd5e1;
                            border-radius: 12px;
                            padding: 30px 20px;
                            text-align: center;
                            color: #64748b;
                            cursor: pointer;
                            transition: all .15s;
                        }

                        .slip-drop:hover,
                        .slip-drop.dragover {
                            border-color: #3b82f6;
                            background: #eff6ff;
                            color: #1e3a8a;
                        }

                        .slip-preview {
                            max-width: 100%;
                            max-height: 300px;
                            margin: 14px auto 0;
                            display: block;
                            border-radius: 8px;
                        }

                        .slip-actions {
                            display: flex;
                            gap: 8px;
                            margin-top: 14px;
                        }

                        .slip-actions button {
                            flex: 1;
                            padding: 10px;
                            border: none;
                            border-radius: 8px;
                            cursor: pointer;
                            font-weight: 700;
                            font-size: 13px;
                        }

                        .slip-actions .btn-primary {
                            background: linear-gradient(135deg, #1e3a8a, #3b82f6);
                            color: #fff;
                        }

                        .slip-actions .btn-secondary {
                            background: #e5e7eb;
                            color: #1f2937;
                        }

                        .slip-actions .btn-danger {
                            background: linear-gradient(135deg, #b91c1c, #ef4444);
                            color: #fff;
                        }

/* ==== Block 3: original lines 5236-5435 ==== */
                            .player-info-btn {
                                display: inline-flex;
                                align-items: center;
                                justify-content: center;
                                width: 18px;
                                height: 18px;
                                margin-left: 6px;
                                padding: 0;
                                border-radius: 50%;
                                border: 1.5px solid #3b82f6;
                                background: #fff;
                                color: #3b82f6;
                                font-family: Georgia, 'Times New Roman', serif;
                                font-style: italic;
                                font-weight: 700;
                                font-size: 11px;
                                line-height: 1;
                                cursor: pointer;
                                vertical-align: middle;
                                transition: all .15s;
                            }

                            .player-info-btn:hover {
                                background: #3b82f6;
                                color: #fff;
                                transform: scale(1.1);
                            }

                            #playerAchModal {
                                position: fixed;
                                inset: 0;
                                background: rgba(0, 0, 0, 0.55);
                                display: none;
                                align-items: flex-start;
                                justify-content: center;
                                z-index: 10000;
                                padding: 30px 12px;
                                overflow-y: auto;
                            }

                            #playerAchModal.show {
                                display: flex;
                            }

                            .pa-card {
                                background: #fff;
                                border-radius: 16px;
                                max-width: 900px;
                                width: 100%;
                                box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
                                overflow: hidden;
                                margin: auto;
                            }

                            .pa-head {
                                padding: 18px 22px;
                                background: linear-gradient(135deg, #1e3a8a, #3b82f6);
                                color: #fff;
                                display: flex;
                                justify-content: space-between;
                                align-items: center;
                                gap: 10px;
                            }

                            .pa-head h3 {
                                margin: 0;
                                font-size: 18px;
                                font-weight: 800;
                            }

                            .pa-head .pa-close {
                                background: rgba(255, 255, 255, 0.2);
                                border: none;
                                color: #fff;
                                width: 32px;
                                height: 32px;
                                border-radius: 50%;
                                cursor: pointer;
                                font-size: 18px;
                                font-weight: 700;
                            }

                            .pa-stats {
                                display: flex;
                                gap: 8px;
                                padding: 14px 22px;
                                background: #f8fafc;
                                border-bottom: 1px solid #e5e7eb;
                                flex-wrap: wrap;
                            }

                            .pa-stat {
                                flex: 1;
                                min-width: 90px;
                                text-align: center;
                                padding: 10px 6px;
                                background: #fff;
                                border-radius: 10px;
                                border: 1px solid #e5e7eb;
                            }

                            .pa-stat-val {
                                font-size: 20px;
                                font-weight: 800;
                            }

                            .pa-stat-lbl {
                                font-size: 11px;
                                color: #64748b;
                                margin-top: 2px;
                            }

                            .pa-body {
                                padding: 16px 22px 22px;
                                max-height: 60vh;
                                overflow-y: auto;
                            }

                            .pa-table {
                                width: 100%;
                                border-collapse: collapse;
                                font-size: 13px;
                            }

                            .pa-table th {
                                background: #1f2937;
                                color: #fff;
                                padding: 8px 10px;
                                text-align: left;
                                font-weight: 700;
                                font-size: 12px;
                            }

                            .pa-table td {
                                padding: 8px 10px;
                                border-bottom: 1px solid #f1f5f9;
                                color: #1f2937;
                            }

                            .pa-badge {
                                display: inline-block;
                                padding: 3px 8px;
                                border-radius: 6px;
                                font-size: 11px;
                                font-weight: 700;
                                color: #fff;
                            }

                            .pa-badge.gold {
                                background: linear-gradient(135deg, #f59e0b, #d97706);
                            }

                            .pa-badge.silver {
                                background: linear-gradient(135deg, #94a3b8, #64748b);
                            }

                            .pa-badge.bronze {
                                background: linear-gradient(135deg, #b45309, #92400e);
                            }

                            .pa-badge.normal {
                                background: #cbd5e1;
                                color: #1f2937;
                            }

                            .pa-empty {
                                text-align: center;
                                color: #94a3b8;
                                padding: 40px 20px;
                            }

                            @media (max-width: 600px) {
                                .pa-table thead {
                                    display: none;
                                }

                                .pa-table tr {
                                    display: block;
                                    border: 1px solid #e5e7eb;
                                    border-radius: 10px;
                                    padding: 10px;
                                    margin-bottom: 8px;
                                }

                                .pa-table td {
                                    display: flex;
                                    justify-content: space-between;
                                    gap: 10px;
                                    border: none;
                                    padding: 4px 0;
                                }

                                .pa-table td::before {
                                    content: attr(data-label);
                                    font-weight: 700;
                                    color: #64748b;
                                }
                            }

/* ==== Block 4: original lines 6182-6192 ==== */
                #odp-search-input:focus {
                    outline: none;
                    border-color: #10b981;
                    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
                }

                .cat-btn.btn-order.odp-has-match {
                    box-shadow: 0 0 0 2px #10b981, 0 4px 10px rgba(16, 185, 129, 0.3);
                }

/* ==== Block 5: original lines 6852-6869 ==== */
                #tab-group .gr-team-row {
                    transition: opacity 0.3s ease, background-color 0.3s ease;
                }

                #tab-group .gr-team-row.gr-dim {
                    opacity: 0.18;
                }

                #tab-group .gr-team-row.gr-highlight {
                    background-color: rgba(16, 185, 129, 0.18) !important;
                    box-shadow: inset 3px 0 0 #10b981;
                }

                #tab-group .cat-btn.btn-group.gr-has-match {
                    box-shadow: 0 0 0 2px #10b981, 0 4px 10px rgba(16, 185, 129, 0.3);
                }

/* ==== Block 6: original lines 7225-7322 ==== */
                #ko-search-input:focus {
                    outline: none;
                    border-color: #10b981;
                    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
                }

                .match-wrapper {
                    transition: opacity 0.3s ease;
                }

                .match-wrapper.ko-dim {
                    opacity: 0.15;
                }

                .match-wrapper.ko-highlight .ko-card {
                    box-shadow: 0 0 0 3px #10b981, 0 6px 20px rgba(16, 185, 129, 0.35) !important;
                    transform: translateY(-2px);
                    transition: box-shadow 0.3s, transform 0.3s;
                }

                .cat-btn.btn-knockout.ko-has-match {
                    box-shadow: 0 0 0 2px #10b981, 0 4px 10px rgba(16, 185, 129, 0.3);
                }

                /* Highlight bracket connector lines along the path of the matched player */
                .match-wrapper.ko-highlight::before {
                    border-top-color: #10b981 !important;
                    border-top-width: 3px !important;
                    z-index: 4;
                }

                /* Bracket connector U-shape highlighting — split into separate elements for granular arm control */
                .match-pair .ko-arm {
                    position: absolute;
                    right: -20px;
                    width: 20px;
                    pointer-events: none;
                    transition: border-color 0.2s;
                    z-index: 3;
                }

                .match-pair .ko-arm-top {
                    top: 25%;
                    bottom: 50%;
                    border-top: 2px solid #cbd5e1;
                    border-right: 2px solid #cbd5e1;
                    border-top-right-radius: 4px;
                }

                .match-pair .ko-arm-bottom {
                    top: 50%;
                    bottom: 25%;
                    border-bottom: 2px solid #cbd5e1;
                    border-right: 2px solid #cbd5e1;
                    border-bottom-right-radius: 4px;
                }

                /* Highlight only the arm of the actually-matched wrapper (both horizontal arm and its half of the right vertical) */
                .match-pair.ko-pair-top .ko-arm-top,
                .match-pair.ko-pair-both .ko-arm-top {
                    border-top-color: #10b981 !important;
                    border-right-color: #10b981 !important;
                    border-top-width: 3px !important;
                    border-right-width: 3px !important;
                    z-index: 4;
                }

                .match-pair.ko-pair-bottom .ko-arm-bottom,
                .match-pair.ko-pair-both .ko-arm-bottom {
                    border-bottom-color: #10b981 !important;
                    border-right-color: #10b981 !important;
                    border-bottom-width: 3px !important;
                    border-right-width: 3px !important;
                    z-index: 4;
                }

                .bracket-round:not(:last-child) .match-pair.single-match .match-wrapper.ko-highlight::after {
                    border-top-color: #10b981 !important;
                    border-top-width: 3px !important;
                    z-index: 4;
                }

                /* On mobile: hide non-matching matches entirely (instead of just dimming) */
                @media (max-width: 768px) {
                    .match-wrapper.ko-dim {
                        display: none !important;
                    }

                    .bracket-round.ko-round-empty {
                        display: none !important;
                    }

                    .match-pair.ko-pair-empty {
                        display: none !important;
                    }
                }

/* ==== Block 7: original lines 7496-7557 ==== */
                        /* สไตล์พิเศษสำหรับหน้าผู้ใช้บนมือถือ เพื่อให้ตารางลูกแบดกลายเป็น Card */
                        @media (max-width: 768px) {
                            .shuttle-table-public {
                                min-width: 100% !important;
                                background: transparent;
                                box-shadow: none;
                                border: none;
                            }

                            .shuttle-table-public thead,
                            .shuttle-table-public th {
                                display: none;
                            }

                            .shuttle-table-public tr {
                                display: block;
                                background: #fff;
                                border: 1px solid #ddd;
                                border-radius: 8px;
                                margin-bottom: 15px;
                                padding: 15px;
                                box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
                            }

                            .shuttle-table-public td {
                                display: flex;
                                justify-content: space-between;
                                align-items: center;
                                border-bottom: 1px dashed #eee !important;
                                padding: 8px 0;
                                text-align: right !important;
                            }

                            .shuttle-table-public td:last-child {
                                border-bottom: none !important;
                            }

                            .shuttle-table-public td::before {
                                content: attr(data-label);
                                font-weight: bold;
                                color: #555;
                                text-align: left;
                                flex-grow: 1;
                            }
                        }

                        .highlight-paid {
                            background: #e8f5e9;
                            color: #28a745 !important;
                            font-weight: bold;
                            font-size: 15px;
                            border-radius: 4px;
                            padding: 2px 6px;
                        }

                        .highlight-unpaid {
                            font-weight: bold;
                            color: #e60000;
                            font-size: 15px;
                        }

/* ==== Block 8: original lines 7688-7703 ==== */
                        #sh-search-input:focus {
                            outline: none;
                            border-color: #10b981;
                            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
                        }

                        .sh-player-row {
                            transition: background-color 0.3s ease;
                        }

                        .sh-player-row.sh-highlight {
                            background-color: rgba(16, 185, 129, 0.10) !important;
                            box-shadow: inset 3px 0 0 #10b981;
                        }
