/* Cartographeur — thème « atelier du cartographe » */

:root {
  --paper: #f1e2bd;
  --paper-light: #f9efd6;
  --paper-dark: #e2cd9d;
  --ink: #36281a;
  --ink-soft: #5d4a33;
  --leather: #6f4a26;
  --leather-dark: #503317;
  --gold: #c99a3f;
  --gold-light: #e8c878;

  --forest: #4c8141;
  --forest-2: #2f5c2a;
  --village: #c25940;
  --village-2: #93402c;
  --farm: #e0b13e;
  --farm-2: #bb8d23;
  --water: #4e87c1;
  --water-2: #36649a;
  --monster: #8d57b4;
  --monster-2: #663d8c;
  --mountain: #9b8d76;
  --mountain-2: #6f6350;
  --waste: #564433;
  --waste-2: #3c2e21;

  --valid: #6fae57;
  --invalid: #c4513f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
  font-size: 17px;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 248, 222, 0.9), rgba(255, 248, 222, 0) 60%),
    radial-gradient(ellipse at 50% 110%, rgba(94, 64, 28, 0.35), rgba(94, 64, 28, 0) 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.26 0 0 0 0 0.13 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #efdcb2 0%, #e6cfa0 55%, #dbc28e 100%);
}

.screen { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.hidden { display: none !important; }

h1 {
  font-family: 'Cinzel', Georgia, serif;
  text-align: center;
  font-size: 2.3rem;
  letter-spacing: 0.06em;
  margin: 1.2rem 0 0.2rem;
  color: var(--leather-dark);
  text-shadow: 0 1px 0 rgba(255, 250, 230, 0.8), 0 3px 8px rgba(80, 50, 15, 0.25);
}
h2, h3 { font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.03em; }

.subtitle {
  text-align: center;
  margin-top: 0.2rem;
  font-style: italic;
  color: var(--ink-soft);
}
.subtitle::after {
  content: '';
  display: block;
  width: 180px;
  height: 12px;
  margin: 0.7rem auto 0;
  background:
    radial-gradient(circle at center, var(--gold) 2.5px, transparent 3px) center / 14px 12px no-repeat,
    linear-gradient(to right, transparent, var(--leather) 25%, transparent 49%, transparent 51%, var(--leather) 75%, transparent) center / 100% 1.5px no-repeat;
}

/* --- Panneaux parchemin --- */

.panel, #edicts-panel, #turn-panel, #board-area, #game-header {
  background:
    linear-gradient(rgba(255, 251, 238, 0.55), rgba(255, 251, 238, 0) 30%),
    var(--paper);
  border: 1px solid rgba(111, 74, 38, 0.55);
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 4px rgba(255, 250, 232, 0.55),
    inset 0 0 35px rgba(143, 100, 45, 0.18),
    0 10px 24px rgba(60, 38, 10, 0.28);
}

.panel { padding: 1.4rem 1.6rem; max-width: 680px; margin: 1.2rem auto; }

label { display: block; margin: 0.7rem 0; font-weight: 600; }
input, select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid rgba(111, 74, 38, 0.6);
  border-radius: 8px;
  box-shadow: inset 0 2px 5px rgba(80, 51, 23, 0.15);
}
input:focus, select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--leather);
  border-radius: 9px;
  background: linear-gradient(180deg, var(--paper-light), var(--paper-dark));
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(70, 45, 15, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 9px rgba(70, 45, 15, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  width: 100%;
  margin-top: 0.9rem;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff6dd;
  text-shadow: 0 1px 2px rgba(60, 35, 5, 0.6);
  background: linear-gradient(180deg, #a8702c, var(--leather) 55%, var(--leather-dark));
  border: 1px solid var(--leather-dark);
  box-shadow: 0 3px 8px rgba(60, 38, 10, 0.4), inset 0 1px 0 rgba(255, 230, 170, 0.45);
}

.home-columns { display: flex; gap: 1.8rem; margin-top: 1.2rem; flex-wrap: wrap; }
.home-col { flex: 1; min-width: 230px; }
.home-col h2 {
  font-size: 1.05rem;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.35rem;
  color: var(--leather-dark);
}

.error { color: #9c2714; font-weight: 600; }

.code {
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 0.35em;
  background: var(--leather-dark);
  color: var(--gold-light);
  padding: 0.12em 0.45em 0.12em 0.6em;
  border-radius: 8px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 250, 230, 0.6);
}

.player-list { list-style: none; padding: 0; font-size: 1.05rem; }
.player-list li { padding: 0.5rem 0.6rem; border-bottom: 1px dashed rgba(111, 74, 38, 0.5); }

/* --- En-tête de partie --- */

#game-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 1rem;
  margin-bottom: 0.9rem;
  font-weight: 600;
}
#game-header > div {
  background: rgba(255, 250, 235, 0.65);
  border: 1px solid rgba(111, 74, 38, 0.35);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  box-shadow: inset 0 1px 3px rgba(80, 51, 23, 0.12);
}
#btn-abandon {
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border-color: #8a3a2a;
  color: #7e2f1f;
  background: linear-gradient(180deg, #f3ddcd, #e7c3ab);
}
#btn-abandon:hover { filter: none; background: linear-gradient(180deg, #eecdb8, #dfae90); }

