/* Maths et Go — la règle des petits
   Copyright (c) 2026 Tristan Cazenave. Tous droits réservés — voir LICENSE.

   LE BOIS ET LES PIERRES SONT CEUX DES AUTRES GOBANS DU SITE, aux mêmes noms de
   variables : onze jeux de Go côte à côte sur golois.com ne peuvent pas être de
   onze couleurs. Ce qui est propre à ce jeu-ci tient en trois dessins — le
   carré imposé du début, la place des pierres prises, et la frise du handicap. */

:root {
  --fond: #E6E7E1;         /* le gris de la porte */
  --surface: #F6F6F1;
  --ligne: #CDCEC5;
  --texte: #171A20;
  --texte-doux: #4E5663;
  --choix: #EDEDE6;
  --bord-choix: #6E7684;
  --focus: #1d4ed8;
  --accent: #2C4E7E;
  --accent-clair: #DCE6F2;
  --sur-accent: #fff;
  --bois-a: #e6cd93; --bois-b: #d8b878; --trait-goban: #6b5426;
  --pierre-n1: #5a626c; --pierre-n2: #0b0e12;
  --pierre-b1: #ffffff; --pierre-b2: #d8cfba;
  --cher: #a53a24; --bon: #2f6d43;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #13161B; --surface: #1B1F26; --ligne: #333A45;
    --texte: #E8E9E4; --texte-doux: #A5ACB8;
    --choix: #232830; --bord-choix: #7C8797;
    --accent: #8CB0E2; --accent-clair: #22304A; --sur-accent: #0E1620;
    --pierre-n1: #3e454e; --pierre-n2: #05070a;
    --pierre-b1: #f7f2e5; --pierre-b2: #cbc1a9;
    --cher: #e08c78; --bon: #7fc79a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
.ecran { display: flex; flex-direction: column; min-height: 100%; }
#ecran-jeu { max-width: 640px; width: 100%; margin: 0 auto; }
.ecran[hidden] { display: none; }
.pousse { flex: 1; }

.btn { appearance: none; background: var(--surface); border: 1px solid var(--ligne);
  color: var(--texte); border-radius: 10px; padding: 10px 14px; cursor: pointer;
  min-height: 44px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primaire { background: var(--accent); border-color: var(--accent);
  color: var(--sur-accent); font-weight: 650; }
.btn-mini { padding: 6px 10px; min-height: 36px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--ligne); border-radius: 999px;
  overflow: hidden; }
.seg button { appearance: none; background: transparent; border: 0;
  color: var(--texte-doux); font-size: 12px; letter-spacing: .08em;
  padding: 6px 10px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--sur-accent); }

.boite { background: var(--surface); border: 1px solid var(--ligne);
  border-radius: 16px; margin: 16px auto; max-width: 34rem; width: calc(100% - 24px); }
.boite-tete { padding: 16px 18px 0; }
.boite-tete h1 { margin: 8px 0 0; font-size: 30px; letter-spacing: -.01em; }
.sous-titre { margin: 8px 0 0; color: var(--texte-doux); font-size: 14px; }
/* LE RAPPEL VA À LA LIGNE LUI-MÊME, et s'efface quand il est vide : la règle
   des petits n'en a plus (7 novembre 2026), celle des grands le garde. Un <br>
   en dur dans la page aurait laissé une ligne blanche chez les petits. */
.sous-titre .rappel { display: block; opacity: .85; font-size: 13px; }
.sous-titre .rappel:empty { display: none; }
/* Le même trait que `.champ label`, pour un intitulé qui ne commande rien. */
.champ .intitule { font-weight: 600; }
/* LE LIEN VERS L'AUTRE PORTE A L'AIR D'UN BOUTON, mais c'est un lien : il faut
   donc lui rendre à la main ce qu'un <button> a d'office. */
.vers-porte { margin: 8px 0 0; }
.vers-porte .btn { display: inline-block; text-decoration: none;
  color: var(--texte); min-height: 0; }
.boite-corps { padding: 12px 18px 16px; }
.boite-pied { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 18px; }
.champ { margin-top: 14px; }
.champ label { font-weight: 600; }

.choix { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* LES QUATRE FAÇONS D'ARRÊTER LA PARTIE SONT DES PHRASES, pas des mots : elles
   tiennent chacune sur sa ligne, sans quoi la plus longue casserait la grille. */
.choix-col { flex-direction: column; align-items: stretch; }
.choix button { appearance: none; background: var(--choix); color: var(--texte);
  border: 1.5px solid var(--bord-choix); border-radius: 10px; padding: 8px 14px;
  min-height: 44px; cursor: pointer; font-variant-numeric: tabular-nums;
  text-align: left; }
.choix:not(.choix-col) button { text-align: center; }
.choix button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent);
  color: var(--sur-accent); font-weight: 650; }
