/* ═══════════════════════════════════════════════════════════════════════════
   MONOPOLY M2-9 — styles spécifiques
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Palette /societe/ verte sombre (cohérente avec echecs.html) */
  --mp-bg-1: #0b1f15;
  --mp-bg-2: #06140d;
  --mp-card: rgba(20,40,28,.85);
  --mp-card-2: rgba(10,22,16,.95);
  --mp-border: rgba(110,224,150,.30);
  --mp-border-strong: rgba(110,224,150,.55);
  --mp-accent: #6fe096;
  --mp-accent-dim: #9be0b3;
  --mp-accent-deep: #1f7a3a;
  --mp-text: #f5f5f7;
  --mp-text-muted: #9aa0a6;
  --mp-warn: #ffd28a;
  --mp-danger: #ff6479;

  /* Couleurs Monopoly officielles (référencées par classes case-color-*) */
  --mp-c-brown: #6d4524;
  --mp-c-light-blue: #86b9d8;
  --mp-c-pink: #a82c70;
  --mp-c-orange: #c5701a;
  --mp-c-red: #8d1717;
  --mp-c-yellow: #c9b323;
  --mp-c-green: #1b6e35;
  --mp-c-dark-blue: #0a2c66;

  /* Couleurs joueurs (4 pions) */
  --mp-p0: #ffd28a;  /* or */
  --mp-p1: #ff6479;  /* rouge corail */
  --mp-p2: #7ff8ff;  /* cyan */
  --mp-p3: #d8b3ff;  /* violet pâle */
}

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(--mp-bg-1) 0%, var(--mp-bg-2) 60%, #04080a 100%);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 18px 60px;
}

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(--mp-accent) 50%, var(--mp-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(--mp-accent-dim);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

/* ─── LAYOUT ─── */
.layout {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(400px, 1fr) 340px;
  align-items: start;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

.board-wrap {
  position: relative;
  background: linear-gradient(180deg, var(--mp-card), var(--mp-card-2));
  border: 1px solid var(--mp-border);
  border-radius: 18px;
  padding: 14px;
  box-shadow:
    0 20px 50px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.05);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  max-width: 760px;
  margin: 0 auto;
  user-select: none;
  touch-action: manipulation;
}

/* ─── CASES SVG ─── */
.case-bg {
  fill: #f4ecd5;
  filter: url(#f-paper);
}

.case-name {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  fill: #1a1006;
  pointer-events: none;
  user-select: none;
}

.case-price {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 700;
  font-size: 7px;
  fill: #3a2410;
  pointer-events: none;
  user-select: none;
}

.case-hover-target {
  cursor: pointer;
  transition: fill 0.18s;
}

.case-hover-target:hover {
  fill: rgba(255, 250, 220, 0.15);
}

.case.mortgaged .case-color,
.case.mortgaged .case-icon {
  opacity: 0.35;
  filter: grayscale(80%);
}

.case.mortgaged::after {
  /* impossible en SVG mais visuel via JS */
}

/* ─── PIONS ─── */
.token {
  /* Transition courte avec léger overshoot — chaque case est visible avant la prochaine */
  transition: transform 0.3s cubic-bezier(.5, 0, .25, 1.1);
  cursor: pointer;
}

/* Halo qui suit le pion case par case */
#case-highlight {
  transition: x 0.25s ease, y 0.25s ease, width 0.25s ease, height 0.25s ease, opacity 0.18s ease;
  filter: drop-shadow(0 0 6px rgba(110,224,150,.7));
}

.token-p0 { color: var(--mp-p0); }
.token-p1 { color: var(--mp-p1); }
.token-p2 { color: var(--mp-p2); }
.token-p3 { color: var(--mp-p3); }

/* ─── DÉS ─── */
.die { pointer-events: none; }
#dice-area { display: none; }   /* remplacés par les dés 3D CSS ci-dessous */

/* ═══ DÉS 3D SUR LE PLATEAU (cubes CSS preserve-3d, faces SVG) ═══ */
.dice3d-layer {
  position: absolute; inset: 14px;            /* recouvre le SVG (= padding .board-wrap) */
  pointer-events: none; z-index: 5;
  perspective: 1100px; perspective-origin: 50% 40%;
  --ds: 60px;                                 /* taille d'un dé (ajustée par le JS) */
}
.die3d-wrap { position: absolute; width: var(--ds); height: var(--ds); }
#m9-dw1 { left: 40%; top: 60%; }
#m9-dw2 { left: 52%; top: 62%; }
.die3d-tilt {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: rotateX(-26deg) rotateY(-22deg);  /* angle de vue : on voit 3 faces */
  filter: drop-shadow(0 calc(var(--ds) * 0.18) calc(var(--ds) * 0.13) rgba(0,0,0,.55));
}
.die3d {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.16,.74,.12,1);  /* décélère → se pose */
}
.die3d-face { position: absolute; width: var(--ds); height: var(--ds); }
.die3d-face svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 0.5px rgba(0,0,0,.3)); }
/* lancer : culbute + rebonds (translation), pendant que le cube tourne */
.die3d-wrap.throwing { animation: m9DiceThrow 1.15s cubic-bezier(.2,.55,.2,1); }
/* --fx / --fy = point de départ (origine du jet), fixés au hasard par le JS.
   Le dé glisse depuis (fx,fy), dépasse un peu le centre puis rebondit et se pose. */
