/* ═══════════════════════════════════════════════════════════════════════════
   CARCASSONNE M2-9 — styles spécifiques
   Thème vert /societe/ (cohérent monopoly/echecs). Plateau zoom + pan.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --cc-bg-1: #0b1f15;
  --cc-bg-2: #06140d;
  --cc-card: rgba(20,40,28,.85);
  --cc-card-2: rgba(10,22,16,.95);
  --cc-border: rgba(110,224,150,.30);
  --cc-border-strong: rgba(110,224,150,.55);
  --cc-accent: #6fe096;
  --cc-accent-dim: #9be0b3;
  --cc-accent-deep: #1f7a3a;
  --cc-text: #f5f5f7;
  --cc-text-muted: #9aa0a6;
  --cc-warn: #ffd28a;
  --cc-danger: #ff6479;

  /* 5 couleurs joueurs — contrastées sur fond herbe */
  --cc-p0: #e8463f;  /* rouge   */
  --cc-p1: #3a8fe0;  /* azur    */
  --cc-p2: #f2b81e;  /* ambre   */
  --cc-p3: #a96cf0;  /* violet  */
  --cc-p4: #2b3340;  /* charbon */
}

body {
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(124,255,170,.10), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(80,160,90,.18), transparent 70%),
    radial-gradient(1200px 600px at 70% 30%, var(--cc-bg-1) 0%, var(--cc-bg-2) 60%, #04080a 100%);
}

main { max-width: 1320px; margin: 0 auto; padding: 18px 16px 56px; }

h1.title {
  font-size: clamp(28px, 4vw, 44px); font-weight: 900; margin: 4px 0 2px; text-align: center;
  background: linear-gradient(180deg, #d8ffe2 0%, var(--cc-accent) 50%, var(--cc-accent-deep) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 20px rgba(110,224,150,.25);
}
p.sub {
  text-align: center; color: var(--cc-accent-dim);
  font-family: ui-monospace, monospace; font-size: 12px;
  letter-spacing: 0.22em; text-transform: uppercase; margin: 0 0 16px;
}

/* ─── LAYOUT ─── */
.layout {
  display: grid; gap: 20px;
  grid-template-columns: minmax(420px, 1fr) 330px;
  align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

/* ─── PLATEAU ─── */
.board-area {
  background: linear-gradient(180deg, var(--cc-card), var(--cc-card-2));
  border: 1px solid var(--cc-border); border-radius: 18px; padding: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.05);
}

.board-toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.tool-btn {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: rgba(60,90,70,.55); color: #d8ffe2;
  border: 1px solid var(--cc-border); font-size: 18px; font-weight: 800;
  display: grid; place-items: center; line-height: 1;
  transition: transform .1s, background .15s, border-color .15s;
}
.tool-btn:hover { background: rgba(80,130,95,.7); border-color: var(--cc-accent); transform: translateY(-1px); }
.tool-btn:active { transform: translateY(0); }
.zoom-label {
  font-family: ui-monospace, monospace; font-size: 12px; color: var(--cc-accent-dim);
  min-width: 48px; text-align: center;
}
.toolbar-sep { flex: 1; }
.toolbar-hint {
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--cc-text-muted);
}

.board-viewport {
  position: relative; width: 100%; height: 70vh; min-height: 440px; max-height: 760px;
  border-radius: 12px; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, #20402b 0%, #13271a 60%, #0a160e 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(110,224,150,.12);
  cursor: grab; touch-action: none;
}
.board-viewport.panning { cursor: grabbing; }
#board { display: block; width: 100%; height: 100%; user-select: none; }

/* Voile « plateau vide » */
.board-empty[hidden] { display: none; }   /* sinon le display:flex écrase l'attribut hidden et bloque les clics */
.board-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  padding: 24px; color: var(--cc-accent-dim);
  background: radial-gradient(ellipse at center, rgba(8,18,12,.4), rgba(6,14,9,.82));
  backdrop-filter: blur(2px);
}
.board-empty .be-emoji { font-size: 64px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.6)); }
.board-empty p { max-width: 320px; font-size: 14px; color: var(--cc-text-muted); margin: 0; }

