/* Mühle – styles. Mobile-first, same look as the other games; no external fonts/images. */
:root {
  --felt: #166534; --felt-dark: #14532d; --ink: #1f2937; --muted: #6b7280; --accent: #f59e0b;
  --wood: #e9cf9b; --wood-dark: #c9a463; --line: #4a3218;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: #f3f4f1; }
a { color: #166534; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.site-header { display: flex; align-items: baseline; gap: 10px; padding: 8px 14px; background: var(--felt-dark); color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.brand-sub { font-size: .8rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { max-width: 980px; margin: 0 auto; padding: 0 10px 24px; }
h1 { font-size: clamp(1.05rem, 4.2vw, 1.6rem); line-height: 1.25; margin: 10px 2px 8px; }

/* ----------------------------------------------------------------- game --- */
.game { position: relative; background: radial-gradient(ellipse at center, #1d7a42 0%, var(--felt) 55%, var(--felt-dark) 100%);
  color: #fff; border-radius: 16px; padding: 10px 12px 12px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.toolbar { display: flex; flex-wrap: wrap; gap: 5px; }
.toolbar button, .dlg-actions button:not(.act) { font: inherit; font-size: .85rem; padding: 6px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.18); color: #fff; cursor: pointer; min-height: 38px; }
.toolbar button[aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); }
.toolbar button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 420px) { .toolbar button { font-size: .78rem; padding: 5px 7px; } }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 8px; }
.side { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(0,0,0,.16);
  border: 2px solid transparent; min-height: 58px; min-width: 0; }
.side.is-turn { border-color: var(--accent); }
.side > div:nth-child(2) { min-width: 0; }
.side-name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-info { font-size: .78rem; opacity: .9; line-height: 1.3; min-height: 2.6em; } /* reserve 2 lines → no layout shift when "x to place" disappears */
.stack { display: none; }
.piece-icon { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; }
.piece-icon.w, .mini.w { background: radial-gradient(circle at 35% 30%, #fff, #d6d3d1); border: 2px solid #57534e; }
.piece-icon.b, .mini.b { background: radial-gradient(circle at 35% 30%, #57534e, #111827); border: 2px solid #e7e5e4; }
@media (min-width: 700px) {
  .stack { display: flex; flex-wrap: nowrap; gap: 3px; margin-left: auto; flex: 0 0 auto; }
  .mini { width: 12px; height: 12px; border-radius: 50%; border-width: 1px !important; }
}

.board-wrap { position: relative; width: min(100%, 560px); margin: 0 auto; }
.board { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.board-bg { fill: var(--wood); stroke: var(--wood-dark); stroke-width: 6; }
.lines rect, .lines line { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; }
.coords text { font: 600 20px var(--font); fill: #6b4f2a; text-anchor: middle; }
.phase { position: absolute; top: 6px; right: 8px; font-size: .75rem; font-weight: 700; color: #4a3218; background: rgba(255,255,255,.6); border-radius: 6px; padding: 0 6px; }
.phase:empty { display: none; }

.pt { cursor: pointer; outline: none; }
.pt .hit { fill: transparent; }
.pt .dot { fill: var(--line); }
.pt .tgt { fill: #16a34a; opacity: 0; }
.pt .piece { opacity: 0; stroke-width: 4; }
.pt .ring { fill: none; stroke: transparent; stroke-width: 6; }
.pt.w .piece { opacity: 1; fill: #fafaf9; stroke: #44403c; }
.pt.b .piece { opacity: 1; fill: #1c1917; stroke: #e7e5e4; }
.pt.w .dot, .pt.b .dot { opacity: 0; }
.pt.target .tgt { opacity: .85; }
.pt.movable .ring { stroke: rgba(22,163,74,.55); stroke-width: 4; }
.pt.sel .ring { stroke: var(--accent); stroke-width: 8; }
.pt.last .ring { stroke: #2563eb; stroke-width: 5; stroke-dasharray: 10 6; }
.pt.removable .ring { stroke: #dc2626; stroke-width: 8; animation: pulse 1s ease-in-out infinite; }
.pt.dragging .piece { opacity: .35; }
.pt:focus-visible .hit { fill: rgba(253,224,71,.45); }
.mill-line { stroke: var(--accent); stroke-width: 14; stroke-linecap: round; opacity: .85; animation: millflash 1.2s ease; }
.ghost { pointer-events: none; stroke-width: 4; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); }
.ghost.w { fill: #fafaf9; stroke: #44403c; }
.ghost.b { fill: #1c1917; stroke: #e7e5e4; }
.ghost.hidden { display: none; }
@keyframes pulse { 50% { stroke: #fca5a5; } }
@keyframes millflash { 0% { stroke-width: 26; opacity: 1; } 100% { stroke-width: 14; opacity: .85; } }

.status { min-height: 4.4em; margin: 8px 0 0; text-align: center; font-size: .92rem; line-height: 1.4; background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 8px; }
.keys { font-size: .75rem; opacity: .7; text-align: center; margin: 6px 0 0; }
@media (hover: none) { .keys { display: none; } }
button:focus-visible { outline: 3px solid #fde047; outline-offset: 2px; }

/* -------------------------------------------------------------- dialogs --- */
dialog { border: 0; border-radius: 14px; padding: 18px; max-width: min(480px, 94vw); width: 100%; color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
dialog label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0; }
dialog label.check { justify-content: flex-start; }
dialog select { font: inherit; padding: 4px 8px; min-height: 38px; max-width: 60%; }
dialog input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; }
dialog fieldset { border: 1px solid #e5e7eb; border-radius: 8px; margin: 10px 0; }
.act { font: inherit; font-weight: 700; min-height: 46px; border: 0; border-radius: 10px; background: var(--felt); color: #fff; cursor: pointer; padding: 8px 16px; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.dlg-actions button:not(.act) { color: var(--ink); background: #f3f4f6; border-color: #d1d5db; }
.over-text { font-size: 1.1rem; font-weight: 600; }
.stats-table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.stats-table th, .stats-table td { border-bottom: 1px solid #e5e7eb; padding: 5px 6px; text-align: right; }
.stats-table th:first-child { text-align: left; }

/* ------------------------------------------------------------- ad slots --- */
.ad-slot { display: block; width: 100%; margin: 16px auto; background: #ebebe6; border-radius: 8px; contain: strict; }
.ad-slot--game { height: 280px; max-width: 728px; }
.ad-slot--content { height: 280px; max-width: 336px; }
@media (min-width: 768px) { .ad-slot--game { height: 90px; } }

/* -------------------------------------------------------------- content --- */
.content { background: #fff; border-radius: 14px; padding: 14px 18px; margin-top: 4px; }
.content h2 { font-size: 1.3rem; margin: 22px 0 8px; color: var(--felt-dark); }
.content h3 { font-size: 1.05rem; margin: 16px 0 4px; }
.content li { margin: 6px 0; }
.lead { font-size: 1.02rem; }
.site-footer { text-align: center; font-size: .85rem; color: var(--muted); padding: 10px 10px 30px; }

@media (min-width: 900px) {
  .game { display: grid; grid-template-columns: 1fr 300px; grid-template-areas: "tools tools" "board sides" "board status" "board keys"; column-gap: 18px; align-content: start; }
  .toolbar { grid-area: tools; }
  .board-wrap { grid-area: board; margin-top: 10px; }
  .sides { grid-area: sides; grid-template-columns: 1fr; align-self: start; }
  .status { grid-area: status; align-self: start; text-align: left; }
  .keys { grid-area: keys; text-align: left; }
}

/* ------------------------------------------------- senior / large pieces --- */
body.senior { font-size: 19px; }
body.senior .game { background: #0b3d1f; }
body.senior .pt .piece { transform-box: fill-box; transform-origin: center; transform: scale(1.22); stroke-width: 5; }
body.senior .pt.w .piece { stroke: #000; }
body.senior .pt .tgt { transform-box: fill-box; transform-origin: center; transform: scale(1.5); }
body.senior .lines rect, body.senior .lines line { stroke: #2b1a08; stroke-width: 8; }
body.senior .status { font-size: 1.05rem; background: #000; }
body.senior .toolbar button { min-height: 44px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 420px) { .side-name { font-size: .8rem; } .side { gap: 6px; padding: 6px; } }

/* ---------------------------------------------------------- language switch --- */
.site-header { display: flex; align-items: center; }
.site-header .brand-sub { flex: 1 1 auto; min-width: 0; }
.site-header .lang-switch { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.site-header .lang-switch a,
.site-header .lang-switch a:link,
.site-header .lang-switch a:visited {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  min-width: 52px; min-height: 44px; padding: 0 14px; border: 2px solid #ffffff; border-radius: 999px;
  background: transparent; color: #ffffff; font: 700 17px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: .04em; text-decoration: none;
}
.site-header .lang-switch a:hover { background: rgba(255,255,255,.18); color: #ffffff; text-decoration: none; }
.site-header .lang-switch a[aria-current="page"],
.site-header .lang-switch a[aria-current="page"]:link,
.site-header .lang-switch a[aria-current="page"]:visited,
.site-header .lang-switch a[aria-current="page"]:hover { background: #ffffff; color: #14532d; border-color: #ffffff; }
.site-header .lang-switch a:focus-visible { outline: 3px solid #fde047; outline-offset: 3px; }
@media (max-width: 400px) { .site-header .brand-sub { display: none; } }
