/* ====== Variables / palette ====== */
:root {
  --color-primary: #2d5a3d;        /* vert forêt */
  --color-primary-dark: #1f3f2a;
  --color-primary-light: #4a7a5c;
  --color-secondary: #8b6f47;      /* bois */
  --color-secondary-dark: #6b563a;
  --color-accent: #f5e6d3;         /* beige */
  --color-bg: #fafaf5;
  --color-card: #ffffff;
  --color-text: #1a1a1a;
  --color-text-light: #555;
  --color-danger: #b8312f;
  --color-success: #2d5a3d;
  --color-warning: #c87f2a;
  --color-border: #e0d9c8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --tap-min: 60px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    radial-gradient(circle at 20% 0%, rgba(139,111,71,.06) 0, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(45,90,61,.06) 0, transparent 40%);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { color: var(--color-primary-dark); margin-top: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }

a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--color-primary-dark); }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* ====== Layout ====== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.logo-icon { font-size: 1.4rem; }

.site-nav {
  display: flex;
  gap: 14px;
}
.site-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}
.site-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.site-footer {
  text-align: center;
  padding: 24px 16px 32px;
  color: var(--color-text-light);
  font-size: 0.9rem;
}
.site-footer a { color: var(--color-text-light); }
.footer-note { font-size: 0.8rem; margin-top: 4px; }

/* ====== Screens ====== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.lead {
  font-size: 1.05rem;
  color: var(--color-text-light);
  margin: 8px 0 24px;
}

.section-title {
  font-size: 1.1rem;
  margin-top: 24px;
  margin-bottom: 12px;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap-min);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

.btn-secondary {
  background: var(--color-accent);
  color: var(--color-secondary-dark);
  border-color: var(--color-secondary);
}
.btn-secondary:hover { background: #ecdcc1; }

.btn-ghost {
  background: transparent;
  color: var(--color-primary-dark);
  border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-accent); }

.btn-large {
  font-size: 1.1rem;
  padding: 16px 24px;
  width: 100%;
}

/* ====== Setup screen ====== */
.players-setup {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  gap: 8px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-card);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.player-row .player-num {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.player-row input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  min-height: 44px;
}
.player-row input:focus { outline: 2px solid var(--color-primary-light); outline-offset: 1px; }
.btn-remove-player {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-danger);
  font-size: 1.4rem;
  font-weight: 700;
  flex-shrink: 0;
}
.btn-remove-player:disabled { opacity: .35; cursor: not-allowed; }

.setup-actions {
  display: grid;
  gap: 12px;
  margin: 16px 0 24px;
}

