:root {
  --bg: #4B1F58; /* violet foncé / bordeaux */
  --card: #3D144D;
  --ink: #F3F1F5; /* écru clair / blanc doux */
  --muted: #B799C4;
  --accent: #F5C621; /* jaune lumineux */
  --hit: #F5C621;
}

@keyframes starTwinkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0.6);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes starPulse {
  0%, 100% {
    opacity: 0.2;
    transform: scale(0.8);
  }
  40% {
    opacity: 0.9;
    transform: scale(1.3);
  }
  60% {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

@keyframes starSparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.6) rotate(35deg);
  }
}

html, body {
  min-height: 100%;
  background-color: #2c0f3f;
}

* { box-sizing: border-box }
body {
  margin:0;
  font-family: system-ui, sans-serif;
  background-image: radial-gradient(140% 120% at 50% -10%, #3D144D 0%, #261038 55%, #11051e 100%);
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-size: 140% 140%;
  background-position: center top;
  color: var(--ink);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 5, 30, 0.6), rgba(18, 5, 30, 0.9));
  pointer-events: none;
  z-index: -1;
}
a {
  color: var(--accent);
}
a:hover,
a:focus {
  color: #FFE27A;
}
.main-nav {
  display:flex;
  justify-content:center;
  flex-wrap:wrap;
  gap:12px;
  margin:16px auto 24px;
  padding:0 16px;
}
.main-nav a {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 16px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.2);
  background: rgba(61,20,77,0.6);
  color: var(--ink);
  text-decoration:none;
  font-weight:600;
}
.main-nav a:hover,
.main-nav a:focus {
  border-color: var(--accent);
  color: var(--accent);
}
header { text-align:center; padding: 24px 16px }
h1 { margin:0; font-size: clamp(22px, 3.5vw, 36px) }
p.lead { margin:.5rem 0 0; color: var(--muted) }

.toolbar { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin:16px 0 24px }
.toolbar .context-input { flex: 1 1 320px; min-width: 220px; }
.toolbar button.primary-button,
.toolbar button.secondary-button {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: var(--accent);
  color: #0f0716;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform .08s ease, background .2s ease, color .2s ease;
}
.toolbar button.secondary-button {
  background: transparent;
  color: var(--ink);
  border-color: rgba(255,255,255,0.35);
}
.toolbar button.primary-button:hover {
  transform: translateY(-1px);
  background: #fadc58;
}
.toolbar button.secondary-button:hover {
  transform: translateY(-1px);
  border-color: #fadc58;
  color: #fadc58;
}
.toolbar .link-button {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #fadc58;
  font-weight: 600;
  text-decoration: none;
}
.toolbar .link-button:hover {
  text-decoration: underline;
}
button, select, input[type="number"], input[type="text"], input[type="checkbox"] {
  background: var(--card);
  color: var(--ink);
  border:1px solid #59246D;
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
}
button:hover, input[type="button"]:hover {
  border-color: var(--accent);
}
input[type="text"] { cursor:text; min-width: 180px }

