/* Theme Phreaks 2600.
 *
 * Surcouche du CSS compile du theme core (Bootstrap 5.3) : on redefinit ses
 * variables plutot que de reecrire les composants, pour suivre les mises a
 * jour de CTFd sans rebuild. Sombre uniquement.
 */

/* --- Polices (IBM Plex, OFL, voir fonts/OFL.txt) ----------------------- */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Palette ---------------------------------------------------------- */

:root,
[data-bs-theme="dark"] {
  /* Fond du header (barre + bandeau de titre) : lie-de-vin tres sombre a
     gauche, fondu dans le noir. */
  --ph-header-bg: linear-gradient(90deg, #1e0c0c 0%, #140b0b 22%, #0d0b0b 48%, #0a0a0a 100%);
  --ph-header-line: #2a1d1d;
  --ph-bg: #0a0a0a;
  --ph-surface: #111111;
  --ph-surface-2: #181818;
  --ph-line: #262626;
  --ph-line-strong: #3a3a3a;
  --ph-text: #ececec;
  --ph-muted: #8c8c8c;
  --ph-faint: #5c5c5c;
  --ph-red: #e10600;
  --ph-red-hover: #ff2a1f;
  --ph-red-ink: #ff4d45;      /* rouge lisible en texte sur fond noir */
  --ph-red-wash: #1c0807;     /* fond des elements resolus / actifs */
  --ph-ok: #4fae6a;

  --ph-sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --ph-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --bs-body-font-family: var(--ph-sans);
  --bs-font-monospace: var(--ph-mono);
  --bs-body-bg: var(--ph-bg);
  --bs-body-bg-rgb: 10, 10, 10;
  --bs-body-color: var(--ph-text);
  --bs-body-color-rgb: 236, 236, 236;
  --bs-emphasis-color: #ffffff;
  --bs-secondary-color: var(--ph-muted);
  --bs-secondary-bg: var(--ph-surface-2);
  --bs-tertiary-color: var(--ph-faint);
  --bs-tertiary-bg: var(--ph-surface);
  --bs-border-color: var(--ph-line);
  --bs-border-color-translucent: var(--ph-line);
  --bs-border-radius: 2px;
  --bs-border-radius-sm: 2px;
  --bs-border-radius-lg: 2px;
  --bs-border-radius-pill: 2px;
  --bs-heading-color: #ffffff;
  --bs-link-color: var(--ph-red-ink);
  --bs-link-color-rgb: 255, 77, 69;
  --bs-link-hover-color: #ffffff;
  --bs-link-hover-color-rgb: 255, 255, 255;
  --bs-code-color: #f2f2f2;
  --bs-primary: var(--ph-red);
  --bs-primary-rgb: 225, 6, 0;
  --bs-danger: var(--ph-red);
  --bs-danger-rgb: 225, 6, 0;
  --bs-info: var(--ph-muted);
  --bs-info-rgb: 140, 140, 140;
  --bs-dark: var(--ph-surface);
  --bs-dark-rgb: 17, 17, 17;
  --bs-focus-ring-color: rgba(225, 6, 0, 0.35);
}

html {
  color-scheme: dark;
}

/* Le core force Lato sur html/body/.container et Raleway sur les en-tetes. */
html,
body,
.container,
.jumbotron .container {
  font-family: var(--ph-sans);
}

body {
  background: var(--ph-bg);
  color: var(--ph-text);
  font-size: 0.975rem;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--ph-red);
  color: #ffffff;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--ph-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #ffffff;
}

code, kbd, pre, samp, .font-monospace {
  font-family: var(--ph-mono);
}

:not(pre) > code {
  background: var(--ph-surface-2);
  border: 1px solid var(--ph-line);
  padding: 0.05em 0.3em;
}

pre {
  background: var(--ph-surface);
  border: 1px solid var(--ph-line);
  padding: 0.75rem 1rem;
  color: var(--ph-text);
}

blockquote {
  border-left: 2px solid var(--ph-red);
  color: var(--ph-muted);
}