/* Emplacements légaux : pulsation */
.legal-cell {
  fill: rgba(124,255,170,.10);
  stroke: var(--cc-accent); stroke-width: 2.5; stroke-dasharray: 7 6;
  rx: 5; cursor: pointer;
  animation: legalPulse 1.7s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center;
}
.legal-cell:hover { fill: rgba(124,255,170,.24); stroke-width: 3.2; animation: none; }
@keyframes legalPulse {
  0%,100% { opacity: .55; stroke-dashoffset: 0; }
  50%     { opacity: 1;   stroke-dashoffset: 13; }
}

/* Tuile posée : animation d'arrivée */
.tile-grp { }
.tile-grp.placing { animation: tileDrop .42s cubic-bezier(.34,1.4,.5,1); transform-box: fill-box; transform-origin: center; }
@keyframes tileDrop {
  0%   { opacity: 0; transform: translateY(-18px) scale(1.08); }
  60%  { opacity: 1; transform: translateY(2px) scale(.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Aperçu fantôme de la tuile à poser */
#layer-ghost { pointer-events: none; }
.ghost-tile { opacity: .62; }
.ghost-tile.illegal { opacity: .42; }

/* Ancres de pose de meeple : pastilles pulsantes cliquables */
.meeple-anchor {
  cursor: pointer;
  transform-box: fill-box; transform-origin: center;
}
.meeple-anchor .anchor-dot {
  fill: rgba(255,255,255,.85);
  stroke: #143a22; stroke-width: 1.4;
  animation: anchorPulse 1.3s ease-in-out infinite;
}
.meeple-anchor .anchor-ring {
  fill: none; stroke: #fff; stroke-width: 1.2; opacity: .0;
}
.meeple-anchor:hover .anchor-dot { fill: #fff; }
.meeple-anchor:hover .anchor-ring { opacity: .9; }
@keyframes anchorPulse {
  0%,100% { opacity: .65; }
  50%     { opacity: 1; }
}

/* Meeple posé : ombre + surbrillance au survol */
.board-meeple {
  cursor: pointer; transition: transform .16s ease, filter .16s ease;
  transform-box: fill-box; transform-origin: 50% 92%;
}
.board-meeple:hover {
  transform: translateY(-2px) scale(1.14);
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.6)) drop-shadow(0 0 7px rgba(255,255,255,.6));
}
.board-meeple.removing { animation: meepleReturn .4s ease forwards; }
@keyframes meepleReturn {
  to { opacity: 0; transform: translateY(-26px) scale(.4); }
}

/* Couleurs joueurs (meeples & pastilles) */
.pcol-0 { color: var(--cc-p0); } .pcol-1 { color: var(--cc-p1); }
.pcol-2 { color: var(--cc-p2); } .pcol-3 { color: var(--cc-p3); }
.pcol-4 { color: var(--cc-p4); }
.swatch-0 { background: var(--cc-p0); } .swatch-1 { background: var(--cc-p1); }
.swatch-2 { background: var(--cc-p2); } .swatch-3 { background: var(--cc-p3); }
.swatch-4 { background: var(--cc-p4); }

/* ─── PANNEAU ─── */
.panel { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 80px; }
@media (max-width: 980px) { .panel { position: static; } }

.card {
  background: linear-gradient(180deg, var(--cc-card), var(--cc-card-2));
  border: 1px solid var(--cc-border); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
}
.card h3 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cc-accent-dim); font-weight: 800;
  display: flex; justify-content: space-between; align-items: baseline;
}
.deck-count {
  font-family: ui-monospace, monospace; font-size: 12px; color: var(--cc-warn);
  letter-spacing: 0; text-transform: none;
}