/* Mode picker (setup) */
.mode-picker {
  border: none;
  padding: 0;
  margin: 0 0 16px;
  display: grid;
  gap: 8px;
}
.mode-option {
  display: block;
  cursor: pointer;
}
.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mode-card {
  display: block;
  background: var(--color-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  min-height: var(--tap-min);
}
.mode-card .mode-title {
  display: block;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 2px;
}
.mode-card .mode-title em {
  font-style: normal;
  font-size: 0.8rem;
  color: var(--color-text-light);
  font-weight: 500;
}
.mode-card .mode-example {
  display: block;
  font-size: 0.9rem;
  color: var(--color-text-light);
}
.mode-option input[type="radio"]:checked + .mode-card {
  border-color: var(--color-primary);
  background: #e8f0e7;
  box-shadow: 0 0 0 3px rgba(45,90,61,.12);
}
.mode-option input[type="radio"]:focus-visible + .mode-card {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
}

/* Indicator on game screen */
.mode-indicator {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 8px;
  background: var(--color-accent);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.mode-indicator strong { color: var(--color-primary-dark); }

.error-message {
  color: var(--color-danger);
  font-weight: 600;
  margin: 8px 0 0;
  min-height: 1.5em;
}

.resume-banner {
  background: var(--color-accent);
  border: 1px solid var(--color-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.resume-banner p { margin: 0 0 10px; font-weight: 600; color: var(--color-secondary-dark); }
.resume-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.seo-content {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
}
.seo-content h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}
.seo-content p {
  margin: 0 0 12px;
  line-height: 1.6;
}

/* ====== Game screen - players board ====== */
.players-board {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.player-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  background: var(--color-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  transition: all .2s ease;
}
.player-card.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
  transform: scale(1.01);
}
.player-card.eliminated {
  opacity: .55;
  text-decoration: line-through;
  background: #f0ede5;
}
.player-card .player-name {
  font-weight: 700;
  font-size: 1.05rem;
  word-break: break-word;
  min-width: 0;
}
.player-card .player-score {
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  grid-column: 2;
  grid-row: 1 / span 2;
}
.player-card .zero-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}
.zero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0,0,0,.15);
  display: inline-block;
}
.player-card.active .zero-dot { background: rgba(255,255,255,.3); }
.zero-dot.on { background: var(--color-danger); box-shadow: 0 0 0 2px rgba(184,49,47,.15); }
.player-card.active .zero-dot.on { background: #ffb3b1; }

.player-meta {
  font-size: 0.85rem;
  color: var(--color-text-light);
}
.player-card.active .player-meta { color: rgba(255,255,255,.85); }
.player-card.eliminated .player-meta { color: var(--color-danger); font-weight: 600; }

.last-throw {
  text-align: center;
  min-height: 24px;
  font-size: 0.95rem;
  color: var(--color-text-light);
  margin: 6px 0 12px;
  font-style: italic;
}

/* ====== Score pad ====== */
.score-pad {
  margin-top: 8px;
}
.pad-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-light);
  margin: 16px 0 8px;
  font-weight: 700;
}
.grid-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.btn-score {
  min-height: var(--tap-min);
  border: 2px solid var(--color-primary);
  background: var(--color-card);
  color: var(--color-primary-dark);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  font-weight: 700;
  padding: 8px;
  transition: transform .06s ease, background .15s ease;
  user-select: none;
  -webkit-user-select: none;
}
.btn-score:hover { background: var(--color-accent); }
.btn-score:active { transform: scale(.95); background: var(--color-primary); color: #fff; }
/* Boutons quille (toggle multi-sélection) */
.btn-pin {
  min-height: var(--tap-min);
  border: 2px solid var(--color-primary);
  background: var(--color-card);
  color: var(--color-primary-dark);
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  font-weight: 700;
  padding: 8px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.btn-pin:hover { background: var(--color-accent); }
.btn-pin:active { transform: scale(.95); }
.btn-pin.selected {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px rgba(45,90,61,.18);
}
.btn-pin.selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.7rem;
  opacity: .85;
}

.pin-summary {
  margin: 14px 0 10px;
  padding: 10px 14px;
  background: var(--color-accent);
  border: 1px dashed var(--color-secondary);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 600;
  color: var(--color-secondary-dark);
  font-size: 0.95rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pin-summary.has-selection {
  background: #e8f0e7;
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  border-style: solid;
}

.validate-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-bottom: 10px;
}
.validate-row .btn { min-height: 56px; }
.validate-row .btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
  background: var(--color-primary);
}

