:root {
    --accent: #cba052;
    --q-direct: #3e8a34;
    --q-playoff: #76ba1b;
    --q-orange: #ff9800;
    --q-red: #e91e63;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Light mode by default */
body {
    --bg: #e0e0e0;
    --shadow-dark: #bebebe;
    --shadow-light: #ffffff;
    --text: #444;
}

/* Dark mode: system preference */
@media (prefers-color-scheme: dark) {
    body {
        --bg: #2c2c2c;
        --shadow-dark: #1a1a1a;
        --shadow-light: #3e3e3e;
        --text: #ddd;
    }
}

/* Manual overrides via JS */
body.dark-mode {
    --bg: #2c2c2c;
    --shadow-dark: #1a1a1a;
    --shadow-light: #3e3e3e;
    --text: #ddd;
}

body.light-mode {
    --bg: #e0e0e0;
    --shadow-dark: #bebebe;
    --shadow-light: #ffffff;
    --text: #444;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    padding: 20px;
    transition: background 0.3s ease;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.main-layout {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.column {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
}

.neumo-card {
    background: var(--bg);
    border-radius: 20px;
    box-shadow: 10px 10px 20px var(--shadow-dark),
                -10px -10px 20px var(--shadow-light);
    padding: 20px;
}

.neumo-inset {
    background: var(--bg);
    border-radius: 12px;
    box-shadow: inset 4px 4px 8px var(--shadow-dark),
                inset -4px -4px 8px var(--shadow-light);
    padding: 10px 20px;
    font-weight: bold;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 8px;
    text-align: center;
}

tr {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Couleurs de positions */
.pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    background: var(--bg);
    box-shadow: 3px 3px 6px var(--shadow-dark),
                -3px -3px 6px var(--shadow-light);
    transition: 0.3s;
}

.p-direct { color: var(--q-direct); border: 3px solid rgba(63, 128, 54, 0.2); }
.p-playoff { color: var(--q-playoff); border: 3px solid rgba(118, 186, 27, 0.2); }
.p-access { color: var(--q-orange); border: 3px solid rgba(255, 152, 0, 0.2); }
.p-releg { color: var(--q-red); border: 3px solid rgba(233, 30, 99, 0.2); }
.p-neutral { color: var(--text); background: none; }

.neumo-btn {
    border: none;
    background: var(--bg);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 5px 5px 10px var(--shadow-dark),
                -5px -5px 10px var(--shadow-light);
    cursor: pointer;
    color: var(--text);
    font-weight: bold;
}

.neumo-btn:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark),
                inset -3px -3px 6px var(--shadow-light);
}

.matches-card-shell {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 16px;
}

.nav-container {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.nav-btn {
    width: 52px;
    height: 52px;
    min-width: 52px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    border-radius: 14px;
    flex-shrink: 0;
}

.nav-container > * {
    min-width: 0;
}

#round-label {
    width: 100%;
    text-align: center;
    padding: 14px 18px;
    font-size: 1rem;
    border-radius: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#matches-section {
    width: 100%;
    margin: 0 auto;
    padding: 4px 0 0 0;
}

#matches-list {
    width: 100%;
    margin: 0 auto;
}

.match-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 15px;
    box-shadow: 3px 3px 8px var(--shadow-dark),
                -3px -3px 8px var(--shadow-light);
}

.team-name {
    font-size: 0.92rem;
    font-weight: 500;
    min-width: 0;
}

.team-home {
    text-align: right;
}

.team-away {
    text-align: left;
}

.score-block {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.score-selector,
.fixed-score {
    background: var(--bg);
    border: none;
    border-radius: 8px;
    box-shadow: inset 2px 2px 4px var(--shadow-dark),
                inset -2px -2px 4px var(--shadow-light);
    padding: 6px 8px;
    color: var(--accent);
    font-weight: bold;
    min-width: 36px;
    text-align: center;
}

.playoffs-section {
    margin: 0 auto 28px;
    padding: 20px 24px;
    border-radius: 16px;
    background: var(--bg);
    box-shadow: 10px 10px 20px var(--shadow-dark),
                -10px -10px 20px var(--shadow-light);
    max-width: 980px;
}

.playoffs-section h2 {
    margin-bottom: 8px;
    text-align: center;
}

.playoffs-note {
    margin-bottom: 18px;
    opacity: 0.8;
    text-align: center;
}

.playoffs-bracket {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.playoff-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.playoff-column h3 {
    margin: 0;
    text-align: center;
}

.playoff-column-final {
    align-self: center;
}

.playoff-match {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(127, 127, 127, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.playoff-match-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    opacity: 0.9;
}

.playoff-team {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.playoff-team:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
}

.playoff-team.is-winner {
    border-color: #cba052;
    box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.18);
    background: rgba(242, 201, 76, 0.12);
    font-weight: 700;
}

.playoff-team.is-empty,
.playoff-team:disabled {
    opacity: 0.5;
    cursor: default;
}

.playoff-team-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.playoff-seed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255,255,255,0.08);
    color: var(--accent);
}