/* Carte : tuile à poser */
.draw-stage { display: flex; gap: 14px; align-items: center; }
.draw-preview {
  width: 116px; height: 116px; flex-shrink: 0;
  border-radius: 10px;
  background: radial-gradient(ellipse at 40% 35%, #20402b, #0e1f15);
  box-shadow: inset 0 0 22px rgba(0,0,0,.55);
}
#drawPreview .preview-rot {
  transition: transform .34s cubic-bezier(.34,1.3,.5,1);
  transform-box: fill-box; transform-origin: center;
}
.draw-controls { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.btn-rotate { width: 100%; }
.rot-readout {
  font-family: ui-monospace, monospace; font-size: 22px; font-weight: 900;
  color: var(--cc-accent); text-align: center;
  text-shadow: 0 0 10px rgba(110,224,150,.3);
}
.draw-status {
  margin-top: 10px; font-family: ui-monospace, monospace; font-size: 11.5px;
  color: var(--cc-warn); min-height: 16px; line-height: 1.4;
}
.card-draw.empty .draw-preview { opacity: .35; }

/* Carte : tour */
.card-turn .turn-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.turn-meeple { width: 30px; height: 38px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.turn-id { display: flex; flex-direction: column; min-width: 0; }
.turn-name { font-weight: 800; font-size: 16px; color: var(--cc-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-meeple-count { font-family: ui-monospace, monospace; font-size: 11px; color: var(--cc-text-muted); }
.turn-score {
  font-family: ui-monospace, monospace; font-size: 26px; font-weight: 900;
  color: var(--cc-accent); text-shadow: 0 0 10px rgba(110,224,150,.3);
}
.turn-phase {
  margin-top: 6px; font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--cc-accent-dim); min-height: 14px;
}

/* Boutons (conventions monopoly) */
.btn {
  appearance: none; border: 0; cursor: pointer; padding: 8px 14px; border-radius: 10px;
  font-family: inherit; font-weight: 700; font-size: 13px;
  background: rgba(60,90,70,.55); color: #d8ffe2; border: 1px solid var(--cc-border);
  transition: transform .1s, box-shadow .2s, background .15s;
}
.btn:hover:not(:disabled) { background: rgba(80,130,95,.7); border-color: var(--cc-accent); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--cc-accent), var(--cc-accent-deep));
  color: #06140d; border: 0; box-shadow: 0 4px 14px rgba(110,224,150,.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(110,224,150,.55); }
.btn-ghost { background: transparent; color: var(--cc-accent-dim); border-color: rgba(110,224,150,.25); }
.btn-small { padding: 6px 10px; font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }

/* Carte : joueurs */
.player-row {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 9px; margin-bottom: 4px; transition: background .15s;
}
.player-row.active { background: rgba(110,224,150,.12); outline: 1px solid var(--cc-border-strong); }
.player-meeple { width: 24px; height: 30px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.55)); }
.player-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.player-name { font-weight: 700; font-size: 13px; color: var(--cc-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--cc-text-muted); }
.player-score { font-family: ui-monospace, monospace; font-weight: 800; font-size: 18px; color: var(--cc-accent); }
.player-meeples-row { display: flex; gap: 2px; margin-top: 2px; }
.player-meeples-row .mini-m { width: 8px; height: 10px; border-radius: 2px 2px 0 0; }

/* Carte : journal */
.card-log { }
#logList {
  max-height: 220px; overflow-y: auto; font-family: ui-monospace, monospace;
  font-size: 11.5px; color: rgba(200,240,220,.8); line-height: 1.5; padding-right: 4px;
}
#logList::-webkit-scrollbar { width: 6px; }
#logList::-webkit-scrollbar-track { background: rgba(0,0,0,.2); border-radius: 3px; }
#logList::-webkit-scrollbar-thumb { background: rgba(110,224,150,.3); border-radius: 3px; }
.log-entry { padding: 3px 0; border-bottom: 1px dashed rgba(110,224,150,.1); }
.log-entry:last-child { border-bottom: none; }
.log-entry .log-p { font-weight: 800; margin-right: 6px; }
.log-entry[data-p="0"] .log-p { color: var(--cc-p0); }
.log-entry[data-p="1"] .log-p { color: var(--cc-p1); }
.log-entry[data-p="2"] .log-p { color: var(--cc-p2); }
.log-entry[data-p="3"] .log-p { color: var(--cc-p3); }
.log-entry[data-p="4"] .log-p { color: var(--cc-p4); }
.log-entry.score-evt { color: var(--cc-accent); }