@keyframes m9DiceThrow {
  0%   { transform: translate(var(--fx, 0%), var(--fy, 260%)); }
  50%  { transform: translate(calc(var(--fx, 0%) * -0.10), calc(var(--fy, 260%) * -0.10)); }
  68%  { transform: translate(calc(var(--fx, 0%) *  0.05), calc(var(--fy, 260%) *  0.05)); }
  84%  { transform: translate(calc(var(--fx, 0%) * -0.02), calc(var(--fy, 260%) * -0.02)); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .die3d { transition: none; }
  .die3d-wrap.throwing { animation: none; }
}

/* ─── MAISONS / HÔTELS ─── */
.house, .hotel {
  animation: buildingSpawn 0.45s cubic-bezier(.34, 1.56, .64, 1);
  transform-origin: center bottom;
}

@keyframes buildingSpawn {
  0%   { transform: translateY(-12px) scale(0); opacity: 0; }
  60%  { transform: translateY(2px) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ─── PANEL DROITE ─── */
.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(--mp-card), var(--mp-card-2));
  border: 1px solid var(--mp-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(--mp-accent-dim);
  font-weight: 800;
}

/* ─── CARD : Tour en cours ─── */
.card-turn .turn-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.turn-pion {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--mp-p0); border: 2px solid rgba(0,0,0,.4);
  display: inline-block;
  box-shadow: 0 0 12px rgba(255,210,138,.5);
}
.turn-pion[data-p="0"] { background: var(--mp-p0); box-shadow: 0 0 12px rgba(255,210,138,.5); }
.turn-pion[data-p="1"] { background: var(--mp-p1); box-shadow: 0 0 12px rgba(255,100,121,.5); }
.turn-pion[data-p="2"] { background: var(--mp-p2); box-shadow: 0 0 12px rgba(127,248,255,.5); }
.turn-pion[data-p="3"] { background: var(--mp-p3); box-shadow: 0 0 12px rgba(216,179,255,.5); }
.turn-name {
  font-weight: 800; font-size: 16px; color: var(--mp-text);
}
.turn-cash {
  font-family: ui-monospace, monospace; font-size: 26px; font-weight: 900;
  color: var(--mp-accent); margin: 2px 0;
  text-shadow: 0 0 10px rgba(110,224,150,.3);
}
.turn-status {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--mp-warn); min-height: 16px;
}

/* ─── BOUTONS ─── */
.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 rgba(110,224,150,.30);
  transition: transform .1s, box-shadow .2s, background .15s;
}
.btn:hover:not(:disabled) {
  background: rgba(80, 130, 95, .7);
  border-color: var(--mp-accent);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--mp-accent), var(--mp-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(--mp-accent-dim);
  border-color: rgba(110,224,150,.25);
}