.playoff-team-name {
    flex: 1;
}

.virtual-champion {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
    background: rgba(203, 160, 82, 0.12);
    border: 1px solid rgba(203, 160, 82, 0.25);
}

.neumo-theme-toggle {
    display: inline-flex;
    align-items: center;
}

.theme-slider {
    position: relative;
    width: 68px;
    height: 26px;
    border-radius: 99px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 9px;
}

.theme-thumb {
    position: absolute;
    width: 30px;
    height: 20px;
    border-radius: 99px;
    left: 3px;
    transition: left 220ms cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    background: var(--bg);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.theme-slider[aria-checked="true"] .theme-thumb {
    left: calc(100% - 33px);
}

.theme-label {
    color: var(--text);
    opacity: 0.45;
    position: relative;
    z-index: 1;
    pointer-events: none;
    transition: opacity 220ms, color 220ms;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.theme-slider[aria-checked="false"] .theme-light,
.theme-slider[aria-checked="true"] .theme-dark {
    opacity: 1;
    color: var(--accent);
}

.theme-slider:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.theme-icon {
    width: 11px;
    height: 11px;
    display: block;
}

/* ── Interlude card ── */
.interlude-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 32px 24px;
    text-align: center;
    gap: 16px;
}

.interlude-title {
    background: var(--bg);
    border-radius: 12px;
    box-shadow: inset 4px 4px 8px var(--shadow-dark),
                inset -4px -4px 8px var(--shadow-light);
    padding: 10px 20px;
    font-weight: bold;
}

.interlude-content {
    font-size: 1rem;
    opacity: 0.8;
    line-height: 1.6;
}

/* ── Monte-Carlo ── */
.mc-card {
    width: 100%;
    max-width: 920px;
    margin: 24px auto 0;
    padding: 16px 18px;
    border-radius: 22px;
}

.mc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.mc-header h2 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.1;
}

.mc-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 0.92rem;
}

.mc-body {
    width: 100%;
    overflow-x: auto;
}

.mc-warning {
    margin: 0 0 12px 0;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #8a6d1d;
    background: #fff4cc;
    border: 1px solid #f0d98a;
}

.mc-warning-error {
    color: #8f3b46;
    background: #f8d7dd;
    border: 1px solid #e7aeb8;
}

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

.mc-body-shell {
    width: 100%;
}

.mc-body {
    position: relative;
    width: 100%;
    overflow-x: auto;
}

.mc-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(2px);
    border-radius: 14px;
}

.mc-overlay-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 14px;
    background: var(--bg);
    color: var(--text);
    box-shadow: 8px 8px 18px var(--shadow-dark),
                -8px -8px 18px var(--shadow-light);
    font-size: 0.95rem;
    font-weight: 600;
}

.mc-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(127, 127, 127, 0.25);
    border-top-color: currentColor;
    animation: mc-spin 0.8s linear infinite;
}

.mc-table {
    width: 100%;
    min-width: 780px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.90rem;
    line-height: 1.2;
}

.mc-table thead th {
    padding: 8px 8px 10px;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    vertical-align: bottom;
    white-space: normal;
    opacity: 0.78;
}

.mc-table tbody td {
    padding: 8px 8px;
    text-align: center;
    vertical-align: middle;
}

.mc-table th,
.mc-table td {
    border-bottom: 1px solid rgba(127, 127, 127, 0.16);
}

.mc-table tbody tr:last-child td {
    border-bottom: none;
}

.mc-table th:nth-child(1),
.mc-table td:nth-child(1) {
    width: 44px;
}