/* ─── MODALES ─── */
.modal-bg {
  position: fixed; inset: 0; z-index: 500; background: rgba(6,14,9,.72);
  backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  background: linear-gradient(180deg, #14281c, #08160e);
  border: 1px solid var(--cc-border-strong); border-radius: 16px; padding: 22px 26px;
  max-width: 460px; width: 100%;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 40px rgba(110,224,150,.2);
  animation: modalPop .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-wide { max-width: 600px; }
@keyframes modalPop { from { transform: scale(.85); opacity: 0; } }
.modal h2 {
  margin: 0 0 12px; font-size: 22px;
  background: linear-gradient(180deg, #d8ffe2, var(--cc-accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.modal p { margin: 0 0 12px; font-size: 14px; color: rgba(220,240,230,.85); line-height: 1.5; }

/* Newgame */
.ng-section { margin-bottom: 14px; }
.ng-label {
  display: block; font-size: 11px; letter-spacing: .15em; text-transform: uppercase;
  color: var(--cc-accent-dim); margin-bottom: 6px; font-weight: 700;
}
.ng-count.active { background: linear-gradient(135deg, var(--cc-accent), var(--cc-accent-deep)); color: #06140d; border: 0; }
.ng-player-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; margin-bottom: 8px; }
.ng-player-meeple { width: 24px; height: 30px; }
.ng-player-input {
  background: rgba(0,0,0,.25); border: 1px solid var(--cc-border); border-radius: 6px;
  padding: 5px 8px; color: var(--cc-text); font-family: inherit; font-size: 13px; width: 100%;
}
.ng-player-input:focus { outline: none; border-color: var(--cc-accent); }
.ng-ai-toggle {
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--cc-accent-dim);
  border: 1px solid var(--cc-border); border-radius: 999px; padding: 4px 10px;
  cursor: pointer; background: rgba(0,0,0,.2); white-space: nowrap; user-select: none;
}
.ng-ai-toggle.on { background: linear-gradient(135deg, var(--cc-accent), var(--cc-accent-deep)); color: #06140d; border: 0; }

/* Règles */
.rules-body { font-size: 13px; color: rgba(220,240,230,.88); line-height: 1.6; max-height: 60vh; overflow-y: auto; }
.rules-body h4 { margin: 14px 0 4px; color: var(--cc-accent-dim); font-size: 13px; }
.rules-body ul { margin: 4px 0; padding-left: 20px; }
.rules-body li { margin-bottom: 3px; }
.rules-body .feat-ico { display:inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* Fin de partie */
.end-board { display: flex; flex-direction: column; gap: 6px; }
.end-row {
  display: grid; grid-template-columns: 26px 24px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.22);
}
.end-row.winner { background: linear-gradient(135deg, rgba(255,210,138,.2), rgba(110,224,150,.14)); outline: 1px solid var(--cc-warn); }
.end-rank { font-family: ui-monospace, monospace; font-weight: 900; font-size: 16px; color: var(--cc-accent-dim); text-align: center; }
.end-meeple { width: 22px; height: 28px; }
.end-name { font-weight: 700; color: var(--cc-text); }
.end-score { font-family: ui-monospace, monospace; font-weight: 900; font-size: 22px; color: var(--cc-accent); }

/* ─── Plein écran (natif :fullscreen ou repli .cc-fs) ─── */
.layout:fullscreen, .layout:-webkit-full-screen, .layout.cc-fs {
  background: radial-gradient(ellipse 80% 70% at 50% 30%, #13271a 0%, #0a160e 70%, #04080a 100%);
  padding: 12px; gap: 12px; height: 100vh; width: 100vw;
  grid-template-columns: minmax(0, 1fr) 340px; align-items: stretch;
}
.layout.cc-fs { position: fixed; inset: 0; z-index: 400; overflow: hidden; }
.layout:fullscreen .board-area, .layout:-webkit-full-screen .board-area, .layout.cc-fs .board-area {
  height: 100%; display: flex; flex-direction: column;
}
.layout:fullscreen .board-viewport, .layout:-webkit-full-screen .board-viewport, .layout.cc-fs .board-viewport {
  flex: 1; height: auto; max-height: none;
}
.layout:fullscreen .panel, .layout:-webkit-full-screen .panel, .layout.cc-fs .panel {
  position: static; max-height: 100%; overflow-y: auto;
}
@media (max-width: 980px) {
  .layout:fullscreen, .layout.cc-fs { grid-template-columns: 1fr; }
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  main { padding: 12px 8px 40px; }
  .board-area { padding: 8px; border-radius: 12px; }
  .board-viewport { height: 60vh; min-height: 360px; }
  .card { padding: 10px 12px; }
  .modal { padding: 18px 20px; }
  .modal h2 { font-size: 18px; }
  .layout { gap: 14px; }
}
