:root {
  --ink: #17202a;
  --muted: #697586;
  --paper: #f6f3ec;
  --card: #fffdf8;
  --line: #d5d0c5;
  --p1: #ef5b4c;
  --p1-soft: #ffb9af;
  --p2: #337ccf;
  --p2-soft: #acd2ff;
  --shadow: 0 18px 50px rgba(35, 41, 48, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(239, 91, 76, .11), transparent 28rem),
    radial-gradient(circle at 85% 90%, rgba(51, 124, 207, .12), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.game-shell { display: grid; grid-template-columns: minmax(0, 1fr) 180px; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px 22px; width: min(96vw, 1050px); min-height: 100vh; margin: 0 auto; padding: clamp(10px, 2vh, 22px) 0 12px; }
.hero { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 3px; color: var(--p1); font-weight: 800; font-size: .72rem; letter-spacing: .18em; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2.6rem, 7vw, 4.7rem); line-height: .95; letter-spacing: -.05em; }
.subtitle { margin: 9px 0 0; color: var(--muted); }

.new-game {
  border: 0; border-radius: 999px; padding: 12px 19px; color: white; background: var(--ink);
  font-weight: 750; cursor: pointer; box-shadow: 0 7px 18px rgba(23, 32, 42, .18); transition: transform .15s;
}
.new-game:hover { transform: translateY(-2px); }
.game-controls { display: flex; align-items: center; gap: 9px; }
.game-controls label { color: var(--muted); font-size: .78rem; font-weight: 800; }
.game-controls select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; color: var(--ink); background: var(--card); font-weight: 700; }