hr {
  border-color: var(--ph-line);
  opacity: 1;
}

.text-muted,
.text-secondary {
  color: var(--ph-muted) !important;
}

/* --- Navigation ------------------------------------------------------- */

.navbar {
  background: var(--ph-header-bg);
  border-bottom: 1px solid var(--ph-header-line);
  padding-top: 0;
  padding-bottom: 0;
  min-height: 3.5rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
  padding: 0.125rem 0;
}

/* Logo "classic" : 3x sa taille d'affichage, pour les ecrans denses. */
.brand-logo {
  display: block;
  width: auto;
  height: 52px;
  filter: saturate(0.82) brightness(0.92);
  transition: filter 0.15s ease;
}

.navbar-brand:hover .brand-logo {
  filter: none;
}

.navbar-brand:hover {
  color: #ffffff;
}

.brand-event {
  font-family: var(--ph-mono);
  font-size: 0.75rem;
  color: var(--ph-muted);
  padding-left: 0.75rem;
  border-left: 1px solid var(--ph-line-strong);
  line-height: 1.6;
}

.navbar .nav-link {
  color: var(--ph-muted);
  font-size: 0.875rem;
  padding: 1.05rem 0.75rem !important;
  border-bottom: 2px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus-visible {
  color: #ffffff;
}

.navbar .nav-link.active {
  color: #ffffff;
  border-bottom-color: rgba(236, 236, 236, 0.7);
}

.navbar-toggler {
  border: 1px solid var(--ph-line-strong);
  border-radius: 2px;
}

.navbar-toggler:focus {
  box-shadow: none;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ececec' stroke-width='2' d='M4 8h22M4 15h22M4 22h22'/%3e%3c/svg%3e");
}

@media (max-width: 767.98px) {
  .navbar-collapse {
    border-top: 1px solid var(--ph-line);
    padding-bottom: 0.5rem;
  }

  .navbar .nav-link {
    padding: 0.6rem 0 !important;
    border-bottom: 0;
    border-left: 2px solid transparent;
  }

  .navbar .nav-link.active {
    border-left-color: rgba(236, 236, 236, 0.7);
    padding-left: 0.6rem !important;
  }

  .brand-event {
    display: none;
  }
}

.navbar hr {
  display: none !important;
}

.badge-notification {
  background: var(--ph-red) !important;
  border-radius: 2px !important;
}

.dropdown-menu {
  --bs-dropdown-bg: var(--ph-surface);
  --bs-dropdown-border-color: var(--ph-line-strong);
  --bs-dropdown-link-color: var(--ph-text);
  --bs-dropdown-link-hover-bg: var(--ph-surface-2);
  --bs-dropdown-link-hover-color: #ffffff;
  --bs-dropdown-link-active-bg: var(--ph-red);
  border-radius: 2px;
  font-size: 0.875rem;
}

.dropdown-item.bg-primary {
  background: var(--ph-red-wash) !important;
  color: var(--ph-red-ink) !important;
}

/* --- En-tete de page (remplace le "jumbotron" centre du core) ---------- */

.jumbotron {
  /* Prolonge la barre : meme degrade, fondu vers le noir en bas. */
  background:
    linear-gradient(180deg, rgba(10, 10, 10, 0) 0%, rgba(10, 10, 10, 0.55) 100%),
    var(--ph-header-bg);
  color: var(--ph-text);
  text-align: left;
  padding: 3.5rem 0 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--ph-header-line);
}

.jumbotron h1 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  letter-spacing: -0.02em;
  margin: 0;
}

.jumbotron h1::before {
  content: "";
  display: block;
  width: 2rem;
  height: 2px;
  background: #8a2a24;
  margin-bottom: 1rem;
}

.jumbotron h2,
.jumbotron h3,
.jumbotron h4 {
  color: var(--ph-muted);
  font-weight: 400;
}

@media (min-width: 576px) {
  .jumbotron {
    padding: 4.5rem 0 2rem;
  }
}

/* --- Boutons ---------------------------------------------------------- */