.btn-small {
  padding: 6px 10px; font-size: 12px;
}

.btn-warn {
  background: linear-gradient(135deg, #ffd28a, #ff7a1a);
  color: #1a0e00;
}

.btn-danger {
  background: linear-gradient(135deg, #ff6479, #b81e3a);
  color: #fff;
}

.row {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.row:last-child { margin-bottom: 0; }

/* ─── CARD : Joueurs ─── */
.player-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background .15s;
}
.player-row.active {
  background: rgba(110,224,150,.12);
  outline: 1px solid var(--mp-border-strong);
}
.player-row.bankrupt {
  opacity: 0.4;
  filter: grayscale(60%);
}
.player-pion {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--mp-p0); border: 1.5px solid rgba(0,0,0,.4);
}
.player-pion[data-p="0"] { background: var(--mp-p0); }
.player-pion[data-p="1"] { background: var(--mp-p1); }
.player-pion[data-p="2"] { background: var(--mp-p2); }
.player-pion[data-p="3"] { background: var(--mp-p3); }
.player-info {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.player-name {
  font-weight: 700; font-size: 13px; color: var(--mp-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 8px;
}
.player-name > span {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-token-mini {
  width: 34px; height: 28px;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.55));
}
.player-stats {
  font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--mp-text-muted);
}
.player-cash {
  font-family: ui-monospace, monospace; font-weight: 800; font-size: 14px;
  color: var(--mp-accent);
}
.player-row.bankrupt .player-cash {
  color: var(--mp-danger);
  text-decoration: line-through;
}

/* ─── CARD : Log ─── */
.card-log {
  max-height: 320px;
}
#logList {
  max-height: 240px;
  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(--mp-p0); }
.log-entry[data-p="1"] .log-p { color: var(--mp-p1); }
.log-entry[data-p="2"] .log-p { color: var(--mp-p2); }
.log-entry[data-p="3"] .log-p { color: var(--mp-p3); }