.scoreboard { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 14px; }
.player { display: flex; align-items: center; gap: 12px; padding: 13px 17px; border: 2px solid transparent; border-radius: 16px; background: rgba(255, 253, 248, .75); transition: .2s; }
.player-two { justify-content: flex-start; text-align: left; }
.player.active { border-color: currentColor; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(35, 41, 48, .08); }
.player-one { color: var(--p1); }
.player-two { color: var(--p2); }
.player-dot { width: 15px; height: 15px; flex: none; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 18%, transparent); }
.player-name { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.player strong { display: block; color: currentColor; font: 800 1.65rem/1 Georgia, serif; }
.turn-message { order: -1; color: var(--muted); font-size: .82rem; font-weight: 700; text-align: center; }
.power-button { border: 1px solid #e0a51e; border-radius: 12px; padding: 10px; color: #725000; background: #fff1b8; font-weight: 800; cursor: pointer; }
.power-button:hover:not(:disabled) { background: #ffe58a; }
.power-button:disabled { opacity: .42; cursor: default; }

.board-wrap { grid-column: 1; grid-row: 2; width: min(100%, calc(100vh - 175px)); margin-inline: auto; padding: clamp(10px, 2vh, 20px); border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.board { position: relative; width: 100%; aspect-ratio: 1; user-select: none; touch-action: manipulation; }
.cell { position: absolute; transition: background .25s, transform .25s; }
.cell.claimed { animation: claim .3s ease-out; }
.cell.player-0 { background: var(--p1-soft); }
.cell.player-1 { background: var(--p2-soft); }
.cell.bonus::after { content: "×2"; position: absolute; inset: 0; display: grid; place-items: center; color: #8a6410; font: 900 clamp(.65rem, 1.7vw, 1rem) Georgia, serif; text-shadow: 0 1px #fff; }
.cell.claimed.bonus::after { color: rgba(23, 32, 42, .62); }

.edge { position: absolute; z-index: 2; padding: 0; border: 0; background: transparent; cursor: pointer; }
.edge::after { content: ""; position: absolute; border-radius: 99px; background: var(--line); transition: background .12s, transform .12s, box-shadow .12s; }
.edge.horizontal { height: 18px; transform: translateY(-50%); }
.edge.horizontal::after { left: 3px; right: 3px; top: 7px; height: 4px; }
.edge.vertical { width: 18px; transform: translateX(-50%); }
.edge.vertical::after { top: 3px; bottom: 3px; left: 7px; width: 4px; }
.edge:not(.drawn):hover::after { background: var(--current); transform: scale(1.12); box-shadow: 0 0 0 3px color-mix(in srgb, var(--current) 16%, transparent); }
.edge.drawn { cursor: default; }
.edge.drawn::after { background: var(--owner); }
.edge.boundary::after { background: var(--ink); }
.edge.obstacle::after { background: #8993a0; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #8993a0; }
.edge.ai-last-move::after { animation: ai-last-move 1s ease-in-out 5; }
.board.ai-turn .edge:not(.drawn) { cursor: wait; }
.board.ai-turn .edge:not(.drawn):hover::after { background: var(--line); transform: none; box-shadow: none; }

.dot { position: absolute; z-index: 4; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); pointer-events: none; }
.hint { grid-column: 1; grid-row: 3; margin: 0; color: var(--muted); text-align: center; font-size: .86rem; }
.notification { position: fixed; z-index: 20; top: 18px; left: 50%; padding: 13px 20px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-weight: 800; transform: translate(-50%, -90px); opacity: 0; transition: .25s; pointer-events: none; }
.notification.show { transform: translate(-50%, 0); opacity: 1; }

.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(23, 32, 42, .58); backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-card { width: min(92vw, 420px); padding: 38px; border-radius: 24px; background: var(--card); text-align: center; box-shadow: var(--shadow); }
.modal-card h2 { margin: 6px 0 10px; font: 800 2.2rem Georgia, serif; }
.modal-card p:not(.eyebrow) { color: var(--muted); margin-bottom: 24px; }

@keyframes claim { 50% { transform: scale(.91); } }
@keyframes ai-last-move {
  0%, 100% { background: var(--owner); box-shadow: none; }
  50% { background: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--owner) 38%, transparent); }
}
@media (max-width: 700px) {
  .game-shell { display: block; width: min(94vw, 600px); min-height: auto; padding-top: 22px; }
  .hero { align-items: flex-end; margin-bottom: 12px; }
  .subtitle { display: none; }
  .new-game { padding: 10px 14px; font-size: .85rem; }
  .game-controls label { display: none; }
  .game-controls { gap: 5px; }
  .scoreboard { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
  .turn-message { grid-column: 1 / -1; grid-row: 2; order: initial; }
  .power-button { grid-column: 1 / -1; grid-row: 3; }
  .player-two { justify-content: flex-end; text-align: right; }
  .player { padding: 10px 12px; }
  .board-wrap { width: min(100%, calc(100vh - 185px)); min-width: 280px; border-radius: 17px; }
  .hint { margin-top: 10px; }
  .edge.horizontal { height: 14px; }
  .edge.horizontal::after { top: 5px; }
  .edge.vertical { width: 14px; }
  .edge.vertical::after { left: 5px; }
  .dot { width: 7px; height: 7px; }
}

@media (max-height: 700px) {
  .subtitle, .hint { display: none; }
  h1 { font-size: clamp(2rem, 7vh, 3.2rem); }
  .board-wrap { width: min(100%, calc(100vh - 105px)); }
}

@media (max-width: 700px) and (max-height: 700px) {
  .board-wrap { width: min(100%, calc(100vh - 155px)); }
}

@media (prefers-reduced-motion: reduce) {
  .edge.ai-last-move::after { animation: none; box-shadow: 0 0 0 5px color-mix(in srgb, var(--owner) 38%, transparent); }
}

/* Direction artistique — salon de jeu précieux */
:root {
  --ink: #f4efe3; --muted: #aeb9ba; --paper: #071a1b; --card: #102a29; --line: #4d625f;
  --p1: #ff735f; --p1-soft: #c95043; --p2: #58a9ff; --p2-soft: #347fc8;
  --gold: #d9b968; --gold-light: #f6df9b;
  --shadow: 0 28px 70px rgba(0,0,0,.42), 0 2px 10px rgba(0,0,0,.3);
}
body { overflow-x: hidden; background: radial-gradient(circle at 14% 18%, rgba(38,115,103,.34), transparent 30rem), radial-gradient(circle at 88% 82%, rgba(128,80,31,.2), transparent 31rem), linear-gradient(145deg,#061516,#0b2423 55%,#071819); }
body::before { content:""; position:fixed; inset:0; opacity:.22; pointer-events:none; background-image:repeating-linear-gradient(115deg,transparent 0 12px,rgba(255,255,255,.018) 13px 14px); }
.game-shell { position:relative; z-index:1; grid-template-columns:minmax(0,1fr) 194px; }
.hero { position:relative; padding:0 3px 12px; border-bottom:1px solid rgba(217,185,104,.25); }
.hero::after { content:""; position:absolute; bottom:-1px; left:0; width:150px; height:1px; background:linear-gradient(90deg,var(--gold),transparent); }
.eyebrow { color:var(--gold); font-size:.68rem; letter-spacing:.24em; text-shadow:0 0 18px rgba(217,185,104,.3); }
h1 { color:#fffaf0; font-family:Georgia,"Times New Roman",serif; font-weight:500; letter-spacing:-.055em; text-shadow:0 5px 30px rgba(0,0,0,.38); }
.subtitle { color:var(--muted); letter-spacing:.02em; }
.game-controls { padding:6px; border:1px solid rgba(217,185,104,.2); border-radius:16px; background:rgba(3,17,17,.38); box-shadow:inset 0 1px rgba(255,255,255,.04); }
.game-controls label { margin-left:5px; color:var(--gold-light); letter-spacing:.1em; }
.game-controls select { border-color:rgba(217,185,104,.3); color:#eee7d6; background:#173330; outline-color:var(--gold); }
.new-game { color:#14201d; background:linear-gradient(135deg,var(--gold-light),#c89e42); box-shadow:0 8px 24px rgba(0,0,0,.25),inset 0 1px rgba(255,255,255,.65); }
.new-game:hover { transform:translateY(-2px); filter:brightness(1.08); }
.scoreboard { gap:12px; }
.player { position:relative; overflow:hidden; border:1px solid rgba(255,255,255,.08); background:linear-gradient(145deg,rgba(24,58,55,.88),rgba(9,31,30,.92)); box-shadow:inset 0 1px rgba(255,255,255,.05),0 10px 24px rgba(0,0,0,.18); }
.player::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:currentColor; opacity:.42; }
.player.active { border-color:color-mix(in srgb,currentColor 60%,var(--gold)); transform:translateX(-4px); box-shadow:0 0 0 1px rgba(217,185,104,.12),0 14px 30px rgba(0,0,0,.28); }
.player-name { color:#bdc9c6; letter-spacing:.06em; text-transform:uppercase; }
.player strong { font-size:1.9rem; text-shadow:0 0 20px color-mix(in srgb,currentColor 35%,transparent); }
.player-dot { box-shadow:0 0 0 4px color-mix(in srgb,currentColor 15%,transparent),0 0 16px currentColor; }
.turn-message { min-height:35px; display:grid; place-items:center; padding:7px; border-block:1px solid rgba(217,185,104,.16); color:var(--gold-light); font-family:Georgia,serif; font-style:italic; }
.power-button { border-color:rgba(217,185,104,.55); color:#2e2410; background:linear-gradient(135deg,#fff0b3,#d9b04d); box-shadow:0 8px 20px rgba(0,0,0,.22),inset 0 1px rgba(255,255,255,.7); }
.power-button:hover:not(:disabled) { background:linear-gradient(135deg,#fff7d5,#e8c66f); transform:translateY(-1px); }
.board-wrap { position:relative; padding:clamp(15px,2.2vh,23px); border:1px solid rgba(246,223,155,.48); background:linear-gradient(145deg,#173a35,#0b2423); box-shadow:var(--shadow),inset 0 0 0 5px #0a211f,inset 0 0 0 6px rgba(217,185,104,.24); }
.board-wrap::before,.board-wrap::after { content:"✦"; position:absolute; z-index:6; color:var(--gold); font-size:12px; text-shadow:0 0 8px var(--gold); }
.board-wrap::before { top:4px; left:7px; } .board-wrap::after { right:7px; bottom:4px; }
.board { border-radius:2px; background:rgba(3,17,17,.28); box-shadow:inset 0 0 35px rgba(0,0,0,.25); }
.cell { border:1px solid rgba(255,255,255,.018); }
.cell.player-0 { background:linear-gradient(135deg,#dc6758,#a93b35); box-shadow:inset 0 0 16px rgba(255,255,255,.12); }
.cell.player-1 { background:linear-gradient(135deg,#579ee4,#2867a8); box-shadow:inset 0 0 16px rgba(255,255,255,.12); }
.cell.bonus::after { color:var(--gold-light); text-shadow:0 1px 3px #071414,0 0 10px rgba(217,185,104,.55); }
.cell.claimed.bonus::after { color:#fff0bd; }
.edge::after { background:#526763; }
.edge:not(.drawn):hover::after { box-shadow:0 0 0 3px color-mix(in srgb,var(--current) 20%,transparent),0 0 13px var(--current); }
.edge.boundary::after { background:linear-gradient(90deg,#d6b55d,#f1dd9c,#af8633); box-shadow:0 0 7px rgba(217,185,104,.35); }
.edge.obstacle::after { background:#9ca9a5; box-shadow:0 0 0 2px #15332f,0 0 0 3px #75847f,0 0 9px rgba(255,255,255,.22); }
.dot { background:radial-gradient(circle at 35% 30%,#fff1bd,#c0943c 50%,#594318); box-shadow:0 2px 5px #000,0 0 5px rgba(217,185,104,.35); }
.hint { color:#91a29f; letter-spacing:.025em; }
.notification { border:1px solid rgba(246,223,155,.45); color:#fff6dc; background:linear-gradient(135deg,#1d403a,#0c2523); }
.modal { background:rgba(1,11,11,.75); }
.modal-card { border:1px solid rgba(217,185,104,.45); background:linear-gradient(145deg,#173a35,#091f1e); }
.modal-card h2 { color:#fff6df; }
@media (max-width:700px) { .game-shell{width:min(95vw,600px)} .hero{padding-bottom:10px} .game-controls{padding:4px} .scoreboard{gap:7px} .player.active{transform:translateY(-2px)} .board-wrap{padding:13px} }

/* Nouvelle direction — atelier éditorial clair */
:root {
  --ink: #27343b;
  --muted: #737c7c;
  --paper: #eee9df;
  --card: #fbf9f3;
  --line: #b9b8b0;
  --p1: #c94f3d;
  --p1-soft: #dc705f;
  --p2: #24A09A;
  --p2-soft: #5EA6A3;
  --gold: #9b7130;
  --gold-light: #c9a253;
  --shadow: 0 18px 45px rgba(48, 55, 54, .13), 0 3px 10px rgba(48, 55, 54, .08);
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(198, 94, 77, .08), transparent 25rem),
    radial-gradient(circle at 92% 90%, rgba(57, 124, 123, .1), transparent 28rem),
    var(--paper);
}

body::before {
  opacity: .45;
  background-image: radial-gradient(rgba(39, 52, 59, .08) .65px, transparent .65px);
  background-size: 8px 8px;
}

.hero { border-bottom-color: rgba(39, 52, 59, .13); }
.hero::after { width: 90px; background: var(--p1); }
.eyebrow { color: var(--p1); text-shadow: none; }
h1 { color: var(--ink); font-weight: 600; text-shadow: none; }
.subtitle { color: var(--muted); }

.game-controls {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.difficulty-control { display: flex; align-items: center; gap: 7px; padding: 6px; border: 1px solid rgba(39,52,59,.12); border-radius: 13px; background: rgba(251,249,243,.72); }
.game-controls label { margin-left: 3px; color: var(--muted); }
.difficulty-control { position: relative; }
.difficulty-control select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.difficulty-trigger { min-width: 112px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--ink); background: #fffefa; font-weight: 750; cursor: pointer; }
.difficulty-trigger span { color: var(--p2); font-size: 1rem; transition: transform .18s; }
.difficulty-trigger[aria-expanded="true"] span { transform: rotate(180deg); }
.difficulty-menu { position: absolute; z-index: 30; top: calc(100% + 7px); right: 0; width: 205px; padding: 6px; border: 1px solid #d7d2c7; border-radius: 14px; background: #fffdf8; box-shadow: 0 16px 38px rgba(39,52,59,.18); }
.difficulty-menu[hidden] { display: none; }
.difficulty-menu button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-radius: 9px; padding: 10px; color: var(--ink); background: transparent; font-weight: 750; text-align: left; cursor: pointer; }
.difficulty-menu button:hover { background: #f0eee7; }
.difficulty-menu button[aria-selected="true"] { color: #176d69; background: #e1f0ed; }
.difficulty-menu small { color: var(--muted); font-size: .67rem; font-weight: 600; white-space: nowrap; }
.game-controls select { border-color: #d2d0c8; color: var(--ink); background: #fffefa; }
.new-game {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 7px 16px rgba(39, 52, 59, .18);
}
.new-game:hover { filter: none; background: #17252c; }

.player {
  overflow: hidden;
  border: 1px solid #dedbd2;
  background: rgba(251, 249, 243, .82);
  box-shadow: 0 7px 20px rgba(50, 57, 55, .07);
}
.player > div { flex: 1; }
.player-one { text-align: left; }
.player-two { justify-content: flex-start; text-align: left; }
.player-two .player-dot { order: -1; }
.player-two::before { right: auto; left: 0; }
.player::before { width: 4px; border-radius: 4px; opacity: .85; }
.player.active {
  border-color: currentColor;
  transform: translateX(-3px);
  box-shadow: 0 9px 24px rgba(50, 57, 55, .12);
}
.player-name { color: var(--muted); }
.player strong { text-shadow: none; }
.player-dot { box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 13%, transparent); }
.turn-message {
  border-block-color: rgba(39, 52, 59, .1);
  color: var(--muted);
  font-family: inherit;
  font-style: normal;
}
.power-button {
  border-color: #d7c38f;
  color: #604d26;
  background: #f5e9c8;
  box-shadow: none;
}
.power-button:hover:not(:disabled) { background: #ecdbab; transform: translateY(-1px); }

.board-wrap {
  padding: clamp(14px, 2vh, 20px);
  border: 1px solid #d8d3c8;
  background: var(--card);
  box-shadow: var(--shadow);
}
.board-wrap::before, .board-wrap::after { content: none; }
.board { background: #f1eee6; box-shadow: inset 0 0 0 1px rgba(39,52,59,.04); }
.cell { border-color: rgba(39, 52, 59, .015); }
.cell.player-0 { background: linear-gradient(135deg, #e17c69, var(--p1-soft)); box-shadow: inset 0 0 0 1px rgba(129,50,39,.16); }
.cell.player-1 { background: #5EA6A3; box-shadow: inset 0 0 0 1px rgba(22,77,76,.2); }
.cell.bonus::after { color: #795516; text-shadow: 0 1px rgba(255,255,255,.9); }
.cell.claimed.bonus::after { color: rgba(39, 52, 59, .68); }
.edge::after { background: #d8d5cc; }
.edge:not(.drawn):hover::after { box-shadow: 0 0 0 3px color-mix(in srgb, var(--current) 14%, transparent); }
.edge.boundary::after { background: var(--ink); box-shadow: none; }
.edge.obstacle::after { background: #596562; box-shadow: 0 1px 3px rgba(39,52,59,.28); }
.edge.obstacle.horizontal::after { top: 6px; height: 6px; }
.edge.obstacle.vertical::after { left: 6px; width: 6px; }
.dot {
  background: var(--ink);
  opacity: .58;
  box-shadow: none;
}
.hint { color: var(--muted); }
.notification { border-color: transparent; color: #fff; background: var(--ink); }
.modal { background: rgba(39, 52, 59, .48); }
.modal-card { border: 1px solid #ded9cc; background: var(--card); }
.modal-card h2 { color: var(--ink); }

@media (max-width: 700px) {
  .player.active { transform: translateY(-2px); }
}