.btn {
  --bs-btn-border-radius: 2px;
  --bs-btn-font-weight: 600;
  --bs-btn-focus-box-shadow: 0 0 0 2px rgba(225, 6, 0, 0.45);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn-primary,
.btn-danger,
.btn-info {
  --bs-btn-color: #ffffff;
  --bs-btn-bg: var(--ph-red);
  --bs-btn-border-color: var(--ph-red);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--ph-red-hover);
  --bs-btn-hover-border-color: var(--ph-red-hover);
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: #b80500;
  --bs-btn-active-border-color: #b80500;
  --bs-btn-disabled-color: #ffffff;
  --bs-btn-disabled-bg: #5a0f0c;
  --bs-btn-disabled-border-color: #5a0f0c;
}

.btn-secondary,
.btn-dark,
.btn-success,
.btn-outline-secondary,
.btn-outline-info,
.btn-outline-primary {
  --bs-btn-color: var(--ph-text);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--ph-line-strong);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--ph-surface-2);
  --bs-btn-hover-border-color: var(--ph-muted);
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: var(--ph-surface-2);
  --bs-btn-active-border-color: var(--ph-red);
  --bs-btn-disabled-color: var(--ph-faint);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--ph-line);
}

.btn-outline-danger {
  --bs-btn-color: var(--ph-red-ink);
  --bs-btn-border-color: #5a0f0c;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--ph-red);
  --bs-btn-hover-border-color: var(--ph-red);
  --bs-btn-active-bg: var(--ph-red);
  --bs-btn-active-border-color: var(--ph-red);
}

.btn-outline-success {
  --bs-btn-color: var(--ph-ok);
  --bs-btn-border-color: #234d2f;
  --bs-btn-hover-color: #0a0a0a;
  --bs-btn-hover-bg: var(--ph-ok);
  --bs-btn-hover-border-color: var(--ph-ok);
  --bs-btn-active-color: #0a0a0a;
  --bs-btn-active-bg: var(--ph-ok);
  --bs-btn-active-border-color: var(--ph-ok);
}

.btn-close {
  filter: invert(1) grayscale(1);
  opacity: 0.6;
}

.btn-close:hover {
  opacity: 1;
}

/* --- Formulaires ------------------------------------------------------ */

.form-control,
.form-select {
  background-color: var(--ph-surface);
  border: 1px solid var(--ph-line-strong);
  border-radius: 2px;
  color: var(--ph-text);
}

.form-control::placeholder {
  color: var(--ph-faint);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--ph-surface);
  border-color: var(--ph-red);
  box-shadow: none;
  color: #ffffff;
}

.form-label,
label {
  font-size: 0.85rem;
  color: var(--ph-muted);
}

.form-label b,
label b {
  font-weight: 600;
}

.form-check-input {
  background-color: var(--ph-surface);
  border-color: var(--ph-line-strong);
  border-radius: 2px;
}

.form-check-input:checked {
  background-color: var(--ph-red);
  border-color: var(--ph-red);
}

.form-check-input:focus {
  box-shadow: none;
  border-color: var(--ph-red);
}

.form-text {
  color: var(--ph-faint);
}

/* --- Alertes et badges ------------------------------------------------ */

.alert {
  --bs-alert-border-radius: 2px;
  background: var(--ph-surface);
  border: 1px solid var(--ph-line-strong);
  border-left-width: 3px;
  color: var(--ph-text);
}

.alert-danger {
  border-left-color: var(--ph-red);
  background: var(--ph-red-wash);
}

.alert-success {
  border-left-color: var(--ph-ok);
}

.alert-info,
.alert-secondary {
  border-left-color: var(--ph-muted);
}

.alert-warning {
  border-left-color: #c98a1b;
}