.btn-miss {
  width: 100%;
  margin-top: 8px;
  background: var(--color-card);
  border: 2px solid var(--color-danger);
  color: var(--color-danger);
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 60px;
  border-radius: var(--radius-md);
  padding: 8px;
  transition: transform .06s ease, background .15s ease;
}
.btn-miss:active { background: var(--color-danger); color: #fff; transform: scale(.97); }

.game-actions {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

/* ====== End screen ====== */
.end-card {
  text-align: center;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  box-shadow: var(--shadow-md);
}
.trophy {
  font-size: 4rem;
  animation: bounce 1s ease infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
#end-message {
  font-size: 1.2rem;
  margin: 8px 0 20px;
  color: var(--color-text);
}
.end-ranking {
  text-align: left;
  margin: 0 auto 24px;
  max-width: 320px;
}
.ranking-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}
.ranking-row:last-child { border-bottom: none; }
.ranking-row.winner {
  background: var(--color-accent);
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.ranking-row.eliminated { color: var(--color-text-light); text-decoration: line-through; }

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: var(--color-primary-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  max-width: 100%;
  animation: toastIn .25s ease, toastOut .25s ease 2.5s forwards;
  pointer-events: auto;
}
.toast.warn { background: var(--color-warning); }
.toast.danger { background: var(--color-danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* ====== AdSense slots ====== */
.ad-slot {
  width: 100%;
  max-width: 728px;
  margin: 8px auto;
  min-height: 90px;
  background: rgba(139,111,71,.06);
  border: 1px dashed rgba(139,111,71,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: rgba(0,0,0,.25);
  border-radius: var(--radius-sm);
}
.ad-slot::before { content: "Espace publicitaire"; }
.ad-slot:not(:empty)::before { content: ""; }
.ad-slot:not(:empty) { border: none; background: transparent; }

/* Sidebar AdSense - desktop only */
@media (min-width: 1100px) {
  body {
    display: grid;
    grid-template-columns: 1fr minmax(0, 720px) 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "header header header"
      "ad-top ad-top ad-top"
      ".      main   side"
      "ad-bot ad-bot ad-bot"
      "footer footer footer";
  }
  .site-header { grid-column: 1 / -1; }
  .ad-slot-top { grid-area: ad-top; }
  main { grid-area: main; }
  .ad-slot-bottom { grid-area: ad-bot; }
  .site-footer { grid-area: footer; grid-column: 1 / -1; }
  .cookie-banner { grid-column: 1 / -1; }

  /* Inject sidebar via ::before on main… simpler: use a fixed slot */
  main::after {
    content: "";
    grid-area: side;
  }
}

/* ====== Cookie banner ====== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-primary-dark);
  color: #fff;
  padding: 16px;
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,.2);
}
.cookie-content {
  max-width: 720px;
  margin: 0 auto;
}
.cookie-content h2 {
  font-size: 1rem;
  margin: 0 0 6px;
  color: #fff;
}
.cookie-content p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.cookie-content a { color: var(--color-accent); }
.cookie-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.cookie-actions .btn { min-height: 44px; padding: 10px 18px; }
.cookie-actions .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.cookie-actions .btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ====== Page de contenu ====== */
.page-content {
  background: var(--color-card);
  padding: 24px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.page-content h1 { font-size: 1.7rem; margin-bottom: 12px; }
.page-content h2 { font-size: 1.25rem; margin: 28px 0 8px; color: var(--color-primary-dark); }
.page-content h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.page-content p { margin: 0 0 12px; line-height: 1.65; }
.page-content ul, .page-content ol { padding-left: 22px; margin: 0 0 14px; }
.page-content li { margin-bottom: 6px; }
.page-content a { color: var(--color-primary); }
.page-content figure { margin: 16px 0; text-align: center; }
.page-content figcaption { font-size: 0.85rem; color: var(--color-text-light); margin-top: 6px; }
.page-content .schema-svg {
  max-width: 280px;
  width: 100%;
  height: auto;
}
.faq dt { font-weight: 700; margin-top: 14px; color: var(--color-primary-dark); }
.faq dd { margin: 4px 0 0; padding-left: 0; }

/* ====== Responsive tweaks ====== */
@media (max-width: 360px) {
  .grid-numbers { grid-template-columns: repeat(3, 1fr); }
  .btn-pin { font-size: 1.2rem; }
  h1 { font-size: 1.4rem; }
}

@media (min-width: 600px) {
  .grid-numbers { grid-template-columns: repeat(6, 1fr); }
  .player-card .player-score { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