.mc-table th:nth-child(2),
.mc-table td:nth-child(2) {
    width: 26%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mc-table th:nth-child(3),
.mc-table td:nth-child(3) {
    width: 150px;
    white-space: nowrap;
}

.mc-table th:nth-child(4),
.mc-table td:nth-child(4),
.mc-table th:nth-child(5),
.mc-table td:nth-child(5),
.mc-table th:nth-child(6),
.mc-table td:nth-child(6),
.mc-table th:nth-child(7),
.mc-table td:nth-child(7) {
    width: 82px;
    white-space: nowrap;
}

.pts-breakdown {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.82em;
    color: var(--text-muted, #777);
    white-space: nowrap;
}

.pct-zero,
.pct-low,
.pct-mid,
.pct-high,
.pct-certain {
    display: inline-block;
    min-width: 38px;
    white-space: nowrap;
}

.pct-zero {
    opacity: 0.25;
}

.pct-certain {
    color: var(--accent, #4caf50);
    font-weight: 700;
}

.pct-high {
    font-weight: 700;
}

.pct-mid {
    opacity: 0.85;
}

.pct-low {
    opacity: 0.55;
}

.mc-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.info-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-tooltip-trigger {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
}

.info-tooltip-box {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%) translateY(6px);
    width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg);
    color: var(--text);
    box-shadow: 8px 8px 18px var(--shadow-dark),
                -8px -8px 18px var(--shadow-light);
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: left;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.info-tooltip-box::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 12px;
    height: 12px;
    background: var(--bg);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 3px 3px 6px var(--shadow-dark);
}

.info-tooltip-trigger:hover + .info-tooltip-box,
.info-tooltip-trigger:focus-visible + .info-tooltip-box,
.info-tooltip-wrap:hover .info-tooltip-box {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 700px) {
    .mc-title-wrap {
        flex-wrap: wrap;
    }

    .info-tooltip-box {
        left: 0;
        transform: translateX(0) translateY(6px);
        width: min(340px, calc(100vw - 40px));
    }

    .info-tooltip-box::after {
        left: 24px;
        transform: rotate(45deg);
    }

    .info-tooltip-trigger:hover + .info-tooltip-box,
    .info-tooltip-trigger:focus-visible + .info-tooltip-box,
    .info-tooltip-wrap:hover .info-tooltip-box {
        transform: translateX(0) translateY(0);
    }
}

@media (max-width: 900px) {
    .playoffs-bracket {
        grid-template-columns: 1fr;
    }

    .playoff-column-final {
        align-self: stretch;
    }

    .mc-card {
        padding: 14px 14px;
    }

    .mc-header {
        align-items: stretch;
        flex-direction: column;
    }

    .mc-btn {
        width: 100%;
    }

    .mc-table {
        min-width: 720px;
        font-size: 0.86rem;
    }

    .mc-table thead th,
    .mc-table tbody td {
        padding: 7px 6px;
    }

    .mc-table th:nth-child(3),
    .mc-table td:nth-child(3) {
        width: 138px;
    }

    .mc-table th:nth-child(4),
    .mc-table td:nth-child(4),
    .mc-table th:nth-child(5),
    .mc-table td:nth-child(5),
    .mc-table th:nth-child(6),
    .mc-table td:nth-child(6),
    .mc-table th:nth-child(7),
    .mc-table td:nth-child(7) {
        width: 74px;
    }
}

@media (max-width: 700px) {
    body {
        padding: 14px;
    }

    .matches-card-shell {
        padding: 12px;
    }

    .nav-container {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        gap: 10px;
    }

    .nav-btn {
        width: 44px;
        height: 44px;
    }

    #round-label {
        font-size: 0.95rem;
        padding: 12px 10px;
    }

    .match-row {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }

    .team-home,
    .team-away {
        text-align: center;
    }

    .score-block {
        order: -1;
    }
}



.prediction-hex-toolbar {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem 0.55rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr) 38px;
  gap: 0.5rem;
  align-items: center;
}

#prediction-hex-output,
#prediction-hex-input {
  min-width: 0;
  height: 38px;
  padding: 0 0.75rem;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1;
  text-transform: none;
  outline: none;
  box-shadow: inset 2px 2px 4px var(--shadow-dark),
              inset -2px -2px 4px var(--shadow-light);
}

#prediction-hex-output:focus,
#prediction-hex-input:focus {
  box-shadow: inset 0 0 0 1px #cba052,
              inset 2px 2px 4px var(--shadow-dark),
              inset -2px -2px 4px var(--shadow-light);
}

#prediction-hex-output {
  opacity: 0.78;
}

#prediction-hex-output::placeholder,
#prediction-hex-input::placeholder {
  opacity: 0.55;
}

#prediction-hex-output::selection,
#prediction-hex-input::selection {
  background: #cba052;
  color: #1f1f1f;
}

#prediction-hex-output::-moz-selection,
#prediction-hex-input::-moz-selection {
  background: #cba052;
  color: #1f1f1f;
}

.prediction-hex-icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prediction-hex-icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#prediction-hex-input.is-error {
  color: #b42318;
  box-shadow: inset 2px 2px 4px rgba(120, 28, 28, 0.16),
              inset -2px -2px 4px rgba(255, 255, 255, 0.5);
}

#prediction-hex-input.is-error::placeholder {
  color: #b42318;
  opacity: 0.95;
}

@media (max-width: 700px) {
  .prediction-hex-toolbar {
    grid-template-columns: minmax(0, 1fr) 38px;
  }
}