.badge {
  border-radius: 2px;
  font-family: var(--ph-mono);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.badge.bg-info,
.badge.bg-secondary {
  background: transparent !important;
  border: 1px solid var(--ph-line-strong);
  color: var(--ph-muted) !important;
}

.badge.bg-primary,
.badge.bg-danger {
  background: var(--ph-red) !important;
}

/* --- Onglets et pilules ----------------------------------------------- */

.nav-tabs {
  --bs-nav-tabs-border-color: var(--ph-line);
  --bs-nav-tabs-border-radius: 0;
  --bs-nav-tabs-link-hover-border-color: transparent;
  --bs-nav-tabs-link-active-color: #ffffff;
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent;
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  color: var(--ph-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.nav-tabs .nav-link:hover {
  color: #ffffff;
}

.nav-tabs .nav-link.active {
  border-bottom-color: var(--ph-red);
}

.nav-pills {
  --bs-nav-pills-border-radius: 2px;
  --bs-nav-pills-link-active-color: #ffffff;
  --bs-nav-pills-link-active-bg: var(--ph-red-wash);
  border: 1px solid var(--ph-line);
}

.nav-pills .nav-link {
  color: var(--ph-muted);
  font-size: 0.875rem;
}

.nav-pills .nav-link.active {
  box-shadow: inset 0 -2px 0 var(--ph-red);
}

.pagination {
  --bs-pagination-bg: transparent;
  --bs-pagination-color: var(--ph-muted);
  --bs-pagination-border-color: var(--ph-line);
  --bs-pagination-hover-bg: var(--ph-surface-2);
  --bs-pagination-hover-color: #ffffff;
  --bs-pagination-hover-border-color: var(--ph-line-strong);
  --bs-pagination-active-bg: var(--ph-red);
  --bs-pagination-active-border-color: var(--ph-red);
  --bs-pagination-border-radius: 2px;
  --bs-pagination-focus-box-shadow: none;
}

/* --- Tableaux (scoreboard, listes) ------------------------------------ */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ph-text);
  --bs-table-border-color: var(--ph-line);
  --bs-table-striped-bg: transparent;
  --bs-table-striped-color: var(--ph-text);
  --bs-table-hover-bg: var(--ph-surface);
  --bs-table-hover-color: #ffffff;
  font-size: 0.925rem;
}

.table > thead {
  border-bottom: 1px solid var(--ph-line-strong);
}

.table > thead th {
  font-family: var(--ph-mono);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ph-muted);
  border-bottom: 0;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.table > tbody > tr > * {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.table > tbody > tr:hover > * {
  background: var(--ph-surface);
}

.table td:last-child,
.table th[scope="row"] {
  font-family: var(--ph-mono);
}

/* Podium : rang en rouge pour les trois premiers. */
#scoreboard tbody tr:nth-child(-n + 3) th[scope="row"] {
  color: var(--ph-red-ink);
  font-weight: 600;
}

#score-graph {
  border: 1px solid var(--ph-line);
  background: var(--ph-surface);
  margin-bottom: 1rem;
}

/* --- Tableau des challenges ------------------------------------------- */

.category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--ph-line);
  padding-bottom: 0.6rem;
}

.category-header h3 {
  font-family: var(--ph-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #ffffff;
  margin: 0;
}

.category-progress {
  font-family: var(--ph-mono);
  font-size: 0.8rem;
  color: var(--ph-muted);
}

.challenges-row {
  --bs-gutter-x: 0.75rem;
}

.challenges-row > div {
  margin-top: 0.375rem !important;
  margin-bottom: 0.375rem !important;
}

.challenge-button,
[data-bs-theme="dark"] .challenge-button,
[data-bs-theme="light"] .challenge-button {
  display: block;
  text-align: left;
  background: var(--ph-surface);
  border: 1px solid var(--ph-line);
  border-left: 3px solid var(--ph-line-strong);
  border-radius: 2px;
  box-shadow: none;
  color: var(--ph-text);
  padding: 0.9rem 1rem;
  min-height: 5.5rem;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.challenge-button:hover,
.challenge-button:focus-visible,
[data-bs-theme="dark"] .challenge-button:hover {
  background: var(--ph-surface-2);
  border-color: var(--ph-line-strong);
  border-left-color: var(--ph-red);
  color: #ffffff;
}

.challenge-button.challenge-solved,
[data-bs-theme="dark"] .challenge-button.challenge-solved,
[data-bs-theme="light"] .challenge-button.challenge-solved {
  background: var(--ph-red-wash);
  border-color: #3a0e0c;
  border-left-color: var(--ph-red);
  color: var(--ph-muted);
}

.challenge-button.challenge-solved:hover,
[data-bs-theme="dark"] .challenge-button.challenge-solved:hover {
  background: #240a09;
  color: var(--ph-text);
}

.challenge-inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  height: 100%;
}

.challenge-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.challenge-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--ph-mono);
  font-size: 0.78rem;
  color: var(--ph-muted);
}