/* ─── MODALES ─── */
.modal-bg {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(6, 14, 9, 0.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(--mp-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: 560px; }
.modal-deed { max-width: 320px; padding: 18px; }
.modal-card-pull { max-width: 360px; padding: 20px; }

@keyframes modalPop {
  from { transform: scale(.85); opacity: 0; }
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 22px;
  background: linear-gradient(180deg, #d8ffe2, var(--mp-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;
}
.modal-help {
  font-size: 12px !important;
  color: var(--mp-text-muted) !important;
  font-style: italic;
}

/* ─── MODAL : Newgame ─── */
.ng-section {
  margin-bottom: 14px;
}
.ng-label {
  display: block;
  font-size: 11px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--mp-accent-dim);
  margin-bottom: 6px;
  font-weight: 700;
}
.ng-count.active {
  background: linear-gradient(135deg, var(--mp-accent), var(--mp-accent-deep));
  color: #06140d;
  border: 0;
}
.ng-player-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ng-player-pion {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.4);
}
.ng-player-input {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--mp-border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--mp-text);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
.ng-player-input:focus {
  outline: none;
  border-color: var(--mp-accent);
}
.ng-player-token {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--mp-border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--mp-text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* ─── MODAL : Deed (titre de propriété style officiel) ─── */
.deed {
  background: var(--mp-text);
  color: #1a1006;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  border: 3px solid #1a1006;
  font-family: Georgia, serif;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.deed-header {
  background: var(--deed-color, #888);
  color: #fff;
  padding: 12px 14px 8px;
  text-align: center;
  border-bottom: 3px solid #1a1006;
}
.deed-title-label {
  font-family: ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: .15em;
  text-transform: uppercase;
  opacity: 0.8;
}
.deed-title {
  font-size: 18px;
  font-weight: 900;
  margin-top: 2px;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}
.deed-body {
  padding: 14px 18px;
}
.deed-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  border-bottom: 1px dotted rgba(0,0,0,.15);
}
.deed-row:last-child { border-bottom: none; }
.deed-row.bold { font-weight: 700; padding-top: 6px; }
.deed-row.house-cost { color: #4a3010; font-style: italic; margin-top: 6px; }

/* ─── MODAL : Carte tirée (papier crème) ─── */
.paper-card {
  background: #faf2d8;
  border: 2px solid #3a2410;
  border-radius: 6px;
  padding: 20px 24px;
  text-align: center;
  position: relative;
  font-family: Georgia, serif;
  color: #1a1006;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.paper-card::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(58, 36, 16, 0.4);
  border-radius: 4px;
  pointer-events: none;
}
.paper-card-head {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: #7a4010;
  font-weight: 700;
}
.paper-card-icon {
  font-size: 42px;
  line-height: 1;
  color: #c25a0c;
}
.paper-card-icon.chest { color: #a07020; }
.paper-card-text {
  font-size: 14px;
  line-height: 1.4;
  font-style: italic;
}

/* ─── MODAL : Construction ─── */
.build-group {
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--mp-border);
}
.build-group-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .15em;
  color: var(--mp-accent-dim);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.build-group-swatch {
  width: 14px; height: 14px; border-radius: 3px;
}
.build-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
}
.build-row .build-name {
  color: var(--mp-text); font-weight: 600;
}
.build-row .build-count {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--mp-accent);
  min-width: 36px;
  text-align: center;
}

/* ─── MODAL : Hypothèques ─── */
.mort-row {
  display: grid;
  grid-template-columns: 16px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--mp-border);
}
.mort-row:last-child { border-bottom: none; }
.mort-swatch {
  width: 12px; height: 12px; border-radius: 2px;
}
.mort-name {
  color: var(--mp-text); font-weight: 600;
}
.mort-name.mortgaged { color: var(--mp-text-muted); text-decoration: line-through; }
.mort-amount {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--mp-accent);
}

/* ─── MODAL : Détail joueur (grille de fiches de propriété SVG) ─── */
.modal-player { max-width: 820px; }

#playerModalTitle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.deed-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 6px 4px 2px;
}

.deed-grid::-webkit-scrollbar { width: 8px; }
.deed-grid::-webkit-scrollbar-track { background: rgba(0,0,0,.2); border-radius: 4px; }
.deed-grid::-webkit-scrollbar-thumb { background: rgba(110,224,150,.3); border-radius: 4px; }

.deed-svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  transition: transform .2s ease, filter .2s ease;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
.deed-svg:hover {
  transform: translateY(-4px) scale(1.03);
  filter: drop-shadow(0 10px 24px rgba(110,224,150,.45));
}

.deed-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--mp-text-muted);
  padding: 40px 20px;
  font-style: italic;
  font-size: 14px;
}

.deed-group-label {
  grid-column: 1 / -1;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mp-accent-dim);
  font-weight: 800;
  margin-top: 4px;
  margin-bottom: -4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deed-group-label::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--group-color, #888);
}
.deed-group-label.complete::after {
  content: '★ MONOPOLE';
  font-size: 9px;
  color: var(--mp-warn);
  letter-spacing: 0.15em;
}

/* Cliquables sur player rows */
.player-row { cursor: pointer; }
.player-row:hover:not(.bankrupt) {
  background: rgba(110,224,150,.18);
}

/* ─── Plein écran : géré uniformément par shared.css (.layout + .panel conservé) ─── */

/* ─── Responsive ajustements ─── */
@media (max-width: 600px) {
  main { padding: 12px 8px 40px; }
  .board-wrap { padding: 8px; border-radius: 12px; }
  .card { padding: 10px 12px; }
  .modal { padding: 18px 20px; }
  .modal h2 { font-size: 18px; }
}

/* ─── Highlight case sélectionnée pour deed view ─── */
.case.highlight rect.case-bg {
  filter: url(#f-glow-active);
}