.container {
  display:flex;
  gap:24px;
  align-items:flex-start;
  justify-content:center;
  flex-wrap:wrap;
}
.board {
  position: relative;
  z-index: 0;
  flex: 1 1 520px;
  width: min(100%, 520px);
  max-width: 520px;
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap:10px;
  grid-auto-rows: 1fr;
}
.cell {
  background: rgba(61,20,77,0.9); /* variante foncée */
  border:1px solid #59246D;
  border-radius:18px;
  padding:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-size: clamp(12px, 2.2vw, 18px);
  line-height:1.25;
  position:relative;
  transition: transform .04s ease, border-color .2s ease, background .2s ease;
}
.cell .label { padding: 6px 4px }
.cell.phenomenon-cell {
  background: linear-gradient(135deg, rgba(245,198,33,0.22), rgba(61,20,77,0.55));
  border: 2px dashed var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(245,198,33,0.15);
}
.cell.phenomenon-cell .label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cell.free {
  background: linear-gradient(120deg, rgba(245,198,33,0.18), rgba(245,198,33,0.18));
  border-color:#59246D;
  font-weight:800;
  color: var(--ink);
}
.cell:active { transform: scale(.98) }
.cell.marked { outline: 2px solid var(--accent); outline-offset: 2px; background: #4B0F5C; }
.cell.phenomenon-cell.marked {
  background: linear-gradient(135deg, rgba(245,198,33,0.32), rgba(61,20,77,0.6));
  outline-color: var(--ink);
}
.cell.bingo { border-color: var(--hit); box-shadow: 0 0 0 2px rgba(245,198,33,0.4) inset; }

.details {
  flex:0 1 360px;
  max-width:360px;
  background: var(--card);
  border:1px solid #59246D;
  border-radius:12px;
  padding:16px;
  color: var(--ink);
  min-height:300px;
  display:flex;
  flex-direction:column;
  gap:12px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.25);
}
.details h2 { font-size:18px; margin:0 }
.details p { font-size:14px; line-height:1.4; margin:0 }
.details ul { margin:0; padding-left:18px; display:grid; gap:6px; }
.details.board-details {
  flex: 1;
  max-width: none;
  width: 100%;
  height: 100%;
  box-shadow: none;
  overflow: auto;
  min-height: 0;
  background: transparent;
  border: none;
  padding: 0;
  gap: 12px;
}
.details.board-details h2 {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.details.board-details p {
  font-size: 15px;
  line-height: 1.5;
}
.board-detail-slot {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  border: 4px solid transparent;
  border-radius: 18px;
  background:
    linear-gradient(150deg, rgba(75,31,88,0.92), rgba(25,6,36,0.95)) padding-box,
    linear-gradient(45deg, rgba(245,198,33,0.9), rgba(255,105,180,0.75), rgba(245,198,33,0.9)) border-box;
  box-shadow:
    0 18px 36px rgba(0,0,0,0.35),
    0 0 26px rgba(245,198,33,0.28);
  overflow: hidden;
  padding: 16px;
  background-color: #1a0b26;
}
.board-detail-wrapper {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(25, 9, 41, 0.82);
  border-radius: 14px;
  padding: 18px;
  backdrop-filter: blur(6px);
  box-shadow: inset 0 0 24px rgba(245,198,33,0.12), inset 0 0 2px rgba(255,255,255,0.12);
  overflow: auto;
}
.board-stars {
  position: absolute;
  z-index: 1;
  top: -12px;
  left: -12px;
  right: -12px;
  bottom: -12px;
  pointer-events: none;
}
.board-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff6d5;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,255,255,0.9), 0 0 12px rgba(255,173,232,0.6);
  animation: starTwinkle 2.4s infinite ease-in-out;
}
.board-star:nth-child(3n) {
  animation-name: starPulse;
}
.board-star:nth-child(5n) {
  width: 3px;
  height: 3px;
  animation-duration: 1.8s;
}
.board-star:nth-child(7n) {
  animation-name: starSparkle;
  animation-duration: 2.6s;
}
.board-star:nth-child(11n) {
  animation-duration: 3s;
}

.footer { text-align:center; color: var(--muted); margin: 4px 0 24px }
.small { font-size: 12px }
.stats { display:flex; gap: 16px; justify-content:center; margin: 12px 0; color: var(--muted) }

@media (hover: hover) {
  .cell:hover { border-color: var(--accent) }
}

@media (max-width: 960px) {
  .container {
    flex-direction: column;
    align-items: stretch;
  }
  .board {
    max-width: 100%;
    width: 100%;
  }
  .details {
    max-width: 100%;
    width: 100%;
  }
  .details:not(.board-details) {
    margin-top: 16px;
  }
}

@media (max-width: 600px) {
  header {
    padding: 16px 12px 12px;
  }
  h1 {
    font-size: clamp(20px, 7vw, 28px);
  }
  .main-nav {
    gap: 8px;
  }
  .toolbar {
    margin: 12px 0 16px;
    gap: 8px;
    padding: 0 4px;
  }
  .toolbar .context-input {
    flex: 1 1 100%;
    min-width: 0;
  }
  .toolbar button,
  .toolbar .link-button {
    width: 100%;
    justify-content: center;
  }
  .toolbar label {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
  .toolbar label select {
    width: 100%;
  }
  .container {
    gap: 16px;
    padding: 0 12px 24px;
  }
  .board {
    width: min(92vw, 480px);
    max-width: 100%;
    aspect-ratio: 1;
    gap: 6px;
  }
  .cell {
    padding: 8px;
    border-radius: 14px;
    font-size: clamp(11px, 3.7vw, 14px);
  }
  .cell .label {
    padding: 4px;
  }
  .stats {
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    padding: 0 12px;
  }
  .details {
    padding: 14px;
  }
}

.site-footer {
  margin-top: 48px;
  background: rgba(0,0,0,0.15);
  border-top: 1px solid #59246D;
  padding: 32px 16px;
  color: var(--muted);
}
.footer-shell {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  gap: 16px 24px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}
.footer-links,
.legal-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-section-title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.footer-link:hover,
.footer-link:focus {
  color: #FFE27A;
}
.contact-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.contact-item svg {
  flex-shrink: 0;
}
.copyright {
  color: var(--muted);
  font-size: 14px;
}
