/* РЕЧМЕЧ — српска игра речи */
:root {
  --bg: #f4efe6;
  --board-bg: #2e5339;
  --cell: #e8e2d4;
  --cell-border: #cfc8b6;
  --tile: #f7e8c5;
  --tile-edge: #d9c188;
  --tile-text: #3a2d13;
  --tw: #d9534f;
  --dw: #f0a3a0;
  --tl: #3f6fb5;
  --dl: #a9c4e4;
  --accent: #2e5339;
  --danger: #b23a2f;
  --ink: #26211a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 10px; left: 12px; z-index: 1000;
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 13px;
  border: 1px solid rgba(76,51,18,.35); border-radius: 10px;
  background: linear-gradient(180deg, #f5d98f, #d9ae51); color: #2e2719;
  box-shadow: 0 12px 24px rgba(7,21,12,.22);
  font-size: .86rem; font-weight: 850; text-decoration: none;
  opacity: 0; pointer-events: none; transition: opacity .14s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  opacity: 1; pointer-events: auto; outline: 3px solid rgba(255,255,255,.92);
  outline-offset: 2px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column; min-height: 100vh;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.11), rgba(255,255,255,0) 42%),
    linear-gradient(90deg, #213f2d 0%, var(--accent) 48%, #416241 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 24px rgba(46,83,57,.18);
}
header h1 {
  font-size: 1.15rem; letter-spacing: .04em;
  text-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.brand-home {
  display: inline-flex; align-items: center; gap: 10px; padding: 0;
  background: transparent; border: 0; color: #fff; box-shadow: none;
  font: inherit; cursor: pointer;
}
.brand-home:hover:not(:disabled) { box-shadow: none; }
.brand-home:focus-visible { outline-color: #f0c56e; }
.brand-tile {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: 7px; background: linear-gradient(145deg, #f9e9bd, #dfc179);
  border: 1px solid rgba(76,51,18,.35); color: #3a2d13; font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 3px 8px rgba(20,35,24,.28);
  transform: rotate(-2deg);
}
.brand-name {
  font-size: 1.18rem; font-weight: 900; letter-spacing: .035em;
  text-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.header-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  background: rgba(255,255,255,.16); color: #fff; font-size: .72rem; font-weight: 800;
  padding: 4px 9px; border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; cursor: help;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 2px 8px rgba(20,35,24,.12);
}
.badge.beta {
  background: linear-gradient(180deg, #f4c979, #e3a94b);
  color: #3a2d13; border-color: rgba(255,235,190,.72);
}
.badge.strict {
  background: linear-gradient(180deg, #f7fff7, #dcebdd);
  color: #21462f; border-color: rgba(255,255,255,.68);
}

main {
  flex: 1; display: grid; gap: 14px; padding: 14px;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-areas: "board side" "rack side";
  max-width: 1160px; margin: 0 auto; width: 100%;
}
.start-screen {
  flex: 1; width: 100%; display: block; padding: 0;
  background:
    radial-gradient(circle at 78% 5%, rgba(217,193,136,.28), transparent 28%),
    linear-gradient(180deg, #f8f3e9 0%, #f1e8d8 100%);
}
.hub-shell { width: min(1180px, 100%); margin: 0 auto; padding: 46px 24px 34px; }
.hub-hero {
  min-height: 350px; display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(360px, .94fr);
  gap: 44px; align-items: center; padding: 42px clamp(30px, 5vw, 68px);
  overflow: hidden; position: relative; border-radius: 28px;
  background:
    linear-gradient(125deg, rgba(255,255,255,.08), transparent 42%),
    linear-gradient(135deg, #173824 0%, #29563b 60%, #3d6848 100%);
  color: #fff; box-shadow: 0 20px 52px rgba(35,59,40,.2);
}
.hub-hero::after {
  content: ""; position: absolute; width: 360px; height: 360px; right: -140px; top: -180px;
  border-radius: 50%; border: 70px solid rgba(244,218,163,.08); pointer-events: none;
}
.hero-copy, .hero-word { position: relative; z-index: 1; }
.hero-kicker, .section-kicker, .setup-kicker {
  display: block; color: #dcb967; font-size: .73rem; font-weight: 900;
  letter-spacing: .14em; text-transform: uppercase;
}
.hero-copy h1 {
  margin-top: 13px; max-width: 620px; font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 5vw, 4.7rem); line-height: .98; letter-spacing: -.045em;
}
.hero-copy h1 em { color: #f0cc7a; font-style: normal; }
.hero-copy > p {
  max-width: 590px; margin-top: 20px; color: rgba(255,255,255,.8);
  font-size: clamp(1rem, 1.6vw, 1.14rem); line-height: 1.55;
}
.hero-facts { display: flex; gap: 22px; margin-top: 27px; flex-wrap: wrap; }
.hero-facts span {
  display: inline-flex; align-items: baseline; gap: 6px; color: rgba(255,255,255,.72);
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.hero-facts b { color: #fff; font-size: 1rem; }
.hero-word { display: grid; gap: 20px; justify-items: center; transform: rotate(1.5deg); }
.hero-rack {
  display: grid; grid-template-columns: repeat(4, 66px); gap: 10px;
  padding: 22px 24px 28px; border-radius: 15px;
  background: linear-gradient(180deg, #916a32, #65441f);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.14), 0 18px 30px rgba(8,24,13,.32);
}
.hero-rack span {
  position: relative; width: 66px; height: 66px; display: grid; place-items: center;
  border-radius: 9px; color: #3d2c13; font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem; font-weight: 900; background: linear-gradient(145deg, #fff1c9, #dfbd72);
  border: 1px solid #b58f4e; box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 4px 0 #ac813e, 0 7px 10px rgba(28,19,7,.2);
}
.hero-rack span::after {
  content: attr(data-points); position: absolute; right: 7px; bottom: 4px;
  font-family: inherit; font-size: .65rem; font-weight: 800;
}
.hero-rack span:nth-child(2), .hero-rack span:nth-child(7) { transform: rotate(-2deg); }
.hero-rack span:nth-child(4), .hero-rack span:nth-child(5) { transform: rotate(1.5deg); }
.hero-word p { color: rgba(255,255,255,.66); text-align: center; font-size: .82rem; line-height: 1.45; letter-spacing: .08em; text-transform: uppercase; }
.hub-continue {
  margin-top: 22px; padding: 18px 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 22px; border-radius: 16px;
  background: #fffaf0; border: 1px solid #d9c08b; box-shadow: 0 7px 20px rgba(58,45,19,.08);
}
.hub-continue > div { display: grid; gap: 3px; }
.hub-continue strong { font-size: 1.08rem; }
.hub-continue small { color: #756b5d; }
.mode-section { padding: 50px 0 40px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.section-heading h2, .clarity-story h2 { margin-top: 7px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 2.35rem); color: #1f3426; }
.section-heading > p { max-width: 340px; color: #776d5e; line-height: 1.45; text-align: right; }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mode-card {
  --mode-accent: #40664b; min-height: 260px; display: flex; flex-direction: column;
  align-items: stretch; justify-content: space-between; gap: 20px; padding: 22px;
  text-align: left; color: var(--ink); background: rgba(255,255,255,.78);
  border: 1px solid #d8cebc; border-radius: 19px; box-shadow: 0 8px 22px rgba(62,48,26,.07);
}
.mode-card.featured { --mode-accent: #d5aa50; color: #fff; background: linear-gradient(145deg, #21462f, #356143); border-color: #456f52; box-shadow: 0 13px 30px rgba(35,70,47,.19); }
.mode-card:hover:not(:disabled) { transform: translateY(-3px); border-color: #ad9564; box-shadow: 0 15px 30px rgba(62,48,26,.13); }
.mode-card.featured:hover:not(:disabled) { border-color: #e0c377; box-shadow: 0 17px 34px rgba(35,70,47,.25); }
.mode-card-top, .mode-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mode-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; background: #f0d28b; color: #3d2c13; font-weight: 900; box-shadow: inset 0 1px 0 rgba(255,255,255,.55); }
.online-mark { background: #dfe9df; color: #294d35; font-size: 1.25rem; }
.local-mark { background: #eadfc9; color: #5f4925; font-size: 1.15rem; }
.mode-tag { padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.12); color: #f2d78f; font-size: .67rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.mode-tag.subtle { background: #eee6d7; color: #6f6047; }
.mode-copy { display: grid; gap: 8px; }
.mode-copy b { font-family: Georgia, "Times New Roman", serif; font-size: 1.38rem; line-height: 1.12; }
.mode-copy small { min-height: 58px; color: #746b5d; font-size: .88rem; line-height: 1.45; }
.featured .mode-copy small { color: rgba(255,255,255,.72); }
.mode-cta { padding-top: 16px; border-top: 1px solid rgba(85,67,37,.14); color: #31553c; font-size: .84rem; font-weight: 900; }
.featured .mode-cta { border-top-color: rgba(255,255,255,.13); color: #f0d28b; }
.mode-cta i { font-style: normal; font-size: 1.2rem; transition: transform .12s ease; }
.mode-card:hover .mode-cta i { transform: translateX(3px); }
.hub-lower { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; padding-bottom: 12px; }
.clarity-story { padding: 30px; border-radius: 20px; background: #e8dfc9; border: 1px solid #d2c4a5; }
.clarity-story p { max-width: 680px; margin-top: 12px; color: #685e4d; line-height: 1.55; }
.hub-secondary { display: grid; gap: 10px; }
.hub-secondary button { display: grid; gap: 3px; align-content: center; text-align: left; padding: 16px 18px; background: rgba(255,255,255,.72); border-color: #d8cebc; }
.hub-secondary span { font-weight: 900; color: #263b2c; }
.hub-secondary small { color: #756b5d; font-weight: 500; line-height: 1.35; }
#board-wrap { grid-area: board; }
#side { grid-area: side; display: flex; flex-direction: column; gap: 10px; }
#rack-area { grid-area: rack; }

/* табла */
#board {
  display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr);
  gap: 2px; background: var(--board-bg); padding: 6px; border-radius: 10px;
  width: 100%; max-width: min(78vh, 700px); aspect-ratio: 1; margin: 0 auto;
  touch-action: manipulation;
  box-shadow: 0 10px 22px rgba(46,83,57,.18), inset 0 0 0 1px rgba(255,255,255,.08);
}
.cell {
  background: var(--cell); border-radius: 3px; position: relative;
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; overflow: hidden; aspect-ratio: 1;
  font-size: clamp(.4rem, 1.1vw, .62rem);
  color: #857e6c; font-weight: 700; cursor: pointer; user-select: none;
}
.cell-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; transition: opacity .12s ease;
}
.cell.occupied .cell-label { opacity: 0; }
.cell.tw { background: var(--tw); color: #fff; }
.cell.dw { background: var(--dw); color: #6d2f2d; }
.cell.tl { background: var(--tl); color: #fff; }
.cell.dl { background: var(--dl); color: #2c4a71; }
.cell.star { background: var(--dw); color: #6d2f2d; font-size: 1rem; }
.cell.droptarget { outline: 2px dashed #fff; outline-offset: -2px; }
.cell:focus-visible {
  outline: 3px solid #e8a33d; outline-offset: -3px; z-index: 2;
  box-shadow: inset 0 0 0 1px #fff;
}

/* плочице */
.tile {
  width: 92%; height: 92%; background: var(--tile);
  border: 1px solid var(--tile-edge); border-bottom-width: 3px;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--tile-text);
  font-size: clamp(.65rem, 2.2vw, 1.05rem); position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.tile .pts {
  position: absolute; right: 2px; bottom: 0; font-size: .5em; font-weight: 700;
}
.tile.blank { color: #8a6d3b; background: #fdf6df; }
.tile.temp {
  outline: 2px solid #e8a33d; outline-offset: 1px; cursor: pointer;
}
.tile.lastmove { background: #ffe9a8; }

/* сталак */
#rack-area { display: flex; flex-direction: column; gap: 8px; align-items: center; }
#rack {
  display: flex; gap: 6px; background: #7a5c33; padding: 8px 10px;
  border-radius: 10px; min-height: 58px;
  box-shadow: inset 0 2px 4px rgba(58,45,19,.28);
}
#rack .tile, #rack .rack-slot {
  width: 44px; height: 48px; font-size: 1.25rem; cursor: grab;
  flex: 0 0 44px;
}
#rack .rack-slot {
  border-radius: 4px; border: 1px dashed rgba(255,244,220,.38);
  background: rgba(58,45,19,.16); cursor: default;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.2);
}
#rack .tile.selected { transform: translateY(-6px); outline: 3px solid #e8a33d; }
#rack .tile.exchange-pick { opacity: .45; outline: 3px solid var(--danger); }
#rack [role="option"]:focus-visible {
  outline: 3px solid #fff; outline-offset: 2px;
  box-shadow: 0 0 0 5px #e8a33d;
}
.preview-slot {
  width: 100%; height: 42px; min-height: 42px; flex: 0 0 42px;
  display: grid; place-items: center; overflow: hidden;
}
.preview {
  --preview-tone: #6d675a;
  --preview-bg: #fff;
  --preview-border: var(--cell-border);
  width: fit-content;
  max-width: min(100%, 680px);
  background: var(--preview-bg); border: 1px solid var(--preview-border);
  border-left: 3px solid var(--preview-tone); border-radius: 999px;
  padding: 7px 14px 7px 9px; min-height: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 6px 16px rgba(58,45,19,.06);
}
.preview-icon {
  width: 22px; height: 22px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 22px; background: var(--preview-tone); color: #fff;
  font-size: .78rem; font-weight: 900; line-height: 1;
}
.preview-copy {
  min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden;
  color: #5f574c; font-size: .9rem; line-height: 1.15;
}
.preview-copy strong {
  color: var(--preview-tone); font-size: .72rem; line-height: 1;
  text-transform: uppercase; letter-spacing: .08em;
  white-space: nowrap;
}
.preview-copy span {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview.ok {
  --preview-tone: var(--accent); --preview-border: #b9d0bf;
  --preview-bg: #f5faf5;
}
.preview.err {
  --preview-tone: var(--danger); --preview-border: #e3b1ab;
  --preview-bg: #fff8f6;
}
.preview.wait {
  --preview-tone: #8a6d3b; --preview-border: #e1c983;
  --preview-bg: #fffaf0;
}
button.report-word {
  padding: 3px 10px; border-radius: 999px; font-size: .78rem;
  border: 1px solid #b9b19d; background: #fff; color: #5f574c;
  white-space: nowrap;
}
button.report-word:disabled { opacity: .55; }
.preview button.report-word { flex: 0 0 auto; }
.report-flags {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}

#controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#exchange-bar { display: flex; gap: 10px; align-items: center; background: #fff3cd;
  border: 1px solid #e2c26a; padding: 8px 12px; border-radius: 8px; }

button {
  font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid #b9b19d;
  background: #fff; cursor: pointer; font-weight: 600;
}
button:hover:not(:disabled) { filter: brightness(.96); }
button:disabled { opacity: .45; cursor: default; }
button.is-busy {
  position: relative;
  opacity: .78;
}
button.is-busy::after {
  content: "";
  width: .75em;
  height: .75em;
  margin-left: .5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin .75s linear infinite;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost {
  background: rgba(255,255,255,.08); color: #fff;
  border-color: rgba(255,255,255,.36);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14);
}
button.ghost:hover:not(:disabled) {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.58);
  box-shadow: 0 4px 12px rgba(20,35,24,.18), inset 0 1px 0 rgba(255,255,255,.18);
}
button.ghost.danger {
  color: #ffe6e2;
  border-color: rgba(255,205,198,.42);
  background: rgba(178,58,47,.18);
}
button.ghost.danger:hover:not(:disabled) {
  background: rgba(178,58,47,.28);
  border-color: rgba(255,205,198,.68);
}
button.big { font-size: 1.05rem; padding: 12px 22px; }
button.link-button {
  align-self: flex-start;
  padding: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--accent); font-size: .86rem; font-weight: 800;
  text-decoration: underline; text-underline-offset: 3px;
}
button.link-button:hover:not(:disabled) {
  box-shadow: none; color: #1f3f2b; background: transparent;
}
#btn-fullscreen { display: none; }
body.fullscreen-capable #btn-fullscreen { display: inline-flex; }
body.is-fullscreen {
  min-height: 100vh;
  overflow: auto;
}
body.is-fullscreen header {
  padding-block: 8px;
}
body.is-fullscreen main {
  max-width: none;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 330px);
  padding: 10px 14px 14px;
}
body.is-fullscreen #board {
  max-width: min(82vh, 820px);
}
.icon-toggle {
  background: rgba(255,255,255,.13); color: #fff; border-color: rgba(255,255,255,.44);
  padding: 6px 10px; border-radius: 999px; font-size: .78rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16);
}
.icon-toggle[aria-pressed="false"] {
  color: rgba(255,255,255,.68); border-color: rgba(255,255,255,.24);
  background: rgba(24,37,27,.22);
}
.icon-toggle::before { content: "♪ "; font-weight: 800; }
.icon-toggle[aria-pressed="false"]::before { content: "× "; }

.ai-difficulty-choice label:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46,83,57,.1);
}

/* бочни панел */
.panel { background: #fff; border: 1px solid var(--cell-border);
  border-radius: 10px; padding: 12px 14px; font-size: .9rem;
  box-shadow: 0 2px 8px rgba(58,45,19,.05); }
.panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: #857e6c; margin-bottom: 6px; }
.panel.history-panel { padding-right: 8px; }
.best-word { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.best-word strong { font-size: 1.35rem; }
.best-word span { color: var(--accent); font-weight: 800; white-space: nowrap; }
#players { display: flex; flex-direction: column; gap: 8px; }
.player { background: #fff; border: 1px solid var(--cell-border);
  border-radius: 10px; padding: 10px 12px; display: flex;
  justify-content: space-between; align-items: center; }
.player.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.player .score { font-size: 1.5rem; font-weight: 800; }
.player .turnmark { font-size: .7rem; color: var(--accent); font-weight: 700; }
.player-main { min-width: 0; }
.player-score-block { display: flex; align-items: center; gap: 13px; }
.player-clock {
  min-width: 5.4ch; text-align: right; color: #5f584c;
  font: 850 .92rem/1.15 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.player-clock small {
  display: block; margin-top: 3px; color: #8a7350;
  font-size: .63rem; font-weight: 800; line-height: 1.1;
}
.player-clock.is-warning { color: #a15c10; }
.player-clock.is-danger { color: #b02c23; }
.player-clock.is-active { transform: translateY(-1px); }
.player.current .player-clock,
.player.current .player-clock small { color: #fff1c9; }
.player.current .player-clock.is-danger { color: #ffd1cb; }
.game-preset { font-size: 1rem; color: var(--ink); font-weight: 800; }
.game-mode { margin-top: 2px; color: #6d675a; font-size: .84rem; }
.bag-count {
  display: flex; align-items: center; gap: 12px; margin: 2px 0 4px;
  color: var(--accent); font-weight: 800;
}
.bag-icon {
  width: 40px; height: 28px; position: relative; z-index: 0;
  display: inline-block; flex: 0 0 40px; opacity: .78;
}
.bag-icon::before,
.bag-icon::after,
.bag-icon span {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 4px;
  background: #f7e8c5; border: 1px solid #d9c188;
  box-shadow: 0 1px 1px rgba(58,45,19,.14);
}
.bag-icon span { left: 10px; top: 1px; z-index: 2; }
.bag-icon::before {
  left: 3px; top: 7px; transform: rotate(-7deg); z-index: 1;
}
.bag-icon::after {
  right: 3px; top: 7px; transform: rotate(7deg); z-index: 1;
}
.bag-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.bag-number { font-size: 1.35rem; line-height: 1; color: var(--ink); min-width: 2ch; }
.bag-label { color: #6d675a; font-size: .86rem; font-weight: 700; line-height: 1.1; }
#history {
  list-style: none; max-height: min(36vh, 310px); overflow-y: auto;
  padding-right: 8px; margin-right: 2px; scrollbar-gutter: stable;
}
#history li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px;
  align-items: start; padding: 7px 8px; border-bottom: 1px dashed #eee;
  font-size: .86rem; line-height: 1.28;
  border-radius: 7px;
}
#history li .move-text { min-width: 0; overflow-wrap: anywhere; }
#history li .pts {
  justify-self: end; font-weight: 800; color: var(--ink);
  background: transparent; border-radius: 0; padding: 0;
}
#history li.player-1 {
  background: #fbf2df;
}

#legend { display: flex; gap: 14px; justify-content: center; margin-top: 8px;
  font-size: .75rem; color: #6d675a; }
#legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  margin-right: 4px; vertical-align: -1px; }
.sw.tw { background: var(--tw); } .sw.dw { background: var(--dw); }
.sw.tl { background: var(--tl); } .sw.dl { background: var(--dl); }
.sw.star { background: var(--dw); }

/* overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(30,26,18,.72);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.overlay[hidden] { display: none; }
.card {
  background: #fff; border-radius: 14px; padding: 26px 30px; width: min(92vw, 430px);
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.new-game-card {
  width: min(94vw, 560px);
  max-height: min(92vh, 860px);
  overflow: auto;
  border: 1px solid rgba(255,255,255,.7);
}
.new-game-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px;
}
.new-game-head h2 { min-width: 0; line-height: 1.16; }
.new-game-head > div { display: grid; gap: 4px; }
.setup-kicker { color: #8d6a2e; }
.setup-subtitle { color: #736a5c; font-size: .86rem; line-height: 1.35; }
.dialog-close {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 999px;
  background: rgba(109,103,90,.1); color: #6d675a;
  font-size: 1.35rem; line-height: 1; flex: 0 0 34px;
}
.dialog-close:hover:not(:disabled) {
  filter: none; background: rgba(109,103,90,.16);
}
.card.center { text-align: center; align-items: center; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.card input[type="text"], .card input[type="password"], .card input:not([type]) {
  font: inherit; padding: 8px 10px; border: 1px solid #c6bfae; border-radius: 8px;
}
.card fieldset { border: 1px solid #ddd6c4; border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; }
.card fieldset label { flex-direction: row; gap: 8px; align-items: center; }
.card fieldset.ai-difficulty-choice { gap: 8px; }
.ai-difficulty-choice label {
  border: 1px solid #e2dac7; border-radius: 8px; padding: 9px 10px;
  background: #fffaf0;
}
.ai-difficulty-choice input { margin-top: 2px; }
.ai-difficulty-choice span { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.ai-difficulty-choice small { color: #6d675a; font-size: .78rem; }
.ai-difficulty-choice .bot-avatar,
.setup-form .ai-difficulty-choice label span.bot-avatar {
  display: block; flex: 0 0 auto; align-self: flex-start;
  font-size: 1.3rem; line-height: 1.1;
}
.new-game-actions { display: grid; gap: 8px; }
.new-game-actions button { width: 100%; }
.new-game-actions .secondary {
  background: rgba(255,255,255,.72);
  border-color: #e2dac7;
  color: #6d675a;
}
.card .hint { font-size: .78rem; color: #857e6c; }
.share-panel {
  display: flex; flex-direction: column; gap: 8px;
  background: #f8f3e7; border: 1px solid #d9cbb0; border-radius: 8px;
  padding: 10px; font-size: .86rem;
}
.share-panel a { color: var(--accent); overflow-wrap: anywhere; font-weight: 700; }
.share-panel .share-row { display: flex; flex-direction: column; gap: 2px; }
.admin-games-panel {
  max-height: 300px;
  overflow: auto;
}
.admin-games-panel p {
  margin: 0;
  color: #5f574c;
}
.admin-game {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid #d9cbb0;
}
.admin-game-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.admin-game-head span {
  color: #6d675a;
  font-size: .78rem;
  white-space: nowrap;
}
.admin-link-row {
  display: grid;
  grid-template-columns: minmax(70px, .7fr) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
.admin-link-row a {
  grid-column: 1 / -1;
  font-size: .78rem;
}
.admin-link-row code {
  min-width: 0;
  overflow-wrap: anywhere;
  background: rgba(46,83,57,.08);
  border: 1px solid rgba(46,83,57,.14);
  border-radius: 6px;
  padding: 4px 6px;
  color: #2e5339;
  font-size: .75rem;
}

.profile-card {
  width: min(760px, calc(100vw - 28px));
  max-height: min(84vh, 720px);
  overflow: auto;
  padding: 26px;
}
.profile-summary {
  display: grid; grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
  align-items: end; gap: 14px;
  margin: 6px 0 18px;
}
.profile-summary label { margin: 0; }
.profile-summary input { height: 40px; font-size: .95rem; }
.profile-summary span {
  color: #857e6c; font-size: .78rem; white-space: nowrap;
  justify-self: end; padding-bottom: 10px;
}
.profile-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: #f4efe6; border: 1px solid var(--cell-border);
  border-radius: 10px; padding: 4px; margin: 8px 0 18px;
}
.profile-tabs button {
  border: 0; background: transparent; color: #6d675a;
  min-height: 42px; padding: 8px 10px; border-radius: 8px;
  box-shadow: none;
}
.profile-tabs button.active {
  background: #fff; color: var(--accent);
  box-shadow: 0 1px 4px rgba(58,45,19,.12);
}
.profile-tabs button:focus-visible {
  outline: 2px solid rgba(232,163,61,.75);
  outline-offset: -4px;
}
.profile-content { display: grid; gap: 10px; }
.profile-empty, .profile-loading {
  background: #fffaf0; border: 1px dashed #dacaa7; border-radius: 9px;
  padding: 14px 16px; color: #6d675a;
}
.profile-empty p { margin-top: 4px; }
.profile-game {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  background: #fff; border: 1px solid var(--cell-border); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 2px 8px rgba(58,45,19,.05);
}
.profile-game.ready { border-color: #98b99b; background: #f7fbf5; }
.profile-game.waiting { background: #fbfaf7; }
.profile-game h3 { margin: 5px 0 4px; font-size: 1rem; }
.profile-game p, .profile-game small { color: #6d675a; }
.profile-pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 8px; font-size: .72rem; font-weight: 800;
  background: #edf4ed; color: var(--accent);
}
.profile-game.waiting .profile-pill { background: #f0ebe0; color: #6d675a; }
.profile-continue {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 92px; min-height: 42px; padding: 8px 12px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 800;
  box-shadow: 0 3px 9px rgba(46,83,57,.2);
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.profile-continue:hover { background: #234b30; box-shadow: 0 5px 13px rgba(46,83,57,.28); }
.profile-continue:active { transform: translateY(1px); box-shadow: none; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.profile-badge {
  font-size: .78rem; font-weight: 800; color: #6d4b08;
  background: #fff4d6; border-radius: 999px; padding: 3px 8px;
}
.records-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.record-card {
  background: #fff; border: 1px solid var(--cell-border);
  border-radius: 10px; padding: 14px;
}
.record-card h3 {
  font-size: .82rem; text-transform: uppercase; color: #857e6c;
  letter-spacing: .05em; margin-bottom: 8px;
}
.record-card ol { list-style: none; display: grid; gap: 6px; }
.record-card li {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px;
  align-items: center; color: #6d675a;
}
.record-card li.record-empty {
  grid-template-columns: 28px minmax(0, 1fr);
}
.record-card li > span:first-child {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; background: #f4efe6;
  color: var(--accent); font-weight: 900; font-size: .75rem;
}
.record-card strong { color: var(--ink); overflow-wrap: anywhere; }
.record-card b { color: var(--accent); }
.rules-card {
  width: min(92vw, 680px);
  max-height: min(86vh, 720px);
  overflow: auto;
  gap: 16px;
  background: #fffbf6;
  border: 1px solid #eadfcb;
}
.rules-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.rules-kicker {
  display: block; margin-bottom: 3px;
  color: var(--accent); font-size: .72rem; font-weight: 900;
  letter-spacing: .08em; line-height: 1; text-transform: uppercase;
}
.rules-card h2 { font-size: 1.45rem; line-height: 1.1; letter-spacing: 0; }
.rules-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.rules-grid section {
  padding: 12px 13px; border: 1px solid #eadfcb;
  border-radius: 10px; background: rgba(255,255,255,.72);
}
.rules-grid h3 {
  margin-bottom: 5px; color: var(--accent);
  font-size: .82rem; line-height: 1.15; text-transform: uppercase;
  letter-spacing: .06em;
}
.rules-grid p, .rules-note {
  color: #5f574c; font-size: .9rem; line-height: 1.38;
}
.rules-note {
  padding: 11px 13px; border-radius: 10px;
  background: #f4efe6; border: 1px solid #e4d8c4;
}
.blank-card {
  width: min(92vw, 430px);
  padding: 22px 24px 24px;
  background: #fffaf0;
  border: 1px solid #d9cbb0;
}
.blank-card h2 {
  font-size: 1.25rem; line-height: 1.2; letter-spacing: 0;
}
#blank-grid {
  display: grid; grid-template-columns: repeat(6, 48px); gap: 9px;
  justify-content: center; padding: 8px 0 2px;
}
#blank-grid .blank-choice {
  width: 48px; height: 52px; padding: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--tile); border: 1px solid var(--tile-edge);
  border-bottom-width: 3px; border-radius: 6px;
  color: var(--tile-text); font-size: 1.45rem; font-weight: 800;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
#blank-grid .blank-choice:hover {
  filter: none; transform: translateY(-2px);
  box-shadow: 0 3px 7px rgba(58,45,19,.24);
}
#blank-grid .blank-choice:active {
  transform: translateY(1px); border-bottom-width: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
#blank-grid .blank-choice:focus-visible {
  outline: 3px solid #e8a33d; outline-offset: 2px;
}
#blank-grid .blank-choice .pts {
  position: absolute; right: 4px; bottom: 1px; font-size: .45em; font-weight: 700;
}
.blank-cancel {
  min-height: 44px; margin-top: 10px; padding: 9px 18px;
  border-color: #cfc1aa; background: transparent; color: #655b4d;
}
.blank-cancel:hover:not(:disabled) { background: #f4ecde; }
#end-details table { margin: 0 auto; border-collapse: collapse; }
#end-details td { padding: 4px 14px; font-size: 1.05rem; }
#end-details td.sc { font-weight: 800; text-align: right; }
.end-card {
  width: min(92vw, 520px); padding: 30px;
  background: #fffaf2; border: 1px solid #d9cbb0;
}
.end-card h2 { font-size: 1.65rem; }
.end-winner {
  width: 100%; padding: 14px 16px; border-radius: 10px;
  background: #edf4ed; border: 1px solid #c7d9c7;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.end-winner span {
  color: #6d675a; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 800;
}
.end-winner strong { font-size: 1.65rem; color: var(--accent); }
.end-standings {
  width: 100%; display: flex; flex-direction: column; gap: 7px;
}
.end-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center;
  gap: 10px; padding: 10px 12px; border-radius: 8px; background: #fff;
  border: 1px solid #eadfcb;
}
.end-row.winner { border-color: #b9d0b9; background: #f3f8f1; }
.end-row .rank {
  width: 26px; height: 26px; border-radius: 999px; background: #f0e4cd;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
  color: #7a5524;
}
.end-row .name { min-width: 0; overflow-wrap: anywhere; font-weight: 700; text-align: left; }
.end-row .score { font-size: 1.18rem; font-weight: 900; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #3a2d13; color: #fff; padding: 10px 18px; border-radius: 10px;
  z-index: 30; max-width: 80vw; box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
#toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .hub-shell { padding: 18px 14px 26px; }
  .hub-hero {
    min-height: 0; grid-template-columns: 1fr; gap: 30px;
    padding: 34px clamp(22px, 7vw, 42px); border-radius: 20px;
  }
  .hero-copy h1 { font-size: clamp(2.45rem, 11vw, 4rem); }
  .hero-copy > p { font-size: .98rem; }
  .hero-word { transform: none; }
  .hero-rack { grid-template-columns: repeat(8, minmax(0, 1fr)); width: min(100%, 570px); gap: clamp(4px, 1.3vw, 8px); padding: 14px 15px 18px; }
  .hero-rack span { width: 100%; height: auto; aspect-ratio: 1; font-size: clamp(1.12rem, 6vw, 1.75rem); }
  .mode-section { padding: 36px 0 30px; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 215px; }
  .mode-copy small { min-height: 0; }
  .hub-lower { grid-template-columns: 1fr; }
  .hub-continue { align-items: stretch; flex-direction: column; }
  .hub-continue button { width: 100%; }
  main { grid-template-columns: 1fr; grid-template-areas: "board" "rack" "side"; }
  #board { max-width: min(94vw, 70vh); }
}

@media (max-width: 520px) {
  .brand-name { font-size: 1.02rem; }
  .brand-tile { width: 30px; height: 30px; }
  .hub-shell { padding-inline: 10px; }
  .hub-hero { padding: 28px 20px; }
  .hero-facts { gap: 12px 16px; }
  .hero-rack span::after { right: 4px; bottom: 2px; font-size: .5rem; }
.section-heading h2, .clarity-story h2 { font-size: 1.6rem; }
.clarity-story { padding: 23px 20px; }
  .new-game-card { padding: 22px 18px; }
}

/* mobile polish + action controls prototype */
button {
  font-weight: 700;
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
button:hover:not(:disabled) { filter: none; box-shadow: 0 2px 8px rgba(58,45,19,.12); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button:focus-visible { outline: 3px solid #e8a33d; outline-offset: 2px; }
button.primary {
  background: linear-gradient(180deg, #3e684a, var(--accent));
  border-color: var(--accent); color: #fff;
  box-shadow: 0 3px 9px rgba(46,83,57,.24);
}
button.danger { color: var(--danger); border-color: #d7a19b; background: #fff8f7; }
button.warn-action { background: #fff4d6; border-color: #d7a847; color: #6d4b08; }

#controls { gap: 9px; }
.action-group {
  --action-bg: #fffdf8;
  --action-fg: var(--ink);
  --action-border: #c8bda8;
  --action-divider: rgba(78,66,45,.16);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 0;
  min-width: 134px;
  overflow: hidden;
  border: 1px solid var(--action-border);
  border-radius: 10px;
  background: var(--action-bg);
  color: var(--action-fg);
  box-shadow: 0 2px 8px rgba(58,45,19,.08);
  transition: transform .08s ease, box-shadow .12s ease;
}
.action-group:hover { box-shadow: 0 4px 12px rgba(58,45,19,.14); }
.action-group:has(.action-main:active:not(:disabled)) {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(58,45,19,.1);
}
.action-group:focus-within { outline: 3px solid #e8a33d; outline-offset: 2px; }
.action-primary {
  --action-bg: linear-gradient(180deg, #477552, var(--accent));
  --action-fg: #fff;
  --action-border: #244831;
  --action-divider: rgba(255,255,255,.22);
}
.action-warn {
  --action-bg: #fff4d6;
  --action-fg: #6d4b08;
  --action-border: #d7a847;
  --action-divider: rgba(109,75,8,.16);
}
.action-danger {
  --action-bg: #fff8f7;
  --action-fg: var(--danger);
  --action-border: #d7a19b;
  --action-divider: rgba(178,58,47,.16);
}
.action-main {
  min-width: 0;
  min-height: 40px;
  padding-inline: 12px 10px;
  white-space: nowrap;
}
.action-group .action-main,
.action-group .info-btn,
.action-group .action-main.primary,
.action-group .action-main.danger {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--action-fg);
  box-shadow: none;
}
.action-group .action-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.action-group button:hover:not(:disabled) { filter: none; box-shadow: none; background: transparent; }
.action-group button:active:not(:disabled) { transform: none; }
.action-group button:focus-visible { outline: 0; }
.action-group .action-main:disabled { opacity: .42; }
.btn-icon {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  opacity: .95;
}
.btn-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.action-primary .btn-icon svg { stroke-width: 2.65; }

@keyframes button-spin {
  to { transform: rotate(360deg); }
}
.info-btn {
  width: 34px; height: 100%; min-height: 40px; padding: 0;
  border-left: 1px solid var(--action-divider);
  font-size: 0;
  color: inherit;
}
.info-btn::before {
  content: "?";
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,.38);
  box-shadow: inset 0 0 0 1px rgba(78,66,45,.12);
  font-size: .82rem; font-weight: 900;
}
.action-tooltip {
  --tone: var(--accent);
  position: fixed;
  z-index: 45;
  width: min(330px, calc(100vw - 20px));
  padding: 12px 13px;
  border: 1px solid #eadfcb;
  border-radius: 12px;
  background: #fffbf6;
  color: var(--ink);
  box-shadow: 0 14px 36px rgba(22,18,12,.24);
  pointer-events: none;
}
.action-tooltip[hidden] { display: none; }
.action-tooltip.tone-neutral { --tone: #6d675a; }
.action-tooltip.tone-success { --tone: var(--accent); }
.action-tooltip.tone-warn { --tone: #9a680d; }
.action-tooltip.tone-danger { --tone: var(--danger); }
.tip-head {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  margin-bottom: 7px;
}
.tip-icon {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--tone);
  color: #fff;
  font-weight: 900;
}
.tip-icon svg {
  width: 18px; height: 18px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2.35;
  stroke-linecap: round; stroke-linejoin: round;
}
.tip-kicker {
  display: block;
  color: var(--tone);
  font-size: .66rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.tip-head strong {
  display: block;
  font-size: .94rem;
  line-height: 1.15;
}
.action-tooltip p {
  color: #4b4336;
  font-size: .84rem;
  line-height: 1.35;
}
.action-tooltip ul {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding-left: 1rem;
  color: #5d5445;
  font-size: .8rem;
  line-height: 1.25;
}

#rack .tile { cursor: grab; touch-action: none; }
#rack.reorder-active .tile { cursor: grabbing; }
#rack .tile.rack-dragging-source { opacity: .28; transform: none; }
#rack .tile.rack-drop-target { outline: 3px solid #e8a33d; outline-offset: 2px; }
.rack-drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  transform: translate3d(-100px, -100px, 0) translate(-50%, -50%) scale(1.04);
  will-change: transform;
  opacity: .96;
  box-shadow: 0 12px 28px rgba(58,45,19,.28);
}
body.is-dragging-tile { cursor: grabbing; user-select: none; }
body.is-dragging-tile .app-header { backdrop-filter: none; }
body.is-dragging-tile .cell-label { transition: none; }

#history li .move-text {
  min-width: 0; overflow-wrap: anywhere;
}

.overlay { background: rgba(30,26,18,.48); backdrop-filter: blur(4px); padding: 18px; }
.action-card {
  --tone: var(--accent);
  --tone-soft: #edf4ed;
  --tone-faint: rgba(46,83,57,.08);
  width: min(92vw, 480px);
  align-items: stretch;
  text-align: left;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(234,223,203,.96);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--tone-soft), rgba(255,250,242,0) 104px), #fffbf6;
  box-shadow: 0 22px 60px rgba(22,18,12,.32);
}
.action-card.tone-neutral { --tone: #6d675a; --tone-soft: #f4efe6; --tone-faint: rgba(109,103,90,.09); }
.action-card.tone-success { --tone: var(--accent); --tone-soft: #edf4ed; --tone-faint: rgba(46,83,57,.09); }
.action-card.tone-warn { --tone: #9a680d; --tone-soft: #fff0bf; --tone-faint: rgba(154,104,13,.1); }
.action-card.tone-danger { --tone: var(--danger); --tone-soft: #ffe8e5; --tone-faint: rgba(178,58,47,.1); }
.action-head {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 34px;
  gap: 12px; align-items: start;
}
.action-icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone); color: #fff; font-size: 1.28rem; font-weight: 900;
  box-shadow: 0 8px 18px rgba(58,45,19,.16);
}
.action-icon svg {
  width: 26px; height: 26px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2.35;
  stroke-linecap: round; stroke-linejoin: round;
}
.action-close {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 999px;
  background: rgba(255,255,255,.55); color: #6d675a;
  font-size: 1.25rem; line-height: 1;
}
.action-close:hover:not(:disabled) {
  background: rgba(255,255,255,.55); color: #6d675a;
  box-shadow: 0 2px 8px rgba(58,45,19,.1); filter: none;
}
.action-title-wrap { min-width: 0; padding-top: 1px; }
.action-kicker {
  display: block; margin-bottom: 3px; color: var(--tone);
  font-size: .72rem; font-weight: 900; line-height: 1.1;
  letter-spacing: .07em; text-transform: uppercase;
}
.action-card h2 { text-align: left; font-size: 1.28rem; line-height: 1.14; letter-spacing: 0; }
.action-card p { color: #4b4336; line-height: 1.45; font-size: .96rem; max-width: 58ch; }
.action-points {
  display: grid; gap: 7px; padding: 12px 13px;
  color: #5d5445; font-size: .9rem; line-height: 1.32;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(234,223,203,.95);
  border-radius: 12px; list-style: none;
  box-shadow: inset 4px 0 0 var(--tone-faint);
}
.action-points li { position: relative; padding-left: 20px; }
.action-points li::before {
  content: "✓"; position: absolute; left: 0; top: .05em;
  width: 14px; height: 14px; border-radius: 999px;
  background: var(--tone-faint); color: var(--tone);
  font-size: .62rem; font-weight: 900; line-height: 14px; text-align: center;
}
.action-options { display: grid; gap: 9px; }
.option-btn {
  width: 100%; text-align: left; display: grid; position: relative; gap: 2px;
  background: rgba(255,255,255,.92); border-color: #d9cbb0;
  padding: 12px 40px 12px 14px; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(58,45,19,.06);
}
.option-btn::after {
  content: "›"; position: absolute; right: 15px; top: 50%;
  transform: translateY(-50%); color: var(--tone); font-size: 1.4rem; line-height: 1;
}
.option-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.92); border-color: #d9cbb0;
  box-shadow: 0 5px 14px rgba(58,45,19,.12);
}
.option-label { color: var(--ink); font-weight: 900; }
.option-desc { color: #756b5d; font-size: .82rem; line-height: 1.25; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 4px; }
.modal-actions button { min-width: 108px; }
.modal-actions.single-action { justify-content: stretch; }
.modal-actions.single-action button:not([hidden]) { flex: 1; }
.action-card.info-only #action-confirm { background: var(--tone); border-color: var(--tone); color: #fff; }

@media (max-width: 900px) {
  body { min-height: 100dvh; }
  header { align-items: flex-start; gap: 10px; padding: 8px 12px; }
  header h1 {
    flex: 0 1 34%; min-width: 112px;
    font-size: clamp(1rem, 6vw, 1.45rem); line-height: 1.06; letter-spacing: 0;
  }
  .header-right { flex: 1 1 auto; gap: 6px; align-items: center; }
  .badge { font-size: clamp(.66rem, 3.2vw, .82rem); padding: 3px 8px; border-radius: 999px; }
  button { padding: 8px 10px; border-radius: 8px; }
  button.ghost, .icon-toggle { padding: 7px 10px; font-size: clamp(.76rem, 3.6vw, .95rem); }
  button.link-button { padding: 0; font-size: .84rem; }
  main {
    grid-template-columns: 1fr; grid-template-areas: "board" "rack" "side";
    justify-items: center; align-items: start;
    gap: 12px; padding: 12px clamp(10px, 3vw, 16px) 18px;
    max-width: none;
  }
  #board-wrap, #rack-area, #side {
    width: min(100%, 94vw); max-width: 720px; margin-inline: auto;
  }
  #board { width: 100%; max-width: none; margin-inline: auto; }
  #legend {
    width: 100%; gap: 8px; justify-content: space-between; flex-wrap: nowrap;
    overflow-x: auto; padding: 0 2px 2px; scrollbar-width: none;
  }
  #legend::-webkit-scrollbar { display: none; }
  #legend span { flex: 0 0 auto; white-space: nowrap; }
  #rack-area { gap: 10px; }
  .preview {
    width: fit-content; max-width: 100%; align-items: center;
    border-radius: 14px; text-align: left;
  }
  .preview-copy {
    flex-wrap: wrap; row-gap: 2px;
  }
  #btn-fullscreen { display: none !important; }
  #rack {
    width: 100%; justify-content: space-between;
    gap: clamp(5px, 1.5vw, 8px);
    padding: 8px clamp(8px, 2.6vw, 12px);
  }
  #rack .tile, #rack .rack-slot {
    width: auto; height: clamp(46px, 12.3vw, 58px);
    flex: 1 1 0; min-width: 0; max-width: 64px;
    font-size: clamp(1.1rem, 7vw, 1.55rem);
  }
  #controls {
    width: 100%; display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  }
  #controls button, .action-group { min-width: 0; }
  .action-group { width: 100%; grid-template-columns: minmax(0, 1fr) 34px; }
  .action-main { white-space: nowrap; padding-inline: 8px; font-size: clamp(.78rem, 3.7vw, .96rem); }
  .btn-icon {
    width: 16px;
    height: 16px;
    margin-right: 4px;
    flex-basis: 16px;
  }
  .btn-icon svg {
    width: 16px;
    height: 16px;
  }
  #exchange-bar { width: 100%; flex-wrap: wrap; justify-content: center; text-align: center; }
  #exchange-bar span { flex: 1 0 100%; }
  .overlay { align-items: flex-end; padding: 10px; }
  .profile-card {
    width: 100%; max-height: min(88vh, 760px);
    border-radius: 20px 20px 14px 14px;
    padding-inline: 14px;
  }
  .profile-summary { display: grid; gap: 6px; align-items: stretch; }
  .profile-summary span { white-space: normal; }
  .profile-tabs { grid-template-columns: 1fr; }
  .profile-game { align-items: stretch; flex-direction: column; }
  .profile-continue { width: 100%; }
  .records-grid { grid-template-columns: 1fr; }
  .rules-card {
    width: 100%; max-height: min(88vh, 760px);
    border-radius: 20px 20px 14px 14px;
    padding: 22px 16px 16px;
  }
  .rules-grid { grid-template-columns: 1fr; gap: 8px; }
  .rules-grid section { padding: 11px 12px; }
  .action-card {
    width: 100%; max-width: 520px;
    border-radius: 20px 20px 14px 14px;
    padding: 24px 16px 16px; gap: 14px; position: relative;
  }
  .action-card::before {
    content: ""; position: absolute; top: 9px; left: 50%;
    transform: translateX(-50%); width: 42px; height: 4px;
    border-radius: 999px; background: rgba(109,103,90,.32);
  }
  .action-head { grid-template-columns: 40px minmax(0, 1fr) 32px; gap: 10px; }
  .action-icon { width: 40px; height: 40px; border-radius: 12px; }
  .action-card h2 { font-size: 1.16rem; }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .modal-actions button { min-width: 0; width: 100%; }
  .modal-actions.single-action { grid-template-columns: 1fr; }
  #players, #side { gap: 8px; }
}

/* -------------------------------------------------------------------------
   Product surfaces opened from the home hub
   ------------------------------------------------------------------------- */
.hero-word { width: 100%; transform: rotate(.7deg); }
.hero-rack {
  width: min(100%, 510px);
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(5px, .65vw, 9px);
  padding: 17px 18px 23px;
}
.hero-rack span {
  width: 100%; height: auto; aspect-ratio: 1;
  font-size: clamp(1.25rem, 2.2vw, 1.85rem);
}

.overlay {
  padding: 24px;
  background: rgba(18,31,22,.72);
  backdrop-filter: blur(8px) saturate(.85);
}
.new-game-card {
  width: min(96vw, 1080px); height: min(90vh, 820px); max-height: 820px;
  display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 0;
  padding: 0; overflow: hidden; border-radius: 25px;
  background: #faf7ef; border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 30px 80px rgba(10,25,15,.38);
}
.setup-identity {
  --setup-tone: #e4bc63;
  min-width: 0; display: flex; flex-direction: column; gap: 26px;
  padding: 28px 30px 34px; color: #fff; overflow: hidden; position: relative;
  background:
    radial-gradient(circle at 90% 12%, rgba(255,255,255,.13), transparent 26%),
    linear-gradient(155deg, #183b27 0%, #2c5c3d 100%);
}
.setup-identity::after {
  content: ""; position: absolute; right: -95px; bottom: -110px;
  width: 260px; height: 260px; border: 44px solid rgba(255,255,255,.055);
  border-radius: 50%; pointer-events: none;
}
.setup-mode-online {
  --setup-tone: #a8d6c1;
  background:
    radial-gradient(circle at 90% 12%, rgba(255,255,255,.13), transparent 26%),
    linear-gradient(155deg, #173b3a 0%, #2d6660 100%);
}
.setup-mode-local {
  --setup-tone: #efd09a;
  background:
    radial-gradient(circle at 90% 12%, rgba(255,255,255,.12), transparent 26%),
    linear-gradient(155deg, #49361e 0%, #77542b 100%);
}
.setup-back {
  align-self: flex-start; padding: 7px 0; color: rgba(255,255,255,.76);
  background: transparent; border: 0; box-shadow: none; font-size: .78rem;
}
.setup-back:hover:not(:disabled) { color: #fff; box-shadow: none; }
.setup-mode-symbol {
  width: 70px; height: 70px; display: grid; place-items: center;
  border-radius: 19px; color: #392910; background: var(--setup-tone);
  font: 900 1.35rem/1 Georgia, "Times New Roman", serif;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 10px 24px rgba(10,22,13,.23);
  transform: rotate(-2deg);
}
.setup-identity > div:nth-of-type(2) { display: grid; gap: 9px; position: relative; z-index: 1; }
.setup-identity .setup-kicker { color: var(--setup-tone); }
.setup-identity h2 {
  max-width: 260px; color: #fff; font-family: Georgia, "Times New Roman", serif;
  font-size: 2.05rem; line-height: 1.03; letter-spacing: -.025em;
}
.setup-identity .setup-subtitle { color: rgba(255,255,255,.7); line-height: 1.5; }
.setup-benefits {
  list-style: none; display: grid; gap: 12px; margin-top: auto;
  position: relative; z-index: 1;
}
.setup-benefits li {
  display: grid; grid-template-columns: 20px minmax(0,1fr); gap: 9px;
  align-items: center; color: rgba(255,255,255,.82); font-size: .82rem;
}
.setup-benefits li::before {
  content: "✓"; width: 20px; height: 20px; display: grid; place-items: center;
  border-radius: 50%; color: #203b29; background: var(--setup-tone);
  font-size: .68rem; font-weight: 900;
}
.setup-form {
  min-width: 0; overflow-y: auto; padding: 24px 30px 26px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-gutter: stable;
}
.setup-form-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.setup-form-head > div { display: grid; gap: 3px; }
.setup-form-head span { color: #9a793a; font-size: .67rem; font-weight: 900; letter-spacing: .12em; }
.setup-form-head strong { color: #263a2c; font: 700 1.1rem/1.25 Georgia, "Times New Roman", serif; }
.setup-name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.setup-name-grid > label:only-of-type { grid-column: 1 / -1; }
.setup-form label > span:first-child { color: #50493d; font-size: .75rem; font-weight: 850; }
.setup-form input[type="text"],
.setup-form input[type="password"],
.setup-form input:not([type]) {
  width: 100%; min-height: 42px; padding: 9px 12px;
  background: #fff; border: 1px solid #d5cbb9; border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(58,45,19,.035);
}
.setup-form input:focus-visible { border-color: #b68b39; outline: 3px solid rgba(220,185,103,.26); }
.setup-form fieldset {
  min-width: 0; display: grid; gap: 7px; padding: 0; border: 0;
}
.setup-form fieldset legend {
  width: 100%; margin-bottom: 4px; color: #50493d; font-size: .75rem; font-weight: 900;
}
.setup-form .preset-choice { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setup-form .preset-choice legend { grid-column: 1 / -1; }
.setup-form .time-control-choice { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.setup-form .time-control-choice legend { grid-column: 1 / -1; }
.preset-choice label,
.time-control-choice label,
.setup-form .ai-difficulty-choice label {
  min-width: 0; display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 10px; border: 1px solid #ded5c5; border-radius: 12px;
  background: rgba(255,255,255,.72); cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.preset-choice label,
.time-control-choice label { align-items: center; }
.preset-choice label span,
.time-control-choice label span,
.setup-form .ai-difficulty-choice label span { min-width: 0; display: grid; gap: 3px; }
.preset-choice label b,
.time-control-choice label b,
.setup-form fieldset label b { color: #293b2e; font-size: .86rem; }
.preset-choice label small,
.time-control-choice label small,
.setup-form fieldset label small { color: #756b5c; font-size: .71rem; line-height: 1.28; }
.preset-choice label:has(input:checked),
.time-control-choice label:has(input:checked),
.setup-form .ai-difficulty-choice label:has(input:checked) {
  border-color: #b88b38; background: #fffaf0;
  box-shadow: 0 0 0 2px rgba(210,165,76,.18), 0 5px 12px rgba(69,52,25,.06);
}
.setup-form input[type="radio"] { margin-top: 2px; accent-color: #315c3e; flex: 0 0 auto; }
.clock-ready-card { gap: 12px; }
.clock-ready-card .clock-symbol { border-radius: 50%; }
.clock-ready-card > p { max-width: 34ch; color: #6d6456; line-height: 1.5; }
.clock-ready-players { width: 100%; display: grid; gap: 7px; margin: 4px 0; }
.clock-ready-player {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 9px 12px; border-bottom: 1px solid #e8dfd0; color: #3f493f;
}
.clock-ready-player strong { font-size: .9rem; }
.clock-ready-player span { color: #8b7350; font-size: .76rem; font-weight: 850; }
.clock-ready-player.is-ready span { color: #315d3e; }
.clock-countdown {
  min-height: 86px; display: grid; place-items: center; color: #315d3e;
  font: 900 4.2rem/1 Georgia, serif; font-variant-numeric: tabular-nums;
}
.clock-countdown[hidden] { display: none; }
.setup-form .ai-difficulty-choice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setup-form .ai-difficulty-choice legend { grid-column: 1 / -1; }
.setup-note {
  display: grid; grid-template-columns: 25px minmax(0,1fr) auto; gap: 10px;
  align-items: center; padding: 9px 11px; border: 1px solid #e0d4ba;
  border-radius: 12px; background: #f4eddd;
}
.setup-note > span {
  width: 23px; height: 23px; display: grid; place-items: center;
  border-radius: 50%; background: #315b3d; color: #fff; font: 800 .75rem Georgia, serif;
}
.setup-note p { color: #685f51; font-size: .75rem; line-height: 1.35; }
.setup-note .link-button { color: #315b3d; font-size: .75rem; white-space: nowrap; }
.setup-form .online-key-field { display: grid; gap: 5px; }
.new-game-actions { display: grid; gap: 9px; margin-top: 1px; }
.new-game-actions .primary { min-height: 48px; font-size: .96rem; }
.share-panel {
  gap: 11px; padding: 15px; border-radius: 15px;
  background: #f2f8f2; border-color: #abc7ad;
}
.share-success { display: flex; align-items: center; gap: 11px; }
.share-success > span {
  width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px;
  border-radius: 50%; background: #315c3e; color: #fff; font-weight: 900;
}
.share-success > div { display: grid; gap: 2px; }
.share-success b { color: #284a33; }
.share-success small { color: #667668; }
.share-panel .share-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px;
  padding: 11px; border-radius: 11px; background: #fff; border: 1px solid #d4e1d4;
}
.share-row > span { grid-column: 1 / -1; color: #4a5f4e; font-size: .71rem; font-weight: 900; text-transform: uppercase; }
.share-row a { min-width: 0; align-self: center; font-size: .72rem; }
.share-row button { padding: 7px 10px; font-size: .72rem; }
.share-private-note { margin: 0; color: #59695c; font-size: .72rem; line-height: 1.4; }

.profile-card, .rules-card {
  padding: 0; gap: 0; overflow: hidden; border-radius: 24px;
  background: #faf7ef; border: 1px solid rgba(255,255,255,.72);
  box-shadow: 0 30px 80px rgba(10,25,15,.38);
}
.profile-card { width: min(94vw, 840px); max-height: min(90vh, 780px); }
.profile-hero, .rules-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 26px 30px; color: #fff;
  background:
    radial-gradient(circle at 88% 0%, rgba(255,255,255,.12), transparent 25%),
    linear-gradient(135deg, #183a27, #315f3f);
}
.profile-hero > div, .rules-head > div { display: grid; gap: 4px; }
.profile-hero span, .rules-kicker { color: #e1bd6b; font-size: .67rem; font-weight: 900; letter-spacing: .14em; }
.profile-hero h2, .rules-head h2 { color: #fff; font: 700 1.75rem/1.05 Georgia, "Times New Roman", serif; }
.profile-hero p, .rules-head p { color: rgba(255,255,255,.68); font-size: .82rem; line-height: 1.4; }
.profile-hero .dialog-close, .rules-head .action-close {
  background: rgba(255,255,255,.11); color: #fff; border-color: rgba(255,255,255,.13);
}
.profile-body { min-height: 390px; overflow-y: auto; padding: 24px 30px 30px; }
.profile-summary { margin: 0 0 17px; }
.profile-summary input { border-radius: 10px; border-color: #d4c9b7; background: #fff; }
.profile-tabs {
  grid-template-columns: repeat(3, 1fr); margin: 0 0 20px;
  padding: 5px; border-radius: 12px; background: #eae2d3; border-color: #d7cbb7;
}
.profile-tabs button { min-height: 40px; }
.profile-tabs button.active { color: #254a31; box-shadow: 0 3px 8px rgba(58,45,19,.1); }
.profile-game, .record-card { border-radius: 13px; border-color: #ddd3c2; box-shadow: 0 5px 14px rgba(58,45,19,.055); }
.profile-empty, .profile-loading {
  min-height: 180px; display: grid; align-content: center; justify-items: center;
  text-align: center; border-radius: 14px; background: #f5eddd;
}

.rules-card {
  width: min(94vw, 900px); max-height: min(90vh, 790px);
  overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable;
}
.rules-head { padding: 28px 32px; }
.rules-grid {
  counter-reset: rule-step; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; padding: 24px 30px 14px;
}
.rules-grid section {
  counter-increment: rule-step; position: relative; min-height: 145px;
  padding: 43px 18px 18px; border: 1px solid #ded4c3; border-radius: 15px;
  background: #fff; box-shadow: 0 5px 14px rgba(58,45,19,.045);
}
.rules-grid section::before {
  content: "0" counter(rule-step); position: absolute; top: 14px; left: 17px;
  color: #b18432; font: 900 .72rem/1 Georgia, serif; letter-spacing: .08em;
}
.rules-grid section:nth-child(5) { grid-column: 1 / -1; min-height: 115px; }
.rules-grid h3 { color: #29432f; font: 700 1.06rem/1.2 Georgia, "Times New Roman", serif; }
.rules-grid p { margin-top: 7px; color: #6d6457; line-height: 1.48; }
.rules-note {
  margin: 0 30px 14px; padding: 12px 14px; border-radius: 12px;
  background: #eee6d5; border-left: 4px solid #b98935; color: #635a4c;
}
.rules-card #rules-ok { margin: 0 30px 26px; min-height: 46px; }

@media (max-width: 1100px) and (min-width: 901px) {
  .hub-hero { grid-template-columns: minmax(0,1fr) minmax(430px,.9fr); gap: 22px; }
  .hero-rack { padding-inline: 12px; }
}

@media (max-width: 900px) {
  .hero-word { transform: none; }
  .hero-rack {
    width: 100%; grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: clamp(3px, 1.1vw, 7px); padding: 12px 12px 17px;
  }
  .hero-rack span { width: 100%; height: auto; font-size: clamp(.95rem, 5.5vw, 1.55rem); }
  .overlay { align-items: flex-end; padding: 10px; backdrop-filter: blur(6px); }
  .new-game-card {
    width: 100%; height: auto; max-height: 94dvh;
    grid-template-columns: 1fr; overflow-y: auto; border-radius: 24px 24px 14px 14px;
  }
  .setup-identity { min-height: 245px; padding: 22px 22px 24px; gap: 16px; }
  .setup-identity::after { width: 190px; height: 190px; right: -80px; bottom: -95px; }
  .setup-back { padding-top: 0; }
  .setup-mode-symbol { width: 54px; height: 54px; border-radius: 15px; }
  .setup-identity h2 { max-width: 90%; font-size: 1.7rem; }
  .setup-benefits { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 0; }
  .setup-benefits li { grid-template-columns: 18px minmax(0,1fr); gap: 6px; font-size: .68rem; align-items: start; }
  .setup-benefits li::before { width: 18px; height: 18px; }
  .setup-form { overflow: visible; padding: 22px 20px 24px; }
  .profile-card, .rules-card { width: 100%; max-height: 92dvh; border-radius: 24px 24px 14px 14px; }
  .profile-hero, .rules-head { padding: 23px 20px; }
  .profile-body { padding: 20px; }
  .profile-tabs { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .rules-grid { grid-template-columns: 1fr; padding: 18px 18px 12px; }
  .rules-grid section, .rules-grid section:nth-child(5) { grid-column: auto; min-height: 0; }
  .rules-note { margin-inline: 18px; }
  .rules-card #rules-ok { margin-inline: 18px; }
}

@media (max-width: 560px) {
  .setup-benefits { display: none; }
  .setup-identity { min-height: 205px; }
  .setup-name-grid { grid-template-columns: 1fr; }
  .setup-form .ai-difficulty-choice { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .setup-form .preset-choice { gap: 6px; }
  .setup-form .time-control-choice { grid-template-columns: 1fr; gap: 6px; }
  .preset-choice label { padding: 9px 7px; }
  .preset-choice label input { display: none; }
  .setup-note { grid-template-columns: 24px minmax(0,1fr); }
  .setup-note .link-button { grid-column: 2; justify-self: start; }
  .profile-summary { grid-template-columns: 1fr; }
  .profile-summary span { justify-self: start; padding: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .player-clock.is-danger.is-active { animation: clock-urgent 850ms ease-in-out infinite alternate; }
  @keyframes clock-urgent { to { opacity: .62; } }
}

/* -------------------------------------------------------------------------
   UX/UI elevation — one visual system from home to final score
   ------------------------------------------------------------------------- */
:root {
  --surface: #fffcf6;
  --surface-soft: #f3ecde;
  --line: #d9cfbd;
  --forest-950: #102b1c;
  --forest-900: #173824;
  --forest-700: #315d3e;
  --gold: #ddb85f;
  --gold-soft: #f2d58e;
  --shadow-sm: 0 5px 16px rgba(43,34,18,.07);
  --shadow-md: 0 16px 36px rgba(34,48,37,.13);
  --shadow-lg: 0 30px 80px rgba(14,31,20,.3);
}

body { background: #f3ede2; }
header {
  position: sticky; top: 0; z-index: 15; min-height: 58px;
  padding-inline: max(18px, calc((100vw - 1280px) / 2));
  background: rgba(24,58,39,.96); backdrop-filter: blur(14px) saturate(1.2);
}
.brand-home { border-radius: 10px; padding: 3px 6px 3px 3px; }
.brand-home:hover:not(:disabled) { background: rgba(255,255,255,.07); }
.header-right .ghost, .header-right .icon-toggle {
  min-height: 34px; border-radius: 9px; font-size: .76rem;
}

.start-screen {
  background:
    radial-gradient(circle at 8% 18%, rgba(221,184,95,.13), transparent 25%),
    radial-gradient(circle at 92% 46%, rgba(49,93,62,.1), transparent 30%),
    linear-gradient(180deg, #faf6ee 0%, #f1e9db 100%);
}
.hub-shell { width: min(1240px, 100%); padding-top: 38px; }
.hub-hero {
  min-height: 390px; grid-template-columns: minmax(0, 1.03fr) minmax(430px, .97fr);
  border: 1px solid rgba(255,255,255,.12); box-shadow: var(--shadow-lg);
}
.hub-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.09) .7px, transparent .7px);
  background-size: 9px 9px; mask-image: linear-gradient(90deg, #000, transparent 60%);
}
.hero-copy > p { max-width: 630px; }
.hero-actions { display: flex; align-items: center; gap: 18px; margin-top: 25px; }
.hero-actions .hero-play {
  min-height: 48px; display: inline-flex; align-items: center; gap: 28px;
  padding: 10px 13px 10px 18px; border-color: #f0d28b; border-radius: 12px;
  background: linear-gradient(180deg, #f5d98f, #d9ae51); color: #2e2719;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 10px 22px rgba(7,21,12,.22);
}
.hero-actions .hero-play:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 14px 26px rgba(7,21,12,.3); }
.hero-play i {
  width: 27px; height: 27px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(42,34,18,.1); font-style: normal;
}
.hero-actions a { color: rgba(255,255,255,.76); font-size: .85rem; font-weight: 850; text-underline-offset: 5px; }
.hero-actions a:hover { color: #fff; }
.hero-facts { margin-top: 24px; }
.hero-rack {
  border: 1px solid rgba(255,225,160,.22);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.16), 0 22px 40px rgba(7,21,12,.37);
}

.hub-continue {
  position: relative; overflow: hidden; border-color: #d5bb7d;
  box-shadow: var(--shadow-sm); background: rgba(255,252,246,.9);
}
.hub-continue::before { content: ""; width: 5px; position: absolute; inset: 0 auto 0 0; background: var(--gold); }
.hub-continue .primary { min-width: 175px; }
.mode-section { padding-bottom: 28px; }
.mode-grid { gap: 18px; }
.mode-card {
  min-height: 276px; padding: 24px; border-radius: 21px;
  box-shadow: var(--shadow-sm); isolation: isolate; overflow: hidden; position: relative;
}
.mode-card::before {
  content: ""; position: absolute; width: 150px; height: 150px; right: -95px; top: -95px;
  border-radius: 50%; border: 27px solid rgba(49,93,62,.045); z-index: -1;
}
.mode-card.featured::before { border-color: rgba(255,255,255,.055); }
.mode-card:focus-visible { outline-offset: 4px; }
.mode-mark { width: 52px; height: 52px; border-radius: 15px; }
.mode-copy b { font-size: 1.48rem; }

.play-path {
  display: grid; grid-template-columns: minmax(210px,.72fr) minmax(0,1.5fr);
  gap: 24px; align-items: center; margin: 0 0 32px; padding: 20px 22px;
  border: 1px solid var(--line); border-radius: 18px; background: rgba(255,252,246,.72);
  box-shadow: var(--shadow-sm);
}
.play-path-intro { display: grid; gap: 7px; padding-right: 22px; border-right: 1px solid var(--line); }
.play-path-intro strong { color: #243a2a; font: 700 1.03rem/1.35 Georgia, "Times New Roman", serif; }
.play-path ol { list-style: none; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.play-path li { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 10px; align-items: start; }
.play-path li > span {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
  background: #e6dcc8; color: #8b692d; font: 900 .67rem/1 Georgia, serif;
}
.play-path li div { display: grid; gap: 3px; }
.play-path li b { color: #2a3d2f; font-size: .81rem; }
.play-path li small { color: #796f61; font-size: .7rem; line-height: 1.35; }
.clarity-story { position: relative; overflow: hidden; }
.clarity-story::after {
  content: "А Б В Г Д Ђ Е Ж"; position: absolute; right: -8px; bottom: -8px;
  color: rgba(94,73,33,.055); font: 900 3.2rem/1 Georgia, serif; letter-spacing: .06em;
  white-space: nowrap; pointer-events: none;
}

/* setup journey */
.setup-progress {
  list-style: none; display: grid; grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 0; padding: 0 2px 3px;
}
.setup-progress li {
  position: relative; display: flex; align-items: center; gap: 7px;
  color: #988f80; font-size: .68rem; font-weight: 850;
}
.setup-progress li:not(:last-child)::after {
  content: ""; height: 1px; flex: 1; margin-inline: 6px; background: #ded5c5;
}
.setup-progress li span {
  width: 21px; height: 21px; display: grid; place-items: center; flex: 0 0 21px;
  border: 1px solid #d1c8b7; border-radius: 50%; background: #fff; font-size: .62rem;
}
.setup-progress li.done { color: #718074; }
.setup-progress li.done span { color: #fff; border-color: #78907d; background: #78907d; }
.setup-progress li.current { color: #2e5339; }
.setup-progress li.current span { color: #fff; border-color: #2e5339; background: #2e5339; box-shadow: 0 0 0 3px rgba(46,83,57,.12); }
.setup-form fieldset label { position: relative; }
.setup-form fieldset label:has(input:checked)::after {
  content: "✓"; position: absolute; right: 9px; top: 8px; width: 18px; height: 18px;
  display: grid; place-items: center; border-radius: 50%; color: #fff; background: #315c3e;
  font-size: .58rem; font-weight: 900;
}
.setup-form fieldset label:has(input:checked) { padding-right: 34px; }
.new-game-actions { position: sticky; bottom: -1px; z-index: 2; padding-top: 3px; background: linear-gradient(180deg, transparent, #faf7ef 22%); }
.new-game-actions .primary::after { content: "  →"; }

/* gameplay surface */
body[data-view="game"] {
  background:
    radial-gradient(circle at 5% 10%, rgba(221,184,95,.12), transparent 24%),
    linear-gradient(180deg, #eee7da, #f7f2e9);
}
body[data-view="game"] main {
  max-width: 1260px; grid-template-columns: minmax(0,1fr) 350px;
  gap: 18px; padding: 22px 22px 30px;
}
body[data-view="game"] #board-wrap {
  align-self: start; padding: 15px 15px 10px; border: 1px solid #d6cbb7;
  border-radius: 18px; background: rgba(255,252,246,.8); box-shadow: var(--shadow-md);
}
body[data-view="game"] #board {
  padding: 8px; gap: 2px; border-radius: 13px;
  box-shadow: 0 16px 30px rgba(29,59,39,.18), inset 0 0 0 1px rgba(255,255,255,.13);
}
body[data-view="game"] .cell { border-radius: 4px; }
body[data-view="game"] .tile { border-radius: 5px; box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 3px rgba(44,31,10,.28); }
body[data-view="game"] #side { gap: 12px; }
body[data-view="game"] .panel,
body[data-view="game"] .player {
  border-color: #d8cebd; border-radius: 14px; background: rgba(255,253,248,.92);
  box-shadow: var(--shadow-sm);
}
body[data-view="game"] .player { min-height: 68px; padding: 12px 14px; }
body[data-view="game"] .player.current {
  color: #fff; border-color: #315d3e; background: linear-gradient(135deg,#244b32,#3b6a48);
  box-shadow: 0 8px 18px rgba(34,75,49,.2);
}
body[data-view="game"] .player.current .turnmark { color: #f1d383; }
body[data-view="game"] .player.current .score { color: #fff; }
body[data-view="game"] .panel h3 { color: #9a793a; font-size: .7rem; letter-spacing: .11em; }
body[data-view="game"] .history-panel {
  flex: 1 1 130px; min-height: 130px;
  display: flex; flex-direction: column; overflow: hidden;
}
body[data-view="game"] .history-panel > h3 { flex: 0 0 auto; }
body[data-view="game"] #history {
  flex: 1 1 auto; min-height: 0; max-height: none;
}
body[data-view="game"] #history li { padding-block: 9px; border-bottom-color: #ebe3d5; }
body[data-view="game"] #rack-area {
  padding: 12px 14px 14px; border: 1px solid #d8cdb9; border-radius: 16px;
  background: #fffcf6; box-shadow: var(--shadow-sm);
}
body[data-view="game"] #rack {
  padding: 10px 13px 12px; border-radius: 12px;
  background: linear-gradient(180deg,#896639,#6f4e27);
  border: 1px solid #60431f; box-shadow: inset 0 3px 5px rgba(42,27,10,.3), 0 8px 16px rgba(55,38,14,.12);
}
body[data-view="game"] #controls { margin-top: 2px; }
body[data-view="game"] .action-group { min-height: 44px; border-radius: 11px; }
body[data-view="game"] #legend { margin-top: 10px; color: #746b5d; }

/* complete system dialogs */
.system-card {
  width: min(92vw, 480px); padding: 30px; border: 1px solid rgba(255,255,255,.72);
  border-radius: 22px; background:
    radial-gradient(circle at 50% -20%, rgba(222,185,96,.2), transparent 40%),
    #fffcf6; box-shadow: var(--shadow-lg);
}
.system-symbol {
  width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px;
  background: linear-gradient(145deg,#f2d68f,#d5aa50); color: #3e2d13;
  font: 900 1.6rem/1 Georgia,serif; box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 10px 22px rgba(76,55,18,.17);
}
.system-kicker { color: #a17b32; font-size: .68rem; font-weight: 900; letter-spacing: .14em; }
.system-card h2, .blank-card h2 { color: #263d2d; font-family: Georgia,"Times New Roman",serif; }
.system-card > p, .system-copy { color: #746b5e; line-height: 1.5; }
.system-card .primary { width: 100%; margin-top: 5px; min-height: 48px; }
.danger-symbol { color: #fff; background: linear-gradient(145deg,#c15a4f,#9e3028); }
.trophy-symbol { color: #fff8df; background: linear-gradient(145deg,#b9862e,#7e5920); }
.blank-card { padding-top: 27px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.blank-card .system-copy { max-width: 330px; font-size: .84rem; }
.end-card { width: min(92vw, 540px); }
.end-winner { border-radius: 14px; }
.end-row { border-radius: 11px; padding-block: 12px; }

#toast {
  min-width: min(340px,calc(100vw - 28px)); padding: 12px 16px 12px 46px;
  border-radius: 13px; text-align: left; background: #244a32; box-shadow: 0 14px 34px rgba(10,25,15,.3);
}
#toast::before {
  content: "✓"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(255,255,255,.16); font-size: .7rem; font-weight: 900;
}
#toast.err { background: #a83d34; }
#toast.err::before { content: "!"; }

@media (max-width: 900px) {
  header { position: sticky; padding-inline: 12px; }
  .hub-shell { padding-top: 14px; }
  .hub-hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-actions { flex-wrap: wrap; }
  .hero-actions .hero-play { flex: 0 1 auto; }
  .play-path { grid-template-columns: 1fr; gap: 16px; }
  .play-path-intro { padding: 0 0 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  body[data-view="game"] main { grid-template-columns: 1fr; padding: 12px 10px 22px; }
  body[data-view="game"] #board-wrap { width: min(100%,720px); padding: 8px 8px 7px; border-radius: 14px; }
  body[data-view="game"] #rack-area { padding: 10px; }
}

@media (max-width: 560px) {
  .hero-actions { display: grid; grid-template-columns: 1fr; justify-items: stretch; gap: 13px; }
  .hero-actions .hero-play { width: 100%; justify-content: space-between; }
  .hero-actions a { text-align: center; }
  .play-path { padding: 18px; }
  .play-path ol { grid-template-columns: 1fr; gap: 14px; }
  .setup-progress li { font-size: 0; }
  .setup-progress li:not(:last-child)::after { margin-inline: 8px; }
  .system-card { padding: 25px 20px 20px; }
  body[data-view="game"] #legend { font-size: .65rem; }
  #toast { bottom: 14px; }
}

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */
.app-header { display: block; padding-block: 8px; }
.header-shell {
  width: min(1280px,100%); min-height: 42px; margin: 0 auto;
  display: grid; grid-template-columns: auto minmax(180px,1fr) auto;
  align-items: center; gap: 22px;
}
.brand-lockup { display: grid; gap: 1px; text-align: left; }
.brand-lockup small {
  color: rgba(255,255,255,.55); font-size: .57rem; font-weight: 750;
  letter-spacing: .08em; text-transform: uppercase;
}
.header-context { min-width: 0; display: flex; align-items: center; }
.header-right { flex-wrap: nowrap; }
.header-right button { white-space: nowrap; }
.header-new {
  min-height: 35px; padding-inline: 14px; border-color: #e2c06f;
  color: #302716; background: linear-gradient(180deg,#f2d68e,#d8ad50);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55),0 4px 11px rgba(10,25,15,.16);
}
.header-new:hover:not(:disabled) {
  border-color: #f0d68f; background: linear-gradient(180deg,#f7dfa2,#dfb95d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6),0 6px 14px rgba(10,25,15,.24);
}
@media (max-width: 900px) {
  .app-header { padding: 8px 12px; }
  .header-shell { grid-template-columns: auto minmax(0,1fr); gap: 8px 12px; }
  .header-context { justify-content: flex-end; }
  .header-right {
    grid-column: 1 / -1; width: 100%; justify-content: flex-end;
    padding-top: 7px; border-top: 1px solid rgba(255,255,255,.1);
  }
}

@media (max-width: 560px) {
  .brand-lockup small { display: none; }
  .brand-home { gap: 7px; }
  .header-right { justify-content: space-between; gap: 5px; }
  .header-right .ghost, .header-right .icon-toggle, .header-new { flex: 1 1 auto; min-width: 0; padding-inline: 7px; }
}

/* -------------------------------------------------------------------------
   Rich game-hub presentation
   ------------------------------------------------------------------------- */
.hero-game-preview {
  width: min(100%, 480px); justify-self: end; position: relative; z-index: 2;
  padding: 13px; border: 1px solid rgba(244,218,163,.24); border-radius: 20px;
  background: linear-gradient(155deg,rgba(255,255,255,.12),rgba(255,255,255,.045));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12),0 28px 55px rgba(6,21,11,.34);
  transform: perspective(900px) rotateY(-2deg) rotateZ(.4deg);
}
.preview-scorebar {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch;
  margin-bottom: 10px;
}
.preview-player {
  min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  gap: 0 8px; align-items: center; padding: 8px 10px; border-radius: 11px;
  background: rgba(8,28,15,.3); border: 1px solid rgba(255,255,255,.1);
}
.preview-player > span { color: rgba(255,255,255,.65); font-size: .62rem; font-weight: 900; }
.preview-player strong { grid-row: 1 / 3; grid-column: 2; justify-self: end; color: #fff; font: 900 1.28rem/1 Georgia,serif; }
.preview-player small { color: rgba(255,255,255,.5); font-size: .56rem; }
.preview-player.active { background: rgba(232,195,111,.16); border-color: rgba(240,210,139,.35); }
.preview-player.active > span, .preview-player.active small { color: #f0d28b; }
.preview-round { display: grid; place-items: center; align-content: center; gap: 2px; padding-inline: 7px; text-align: center; }
.preview-round span { color: #e5bd62; font-size: .5rem; font-weight: 950; letter-spacing: .1em; }
.preview-round b { color: rgba(255,255,255,.65); font-size: .58rem; white-space: nowrap; }
.mini-board {
  display: grid; grid-template-columns: repeat(7,1fr); grid-template-rows: repeat(7,1fr);
  gap: 3px; aspect-ratio: 1; padding: 7px; overflow: hidden; border-radius: 13px;
  background-color: #234a32;
  background-image:
    linear-gradient(rgba(255,255,255,.055) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.055) 1px,transparent 1px);
  background-size: calc(100% / 7) calc(100% / 7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08),inset 0 10px 30px rgba(5,20,10,.2);
}
.mini-board::before {
  content: ""; grid-area: 1 / 1 / 8 / 8; border-radius: 8px;
  background: radial-gradient(circle at center,rgba(239,179,173,.16),transparent 13%);
}
.mini-premium, .mini-tile { min-width: 0; min-height: 0; display: grid; place-items: center; z-index: 1; }
.mini-premium {
  align-self: stretch; border-radius: 5px; color: rgba(255,255,255,.76);
  background: rgba(125,160,190,.5); font-size: clamp(.38rem,.75vw,.57rem); font-style: normal; font-weight: 900;
}
.mp-1 { grid-area: 1 / 1; background: rgba(192,71,61,.7); }
.mp-2 { grid-area: 2 / 3; }
.mp-3 { grid-area: 4 / 4; color: #7c342f; background: rgba(239,179,173,.88); font-size: .9rem; }
.mp-4 { grid-area: 7 / 7; background: rgba(217,139,133,.75); }
.mini-tile {
  position: relative; aspect-ratio: 1; align-self: center; width: 92%; justify-self: center;
  border: 1px solid #c99d50; border-bottom-width: 3px; border-radius: 6px;
  color: #3b2a12; background: linear-gradient(145deg,#ffedbd,#dfba6b);
  font: 900 clamp(.9rem,2vw,1.3rem)/1 Georgia,"Times New Roman",serif;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72),0 3px 6px rgba(13,8,2,.3);
}
.mini-tile small { position: absolute; right: 4px; bottom: 2px; font: 800 .42em/1 Georgia,serif; }
.mt-s { grid-area: 4 / 2; }.mt-l { grid-area: 4 / 3; }.mt-o1 { grid-area: 4 / 4; }
.mt-v { grid-area: 4 / 5; }.mt-o2 { grid-area: 4 / 6; }.mt-b { grid-area: 3 / 6; }.mt-j { grid-area: 5 / 6; }
.preview-rack {
  display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 5px;
  width: 82%; margin: 10px auto 0; padding: 7px 9px 10px; border-radius: 9px;
  background: linear-gradient(180deg,#805c30,#5e3d1c); box-shadow: inset 0 3px 4px rgba(28,16,4,.28);
}
.preview-rack span {
  position: relative; aspect-ratio: 1; display: grid; place-items: center; min-width: 0;
  border: 1px solid #c99d50; border-bottom-width: 2px; border-radius: 4px;
  color: #3c2a12; background: linear-gradient(145deg,#ffedbd,#ddb667);
  font: 900 clamp(.68rem,1.25vw,.95rem)/1 Georgia,serif;
}
.preview-rack small { position: absolute; right: 2px; bottom: 1px; font-size: .42em; }
.preview-action {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 10px; padding: 8px 9px 8px 11px; border-radius: 10px;
  background: rgba(7,24,13,.34); color: rgba(255,255,255,.72); font-size: .67rem;
}
.preview-action > span { display: flex; align-items: center; gap: 6px; }
.preview-action i { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: #e0ba63; color: #24351f; font-style: normal; font-weight: 900; }
.preview-action b { color: #f0d28b; }
.preview-action button { padding: 6px 10px; border: 0; border-radius: 7px; background: #e0ba63; color: #2c2517; font-size: .65rem; pointer-events: none; }

.mode-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -7px; }
.mode-meta span {
  padding: 5px 8px; border-radius: 999px; color: #6e665b; background: #f1eadf;
  border: 1px solid #e2d7c4; font-size: .61rem; font-weight: 850; text-transform: uppercase; letter-spacing: .035em;
}
.featured .mode-meta span { color: rgba(255,255,255,.76); background: rgba(255,255,255,.085); border-color: rgba(255,255,255,.12); }

@media (max-width: 900px) {
  .hero-game-preview { width: min(100%,520px); justify-self: center; transform: none; }
}

@media (max-width: 560px) {
  .hero-game-preview { padding: 9px; border-radius: 15px; }
  .preview-player { padding: 6px 7px; }
  .preview-player strong { font-size: 1.05rem; }
  .preview-round { display: none; }
  .preview-scorebar { grid-template-columns: 1fr 1fr; }
  .mini-board { padding: 5px; gap: 2px; }
  .preview-rack { width: 90%; }
  .preview-action { font-size: .61rem; }
}