.challenge-card-state {
  color: var(--ph-red-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

/* --- Fenetre d'un challenge ------------------------------------------- */

.modal {
  --bs-modal-bg: var(--ph-surface);
  --bs-modal-border-color: var(--ph-line-strong);
  --bs-modal-border-radius: 2px;
  --bs-modal-box-shadow: none;
}

.modal-backdrop {
  --bs-backdrop-bg: #000000;
  --bs-backdrop-opacity: 0.8;
}

.modal-content {
  border-top: 3px solid var(--ph-red);
}

.challenge-name {
  font-size: 1.6rem;
  text-align: left !important;
  padding-top: 1.5rem !important;
  margin-bottom: 0.25rem;
}

.challenge-value {
  font-family: var(--ph-mono);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--ph-red-ink);
  text-align: left !important;
  margin-bottom: 1rem;
}

.challenge-value::after {
  content: " pts";
}

.challenge-tags,
.challenge-attribution,
.challenge-ratings {
  text-align: left !important;
}

.challenge-desc {
  display: block;
  line-height: 1.65;
  margin: 1rem 0 1.25rem;
}

.challenge-desc h1,
.challenge-desc h2,
.challenge-desc h3,
.challenge-desc h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}

.challenge-desc h1,
.challenge-desc h2 {
  font-family: var(--ph-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ph-muted);
}

.challenge-desc pre,
.challenge-desc code {
  font-size: 0.85em;
}

.challenge-desc pre {
  white-space: pre-wrap;
}

/* La fenetre par defaut (500px) tronque les noms de fichiers. */
#challenge-window .modal-dialog:not(.modal-sm):not(.modal-lg) {
  max-width: min(760px, calc(100vw - 1rem));
}

.challenge-connection-info code {
  display: inline-block;
  background: var(--ph-bg);
  border: 1px solid var(--ph-line-strong);
  padding: 0.35rem 0.6rem;
  color: #ffffff;
}

.challenge-hints details {
  border: 1px solid var(--ph-line);
  border-left: 2px solid var(--ph-line-strong);
  margin-bottom: 0.5rem;
  background: var(--ph-bg);
}

.challenge-hints details[open] {
  border-left-color: var(--ph-red);
}

.challenge-hints summary {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--ph-muted);
  cursor: pointer;
}

.challenge-hints summary:hover {
  color: #ffffff;
}

.challenge-hints details > div {
  padding: 0 0.75rem 0.75rem;
}

.challenge-files {
  text-align: left !important;
}

.btn-file {
  --bs-btn-color: var(--ph-text);
  --bs-btn-bg: var(--ph-bg);
  --bs-btn-border-color: var(--ph-line-strong);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--ph-surface-2);
  --bs-btn-hover-border-color: var(--ph-red);
  font-family: var(--ph-mono);
  font-weight: 400;
  text-align: left;
}

.btn-file .fa-download {
  color: var(--ph-red-ink);
  margin-right: 0.35rem;
}

.challenge-input {
  font-family: var(--ph-mono);
}

.challenge-submit {
  --bs-btn-color: #ffffff;
  --bs-btn-bg: var(--ph-red);
  --bs-btn-border-color: var(--ph-red);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--ph-red-hover);
  --bs-btn-hover-border-color: var(--ph-red-hover);
  --bs-btn-active-bg: #b80500;
  --bs-btn-active-border-color: #b80500;
}