.abandon-note {
  text-align: center;
  font-weight: 600;
  color: #7e2f1f;
  background: linear-gradient(180deg, #f3ddcd, #ecd0ba);
  border: 1px solid #8a3a2a;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
}

#game-header[data-season="spring"] #season-info { background: #e4eed2; border-color: #7d9c52; }
#game-header[data-season="summer"] #season-info { background: #faecc3; border-color: #c9a23f; }
#game-header[data-season="autumn"] #season-info { background: #f6ddc2; border-color: #c07b3a; }
#game-header[data-season="winter"] #season-info { background: #dde8f0; border-color: #6e93b4; }

/* --- Disposition --- */

#game-layout {
  display: grid;
  grid-template-columns: 270px minmax(330px, 1fr) 310px;
  gap: 0.9rem;
  align-items: start;
}
@media (max-width: 980px) {
  #game-layout { grid-template-columns: 1fr; }
}

#edicts-panel, #turn-panel, #board-area { padding: 0.9rem; }

/* --- Décrets --- */

#edicts-panel h3, #turn-panel h3 {
  margin: 0.1rem 0 0.6rem;
  font-size: 1rem;
  color: var(--leather-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.3rem;
}

.edict {
  position: relative;
  border: 1px solid rgba(111, 74, 38, 0.5);
  border-radius: 10px;
  padding: 0.6rem 0.65rem;
  margin-bottom: 0.7rem;
  background: linear-gradient(180deg, var(--paper-light), #f3e6c4);
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(70, 45, 15, 0.15);
  transition: box-shadow 0.2s ease;
}
.edict.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fdf3d4, #f6e4ae);
  box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(201, 154, 63, 0.6);
}
.edict.active::before {
  content: '✦ Décret de la saison';
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9c7320;
  margin-bottom: 0.25rem;
}
.edict-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}
.edict-badge {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff6dd;
  background: linear-gradient(180deg, #a8702c, var(--leather-dark));
  border-radius: 50%;
  box-shadow: inset 0 1px 0 rgba(255, 230, 170, 0.5), 0 1px 3px rgba(60, 38, 10, 0.4);
}
.edict-name { font-weight: 700; font-size: 1rem; color: var(--leather-dark); }
.edict-score { margin-left: auto; font-weight: 700; color: #9c7320; }
.edict-text { color: var(--ink); }

/* --- Plateau --- */

#board-title { margin: 0.2rem 0 0.5rem; text-align: center; font-size: 1.02rem; color: var(--leather-dark); }

#board-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  gap: 2px;
  padding: 5px;
  background: linear-gradient(150deg, #7d5630, var(--leather-dark));
  border: 1px solid var(--leather-dark);
  border-radius: 10px;
  aspect-ratio: 1;
  max-width: 580px;
  margin: 0 auto;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45), 0 6px 16px rgba(60, 38, 10, 0.35);
  touch-action: manipulation;
}

.cell {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 252, 240, 0.75), rgba(255, 252, 240, 0) 60%),
    #f6ebca;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 2.5vw, 19px);
  line-height: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: filter 0.1s ease;
}
.cell > * { pointer-events: none; }

.cell.forest { background: linear-gradient(145deg, var(--forest), var(--forest-2)); }
.cell.village { background: linear-gradient(145deg, var(--village), var(--village-2)); }
.cell.farm { background: linear-gradient(145deg, var(--farm), var(--farm-2)); }
.cell.water { background: linear-gradient(145deg, var(--water), var(--water-2)); }
.cell.monster { background: linear-gradient(145deg, var(--monster), var(--monster-2)); }
.cell.mountain { background: linear-gradient(145deg, var(--mountain), var(--mountain-2)); }
.cell.waste { background: linear-gradient(145deg, var(--waste), var(--waste-2)); }
.cell.forest, .cell.village, .cell.farm, .cell.water, .cell.monster, .cell.mountain, .cell.waste {
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.28);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Case ruines libre : filigrane bien visible. */
.cell.ruin-empty::before {
  content: '🏛️';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  opacity: 0.55;
  filter: grayscale(0.3) sepia(0.4);
}
/* Case ruines recouverte : petit repère dans le coin. */
.cell.ruin-mark::after {
  content: '◆';
  position: absolute;
  top: 0;
  right: 2px;
  font-size: 0.5em;
  color: #fff3d6;
  text-shadow: 0 0 3px rgba(40, 25, 8, 0.9);
}

/* Fantôme : aperçu du terrain choisi (survol ou placement en attente). */
.cell.ghost {
  opacity: 0.82;
  z-index: 1;
}
.cell.ghost.preview {
  outline: 3px solid var(--valid);
  outline-offset: -3px;
  box-shadow: 0 0 9px rgba(111, 174, 87, 0.85);
}
.cell.preview-invalid {
  outline: 3px solid var(--invalid);
  outline-offset: -3px;
  z-index: 1;
}
.cell.ghost.staged {
  outline: 3px dashed rgba(255, 252, 240, 0.95);
  outline-offset: -3px;
  animation: staged-pulse 1.1s ease-in-out infinite;
}
@keyframes staged-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