.note { margin: 8px 0 0; font-size: 13px; color: var(--texte-doux); }
.note.petite { font-size: 12.5px; }
.note:empty { display: none; }
.bascule { display: flex; align-items: center; gap: 10px; margin-top: 14px;
  cursor: pointer; }
.bascule[hidden] { display: none; }
.bascule input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Les réglages propres à une variante : la durée, le nombre de prisonniers, les
   deux bols. Ils apparaissent et disparaissent avec le choix du dessus. */
.nombres { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px;
  align-items: flex-end; }
.nombre { display: flex; flex-direction: column; gap: 4px; }
.nombre span { font-size: 13px; color: var(--texte-doux); }
.nombre input { width: 6rem; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--ligne); background: var(--surface); padding: 0 10px;
  font-variant-numeric: tabular-nums; }

/* LA FRISE EST LA FIGURE DU DOCUMENT, et elle se lit de gauche à droite : c'est
   l'ordre des coups. Les pierres d'un même paquet se touchent, et les paquets
   sont séparés — un paquet de deux noires veut dire deux coups de suite. */
.frise { margin-top: 10px; overflow-x: auto; }
.frise svg { height: 26px; display: block; }
.frise .fn { fill: url(#frise-n); stroke: #00000070; stroke-width: .6; }
.frise .fb { fill: url(#frise-b); stroke: #5a462859; stroke-width: .6; }

#barre { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  flex-wrap: wrap; border-bottom: 1px solid var(--ligne); }
.trait { font-weight: 650; font-size: 14px; display: inline-flex; align-items: center;
  gap: 7px; }
.trait::before { content: ""; width: 14px; height: 14px; border-radius: 50%;
  flex: none; border: 1px solid #00000055;
  background: radial-gradient(circle at 35% 30%, var(--pierre-n1), var(--pierre-n2)); }
.trait[data-couleur="2"]::before {
  background: radial-gradient(circle at 35% 30%, var(--pierre-b1), var(--pierre-b2)); }
.trait[data-couleur="0"]::before { display: none; }

#compteurs { display: flex; gap: 5px; flex-wrap: wrap; }
.compteur { font-size: 12px; font-weight: 650; border-radius: 999px; padding: 3px 10px;
  border: 1px solid; font-variant-numeric: tabular-nums; }
.compteur.noir { background: #17151a; color: #fdfbf4; border-color: #00000080; }
.compteur.blanc { background: #fdfbf4; color: #17151a; border-color: #5a462859; }
.compteur.horloge { background: var(--choix); color: var(--texte);
  border-color: var(--bord-choix); }
.compteur.au-trait { box-shadow: 0 0 0 2px var(--accent); }
.compteur.presse { outline: 2px solid var(--cher); outline-offset: 1px; }

#zone-plateau { padding: 10px; display: flex; justify-content: center; }
#plateau { width: 100%; max-width: 600px; height: auto; touch-action: manipulation;
  cursor: pointer; }

/* L'identifiant du dégradé doit correspondre à celui que `vue.js` pose dans les
   <defs> : un `url()` qui ne pointe sur rien ne peint rien du tout. */
.bois { fill: url(#mg-bois); }
.ligne { stroke: var(--trait-goban); stroke-width: 3; opacity: .8; }
/* LE POURTOUR DU TORE : le plateau répété d'un rang tout autour, pour montrer
   ce qui touche quoi. Un voile par-dessus le bois et sous les pierres — il doit
   se lire, et se lire comme un rappel plutôt que comme du plateau. */
.pourtour { fill: var(--trait-goban); opacity: .16; pointer-events: none; }
.fantomes { opacity: .42; }
.hoshi { fill: var(--trait-goban); }
.ombre { fill: #00000038; }
.pierre.noire { fill: url(#mg-pn); stroke: #00000080; stroke-width: .8; }
.pierre.blanche { fill: url(#mg-pb); stroke: #5a462859; stroke-width: .8; }
.fantome { opacity: .38; pointer-events: none; }
.marque { fill: none; stroke-width: 4; }
.marque.sur-noire { stroke: #fdfbf4; }
.marque.sur-blanche { stroke: #17151a; }

/* L'OUVERTURE IMPOSÉE : les points du centre encore libres. Tant que le premier
   coup n'a pas choisi la diagonale, ils sont tous les quatre neutres ; ensuite
   chacun montre la couleur qu'il attend. */
.impose { fill: none; stroke: var(--accent); stroke-width: 5;
  stroke-dasharray: 10 9; pointer-events: none; opacity: .75; }
.impose.veut-noire { stroke: #17151a; opacity: .5; }
.impose.veut-blanche { stroke: #fdfbf4; opacity: .9; }

/* Les chaînes qui n'ont plus qu'une liberté, et le point où elles se prennent.
   La place des pierres qu'on vient de prendre porte le même rouge, en plein :
   l'un annonce ce que l'autre accomplit. */
.danger { fill: none; stroke: var(--cher); stroke-width: 6;
  stroke-dasharray: 13 10; pointer-events: none; }
.souffle { fill: none; stroke: var(--cher); stroke-width: 6;
  stroke-dasharray: 9 8; opacity: .85; pointer-events: none; }
.prise { fill: none; stroke: var(--cher); stroke-width: 7; opacity: .9;
  pointer-events: none; }
.refus { fill: none; stroke: var(--cher); stroke-width: 6; }

/* LE POINT INTERDIT PAR LE KO, chez les grands. Un CARRÉ, et non un cercle :
   tout ce qui est rond sur ce plateau est une pierre ou la place d'une pierre,
   et celui-ci n'est ni l'un ni l'autre — c'est un point libre où l'on ne peut
   pas jouer, la seule règle du jeu qui ne se lise pas sur le plateau. */
.ko { fill: none; stroke: var(--trait-goban); stroke-width: 6; opacity: .75;
  pointer-events: none; }

.ruban { display: flex; align-items: center; gap: 6px; margin: 0 12px;
  max-width: 600px; }
.ruban[hidden] { display: none; }
.ruban .btn-mini { flex: 0 0 auto; padding: 6px 9px; line-height: 1; }
.ruban input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent);
  height: 24px; }
.coup-n { font-size: 12.5px; color: var(--texte-doux); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
#btn-ici { margin-left: auto; }
@media (max-width: 420px) {
  .ruban { gap: 4px; margin: 0 8px; }
  .ruban .btn-mini { padding: 6px 7px; }
  .coup-n { font-size: 11.5px; }
}

.dit { margin: 6px 14px 0; color: var(--texte-doux); font-size: 15px; min-height: 1.5em; }
.dit.serie { color: var(--texte); font-weight: 600; }
/* LA PARTIE EST FINIE, ET CELA SE VOIT. La même ligne disait « Au tour de
   Noir » et « Noir gagne » du même gris : la fin se lisait, elle ne se voyait
   pas. Un cadre, la couleur pleine, et le verdict cesse d'avoir l'air d'un
   commentaire de plus. Le coup de plus porte le même cadre — il appartient
   déjà à la fin de la partie. */
.dit.finie { color: var(--texte); font-weight: 600; margin-top: 10px;
  padding: 9px 12px; border: 1px solid var(--ligne); border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dit[hidden] { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); }

.modale { position: fixed; inset: 0; background: #0b0e0a99; display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modale[hidden] { display: none; }
.modale-boite { background: var(--surface); border-radius: 14px; max-width: 36rem;
  width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.modale-tete { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--ligne); }
.modale-tete h2 { margin: 0; font-size: 18px; flex: 1; }
.modale-corps { padding: 14px 16px; overflow: auto; }
.modale-corps h3 { font-size: 14px; color: var(--accent); margin: 16px 0 6px; }
.modale-corps h3:first-child { margin-top: 0; }
/* DE QUELLE RÈGLE PARLE CE COMPLÉMENT ? Les deux portes ouvrent la même fenêtre
   sous le même titre, et c'est cette ligne qui les distingue. Elle passe devant
   le premier <h3>, qui perd donc son `:first-child`. */
.modale-corps .modale-sous { margin: 0 0 2px; font-weight: 600; }
.modale-corps .modale-sous + h3 { margin-top: 10px; }
.modale-corps p, .modale-corps li { font-size: 14px; }
.modale-corps ul { padding-left: 1.1rem; }
.modale-corps a { color: var(--accent); }
/* Les deux formes de l'ouverture, dessinées dans la page des règles. */
.formes { display: flex; gap: 18px; margin: 10px 0 2px; flex-wrap: wrap; }
.formes svg { width: 108px; height: 108px; }

.hof { width: 100%; border-collapse: collapse; margin-top: 8px; }
.hof th, .hof td { text-align: left; padding: 5px 8px; font-size: 14px;
  border-bottom: 1px solid var(--ligne); }
.hof td.num, .hof th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hof tr.moi { background: var(--accent-clair); }

/* RIEN NE ZOOME TOUT SEUL SUR UN ÉCRAN TACTILE. Deux appuis rapprochés sur un
   bouton sont lus par Safari comme un ordre de grossir, et le jeu sort du
   cadre ; sous seize pixels, entrer dans un champ grossit la page et ne la
   redescend pas. Les deux remèdes sont posés sur tous les jeux du site. */
html, body { touch-action: manipulation; }
button, select, input, textarea, a, label, summary { touch-action: manipulation; }
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