/* Panneau d'instance ctfd-whale. */
#whale-panel-stopped,
#whale-panel-started {
  --bs-card-bg: var(--ph-bg);
  --bs-card-border-color: var(--ph-line-strong);
  --bs-card-border-radius: 2px;
  text-align: left;
}

#whale-panel-stopped .card-title,
#whale-panel-started .card-title {
  font-family: var(--ph-mono);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ph-muted);
}

#whale-challenge-user-access {
  font-family: var(--ph-mono);
  color: #ffffff;
  background: var(--ph-surface);
  border: 1px solid var(--ph-line);
  padding: 0.5rem 0.75rem;
  overflow-wrap: anywhere;
}

#whale-panel-started .card-link + .card-link {
  margin-left: 0.5rem;
}

/* --- Cartes, listes, divers ------------------------------------------- */

.card {
  --bs-card-bg: var(--ph-surface);
  --bs-card-border-color: var(--ph-line);
  --bs-card-border-radius: 2px;
  --bs-card-cap-bg: var(--ph-surface-2);
}

.list-group {
  --bs-list-group-bg: var(--ph-surface);
  --bs-list-group-border-color: var(--ph-line);
  --bs-list-group-border-radius: 2px;
  --bs-list-group-active-bg: var(--ph-red);
  --bs-list-group-active-border-color: var(--ph-red);
}

.progress {
  --bs-progress-bg: var(--ph-surface-2);
  --bs-progress-bar-bg: var(--ph-red);
  --bs-progress-border-radius: 0;
}

.toast {
  --bs-toast-bg: var(--ph-surface);
  --bs-toast-border-color: var(--ph-line-strong);
  --bs-toast-border-radius: 2px;
  --bs-toast-header-bg: var(--ph-surface-2);
  --bs-toast-header-color: #ffffff;
}

.tooltip {
  --bs-tooltip-bg: #ffffff;
  --bs-tooltip-color: #0a0a0a;
  --bs-tooltip-border-radius: 2px;
  font-family: var(--ph-mono);
  font-size: 0.75rem;
}

.spinner {
  color: var(--ph-red);
  opacity: 0.8 !important;
}

/* --- Pied de page ----------------------------------------------------- */

.footer {
  border-top: 1px solid var(--ph-line);
  background: var(--ph-bg);
  font-family: var(--ph-mono);
  font-size: 0.75rem;
}

.footer .container {
  font-family: var(--ph-mono);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.footer-brand {
  color: var(--ph-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.footer-credit,
.footer-credit:hover {
  color: var(--ph-faint);
}

.footer-credit:hover {
  color: var(--ph-muted);
}

/* --- Page d'accueil (contenu de scripts/apply_theme.py) --------------- */

.ph-home {
  padding: 5rem 0 3rem;
}

.ph-home-eyebrow {
  font-family: var(--ph-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ph-red-ink);
  margin-bottom: 1.25rem;
}

.ph-home-title {
  font-size: clamp(2.5rem, 7vw, 4.75rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.ph-home-title span {
  color: var(--ph-red);
}

.ph-home-lead {
  max-width: 38rem;
  color: var(--ph-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.ph-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.ph-home-actions .btn {
  padding: 0.65rem 1.25rem;
}

.ph-home-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  border-top: 1px solid var(--ph-line);
  margin-top: 4rem;
}

.ph-home-facts > div {
  padding: 1.25rem 1.25rem 1.25rem 0;
  border-bottom: 1px solid var(--ph-line);
}

.ph-home-facts dt {
  font-family: var(--ph-mono);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ph-muted);
  margin-bottom: 0.4rem;
}

.ph-home-facts dd {
  margin: 0;
  color: var(--ph-text);
}

.ph-home-facts code {
  color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Etats vides ("Scoreboard is empty", listes vides). */
h3.text-center.text-muted {
  font-family: var(--ph-mono);
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3rem 0;
}