#board-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.1rem;
  margin: 0.55rem auto 0;
  max-width: 580px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
#board-legend small { opacity: 0.8; }

#board-banner {
  background: linear-gradient(180deg, var(--monster), var(--monster-2));
  color: #fdf4ff;
  text-align: center;
  border: 1px solid var(--monster-2);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.7rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(40, 10, 60, 0.6);
  box-shadow: 0 4px 10px rgba(70, 40, 100, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: banner-in 0.35s ease;
}
#board-banner.ruins {
  background: linear-gradient(180deg, #a8702c, var(--leather-dark));
  border-color: var(--leather-dark);
  box-shadow: 0 4px 10px rgba(70, 45, 15, 0.35), inset 0 1px 0 rgba(255, 235, 180, 0.35);
}
@keyframes banner-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#turn-status { text-align: center; margin-top: 0.7rem; font-style: italic; color: var(--ink-soft); }

/* --- Panneau de tour --- */

.card-name { font-size: 1.18rem; font-weight: 700; color: var(--leather-dark); }
.card-time { color: var(--ink-soft); font-size: 0.85rem; }

#terrain-buttons, #shape-buttons { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.65rem 0; }

.terrain-btn {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 2px solid rgba(54, 40, 26, 0.7);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.3), 0 2px 5px rgba(70, 45, 15, 0.3);
}
.terrain-btn.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  transform: scale(1.06);
}
.terrain-btn.forest { background: linear-gradient(145deg, var(--forest), var(--forest-2)); }
.terrain-btn.village { background: linear-gradient(145deg, var(--village), var(--village-2)); }
.terrain-btn.farm { background: linear-gradient(145deg, var(--farm), var(--farm-2)); }
.terrain-btn.water { background: linear-gradient(145deg, var(--water), var(--water-2)); }
.terrain-btn.monster { background: linear-gradient(145deg, var(--monster), var(--monster-2)); }

.shape-btn {
  background: var(--paper-light);
  border: 2px solid rgba(111, 74, 38, 0.6);
  border-radius: 10px;
  padding: 8px;
  position: relative;
}
.shape-btn.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  background: #fff8e3;
}
.shape-btn .coin-badge { position: absolute; top: -9px; right: -9px; font-size: 1rem; filter: drop-shadow(0 1px 2px rgba(70, 45, 15, 0.5)); }
.shape-grid { display: grid; gap: 2px; }
.shape-cell { width: 14px; height: 14px; }
.shape-cell.on {
  background: linear-gradient(145deg, #54402a, var(--ink));
  border-radius: 3px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.orient-buttons { display: flex; gap: 0.45rem; }
.orient-buttons button { flex: 1; }
.fallback { font-weight: 400; font-size: 0.85rem; color: var(--ink-soft); }
.fallback input { display: inline; width: auto; box-shadow: none; }

/* --- Joueurs --- */

#players-panel { margin-top: 1.1rem; }
.player-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.3rem;
  border-top: 1px dashed rgba(111, 74, 38, 0.45);
  font-size: 0.9rem;
  line-height: 1.3;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b04a3a;
  flex-shrink: 0;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 0 4px rgba(176, 74, 58, 0.6);
}
.dot.on { background: #5d8f4e; box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 0 5px rgba(93, 143, 78, 0.8); }

.mini-board {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  width: 70px;
  height: 70px;
  gap: 0;
  padding: 2px;
  background: var(--leather-dark);
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(60, 38, 10, 0.4);
  transition: transform 0.12s ease;
}
.mini-board:hover { transform: scale(1.08); }
.mini-cell { background: #f6ebca; }
.mini-cell.forest { background: var(--forest); }
.mini-cell.village { background: var(--village); }
.mini-cell.farm { background: var(--farm); }
.mini-cell.water { background: var(--water); }
.mini-cell.monster { background: var(--monster); }
.mini-cell.mountain { background: var(--mountain); }
.mini-cell.waste { background: var(--waste); }

/* --- Résultats --- */

table.results {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  background: var(--paper-light);
  box-shadow: 0 3px 8px rgba(70, 45, 15, 0.2);
}
table.results th, table.results td {
  border: 1px solid rgba(111, 74, 38, 0.5);
  padding: 0.45rem 0.55rem;
  text-align: center;
}
table.results th {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.85rem;
  background: linear-gradient(180deg, #a8702c, var(--leather));
  color: #fff6dd;
  text-shadow: 0 1px 2px rgba(60, 35, 5, 0.5);
}
table.results tr:nth-child(odd) td { background: rgba(226, 205, 157, 0.35); }
.winner td {
  font-weight: 700;
  background: linear-gradient(180deg, #f7e7b5, #ecd58a) !important;
  box-shadow: inset 0 0 0 1px var(--gold);
}
.solo-title { text-align: center; font-size: 1.3rem; margin: 0.9rem 0; color: var(--leather-dark); }
