.ept-panel { max-width: 980px; margin: 0 auto; }
.ept-head h2 { margin: 0 0 6px; }
.ept-muted { opacity: .75; font-size: 14px; }
.ept-card { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); padding: 14px; border-radius: 12px; margin: 12px 0; }
.ept-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ept-field label { display:block; font-size: 13px; opacity:.8; margin-bottom: 6px; }
.ept-field input { width:100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.15); color: inherit; }
.ept-actions { display:flex; gap:10px; align-items:center; margin-top: 10px; }
.ept-status.is-error { color: #ffb4b4; }
.ept-list { display:flex; flex-direction: column; gap: 10px; }
.ept-row { display:flex; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.12); }
.ept-row-title { display:flex; align-items:center; gap: 10px; }
.ept-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); opacity:.85; }
.ept-row-actions { display:flex; gap: 8px; align-items:center; }
.ept-btn, .ept-btn-primary, .ept-btn-danger { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: inherit; cursor:pointer; }
.ept-btn-primary { background: rgba(59,130,246,.25); border-color: rgba(59,130,246,.35); }
.ept-btn-danger { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.32); }
/* --- Score Entry header/table helpers --- */
.ept-se-scroll { overflow: auto; max-width: 100%; max-height: 70vh; position: relative; }
.ept-se-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.ept-se-table{ --ept-h1: 36px; --ept-hm: 22px; }
/* Use core color tokens when available, fallback to slate/dark */
.ept-se-table thead th { position: sticky; top: 0; z-index: 3; background: var(--epc-surface-800, #0f172a); color: inherit; background-clip: padding-box; }
.ept-se-table th, .ept-se-table td { border: 1px solid rgba(255,255,255,.15); padding: 6px; }
.ept-se-table .ept-sticky-col { position: sticky; left: 0; z-index: 4; background: var(--epc-surface-750, #111827); color: inherit; background-clip: padding-box; }
.ept-se-table thead .ept-sticky-col { z-index: 5; }

/* Compact header helper rows (Par / YDG) under the sticky header */
.ept-se-table thead tr.ept-head-main th { top: 0; height: var(--ept-h1); }
.ept-se-table thead tr.ept-mini th { font-size: 11px; padding-top: 3px; padding-bottom: 3px; background: #1f1f1f; }
.ept-se-table thead tr.ept-mini:nth-of-type(2) th { top: var(--ept-h1); }
.ept-se-table thead tr.ept-mini:nth-of-type(3) th { top: calc(var(--ept-h1) + var(--ept-hm)); }
.ept-se-table thead tr.ept-mini:nth-of-type(4) th { top: calc(var(--ept-h1) + var(--ept-hm) * 2); }
.ept-se-table thead tr.ept-mini:nth-of-type(5) th { top: calc(var(--ept-h1) + var(--ept-hm) * 3); }

/* Compact print panel and group grid */
.ept-print-50 { width: 100%; max-width: 100%; }
.ept-print-grid-4 { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row; gap: 6px; align-items: start; }
/* Prevent label wrapping inside the grid while preserving original LI padding */
.ept-print-grid-4 > * { white-space: nowrap; min-width: 0; }
@media (max-width: 800px){
  .ept-print-50 { flex-basis: 100%; max-width: 100%; }
  .ept-print-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Ensure horizontal scrollbar is anchored to container */
.ept-se-scroll { overflow: auto; overscroll-behavior: contain; }
/* Top horizontal scrollbar rail synced with table */
.ept-se-scroll-top { position: sticky; top: 0; z-index: 7; background: var(--epc-surface-850, #0b1220); padding: 0; height: 14px; display: block; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--epc-border-700, rgba(255,255,255,.12)); }
.ept-se-scroll-top::-webkit-scrollbar { height: 10px; }
.ept-se-scroll-top::-webkit-scrollbar-thumb { background: var(--epc-border-600, rgba(255,255,255,.25)); border-radius: 8px; }
.ept-se-scroll-spacer { height: 1px; }
/* Light/Dark friendly sticky backgrounds */
.ept-se-table thead th, .ept-se-table .ept-sticky-col { color: inherit; }
.ept-group-header td { background: #2a2a2a; }

/* Tiny caret buttons */
.ept-caret { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; background: rgba(0,0,0,.15); cursor: pointer; }
.ept-caret svg { display:block; }

/* Sticky header for Matches view controls */
.ept-controls { position: sticky; top: 0; z-index: 50; background: var(--epc-surface-850, #0b1220); border-radius: 12px; }
.ept-controls .ept-controls-right { margin-left: auto; display:flex; gap:10px; align-items:center; }
.ept-toggle { display:inline-flex; align-items:center; gap:6px; font-size:12px; opacity:.9; }

/* Floating Print panel */
.ept-print-flyout-toggle { position: relative; }

/* Ensure hidden overlay doesn't block clicks */
.ept-loading-overlay[style*="display: none"] { pointer-events: none !important; }
/* Loading overlay */
.ept-loading-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(0,0,0,.25); z-index: 10; }
.ept-se-scroll { position: relative; }

/* Ensure preview creates stacking context so sticky rails/overlays are clipped within */
#ept-preview { position: relative; z-index: 0; overflow-x: hidden; }

/* Avoid header flashing/bleed through with sticky elements */
.ept-se-table thead th { background-clip: padding-box; contain: paint; }
.ept-se-table .ept-sticky-col { background-clip: padding-box; contain: paint; }
/* Smoother scroll and fewer repaints */
.ept-se-scroll { will-change: scroll-position; transform: translateZ(0); }

/* Prevent controls row from creating horizontal scroll when items wrap */
.ept-controls { overflow-x: hidden; }

/* Light mode overrides (when no EPCore tokens are defined, prefer light backgrounds) */
@media (prefers-color-scheme: light){
  .ept-se-table thead th { background: var(--epc-surface-100, #f8fafc); color: var(--epc-text-900, #0b1220); }
  .ept-se-table .ept-sticky-col { background: var(--epc-surface-150, #f1f5f9); color: var(--epc-text-900, #0b1220); }
  .ept-controls { background: var(--epc-surface-100, #f8fafc); }
  .ept-group-header td { background: var(--epc-surface-200, #e5e7eb); }
}
/* Explicit light mode toggles (overrides OS Dark preference) */
:root[data-theme="light"] .ept-se-wrap, body.theme-light .ept-se-wrap, body.light .ept-se-wrap { background: #f9fafb; border-color: #ddd; }
:root[data-theme="light"] .ept-se-table, body.theme-light .ept-se-table, body.light .ept-se-table { background: #ffffff; color: #374151; }
:root[data-theme="light"] .ept-se-table thead, body.theme-light .ept-se-table thead, body.light .ept-se-table thead { background: #ffffff; }
:root[data-theme="light"] .ept-se-table thead th, body.theme-light .ept-se-table thead th, body.light .ept-se-table thead th { background: var(--epc-surface-100, #f8fafc); color: var(--epc-text-900, #0b1220); border-color: rgba(0,0,0,.1); }
:root[data-theme="light"] .ept-se-table .ept-sticky-col, body.theme-light .ept-se-table .ept-sticky-col, body.light .ept-se-table .ept-sticky-col { background: #dbeafe; color: var(--epc-text-900, #0b1220); border-color: rgba(0,0,0,.1); }
:root[data-theme="light"] .ept-se-table th.left, body.theme-light .ept-se-table th.left, body.light .ept-se-table th.left { background: #dbeafe; color: var(--epc-text-900, #0b1220); border-color: rgba(0,0,0,.1); }
:root[data-theme="light"] .ept-se-table td.left, body.theme-light .ept-se-table td.left, body.light .ept-se-table td.left { background: #dbeafe; color: var(--epc-text-900, #0b1220); border-color: rgba(0,0,0,.1); }
:root[data-theme="light"] .ept-se-table th, :root[data-theme="light"] .ept-se-table td, body.theme-light .ept-se-table th, body.theme-light .ept-se-table td, body.light .ept-se-table th, body.light .ept-se-table td { border-color: rgba(0,0,0,.1); color: #374151; }
:root[data-theme="light"] .ept-se-table tr:nth-child(even) td, body.theme-light .ept-se-table tr:nth-child(even) td, body.light .ept-se-table tr:nth-child(even) td { background-color: #f9fafb; }
:root[data-theme="light"] .ept-se-table tr:nth-child(even) td.left, body.theme-light .ept-se-table tr:nth-child(even) td.left, body.light .ept-se-table tr:nth-child(even) td.left { background-color: #bfdbfe; }
:root[data-theme="light"] .ept-se-table input, body.theme-light .ept-se-table input, body.light .ept-se-table input { background: rgba(0,0,0,0.04); color: #111827; }
:root[data-theme="light"] .ept-controls, body.theme-light .ept-controls, body.light .ept-controls { background: var(--epc-surface-100, #f8fafc); }
:root[data-theme="light"] .ept-grp-hdr, body.theme-light .ept-grp-hdr, body.light .ept-grp-hdr { background: #eff6ff !important; color: #5c7fe3 !important; }
:root[data-theme="light"] .ept-grp-hdr td, body.theme-light .ept-grp-hdr td, body.light .ept-grp-hdr td { background: #eff6ff !important; border-color: rgba(0,0,0,.1); }
.ept-loading-spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: rgba(255,255,255,.85); animation: eptSpin 0.8s linear infinite; }
.ept-loading-text { font-size: 13px; opacity: .9; }
@keyframes eptSpin { to { transform: rotate(360deg); } }
@media (max-width: 700px){
    .ept-grid { grid-template-columns: 1fr; }
    .ept-row { flex-direction: column; }
    .ept-row-actions { justify-content: flex-end; }
}


/* --- Tournament Results Light Mode Overrides --- */
/* Force light backgrounds when light theme is active, overriding dark mode media queries */
:root[data-theme="light"] .ept-tr-wrap, body.theme-light .ept-tr-wrap, body.light .ept-tr-wrap {
    background: #f9fafb;
    color: #374151;
}
:root[data-theme="light"] .ept-tr-card, body.theme-light .ept-tr-card, body.light .ept-tr-card {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #374151;
}
:root[data-theme="light"] .ept-tr-section-toggle, body.theme-light .ept-tr-section-toggle, body.light .ept-tr-section-toggle,
:root[data-theme="light"] .ept-tr-detail-toggle, body.theme-light .ept-tr-detail-toggle, body.light .ept-tr-detail-toggle {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #111827;
}
:root[data-theme="light"] .ept-tr-title, body.theme-light .ept-tr-title, body.light .ept-tr-title {
    color: #111827;
}
:root[data-theme="light"] .ept-tr-sub, body.theme-light .ept-tr-sub, body.light .ept-tr-sub {
    color: #6b7280;
}

/* Table Header & Cells */
:root[data-theme="light"] .ept-tr-table th, body.theme-light .ept-tr-table th, body.light .ept-tr-table th {
    background: #ffffff;
    color: #111827;
    border-color: #e5e7eb;
}
:root[data-theme="light"] .ept-tr-table td, body.theme-light .ept-tr-table td, body.light .ept-tr-table td {
    color: #374151;
    border-color: #e5e7eb;
}

/* Row Striping for Results Table (Light Mode) */
:root[data-theme="light"] .ept-tr-table tr:nth-child(even) td, body.theme-light .ept-tr-table tr:nth-child(even) td, body.light .ept-tr-table tr:nth-child(even) td {
    background-color: #f9fafb; /* Gray 50 */
}

/* Sticky Columns (Default) */
:root[data-theme="light"] .ept-tr-table th.left, body.theme-light .ept-tr-table th.left, body.light .ept-tr-table th.left {
    background: #f9fafb;
    color: #111827;
}
:root[data-theme="light"] .ept-tr-table td.left, body.theme-light .ept-tr-table td.left, body.light .ept-tr-table td.left {
    background: #f9fafb;
    color: #111827;
}

/* Club Specific Themes (Light Mode) */
/* Team A: Blue (Darker Blue 100) */
:root[data-theme="light"] .ept-tr-score--a, body.theme-light .ept-tr-score--a, body.light .ept-tr-score--a {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}
:root[data-theme="light"] .ept-tr-table td.left.ept-player-club-a, body.theme-light .ept-tr-table td.left.ept-player-club-a, body.light .ept-tr-table td.left.ept-player-club-a {
    background: #dbeafe !important;
    color: #1e40af;
}
:root[data-theme="light"] .ept-tr-status--win-a, body.theme-light .ept-tr-status--win-a, body.light .ept-tr-status--win-a {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

/* Team B: Slate (Darker Slate 200) */
:root[data-theme="light"] .ept-tr-score--b, body.theme-light .ept-tr-score--b, body.light .ept-tr-score--b {
    background: #e2e8f0;
    color: #334155;
    border-color: #cbd5e1;
}
:root[data-theme="light"] .ept-tr-table td.left.ept-player-club-b, body.theme-light .ept-tr-table td.left.ept-player-club-b, body.light .ept-tr-table td.left.ept-player-club-b {
    background: #e2e8f0 !important;
    color: #334155;
}
:root[data-theme="light"] .ept-tr-status--win-b, body.theme-light .ept-tr-status--win-b, body.light .ept-tr-status--win-b {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
}

/* Team B Points Label */
:root[data-theme="light"] .ept-tr-score--b .ept-tr-points, body.theme-light .ept-tr-score--b .ept-tr-points, body.light .ept-tr-score--b .ept-tr-points {
    color: #ffffff;
}


/* Fix Points Mini text color in Light Mode (ensure contrast) */
:root[data-theme="light"] .ept-tr-points-mini,
body.theme-light .ept-tr-points-mini,
body.light .ept-tr-points-mini {
    color: #111827;
}