#ancientSocietySenet, body.senet-standalone-body{
  --bg: #15120d;
  --panel: #231d14;
  --panel-2: #2c2419;
  --line: #b59456;
  --ivory: #eadfc3;
  --muted: #b8aa8b;
  --gold: #d0a95e;
  --turquoise: #68a6a1;
  --wood-1: #6f4b2d;
  --wood-2: #8f6540;
  --shadow: rgba(0, 0, 0, 0.35);
}

#ancientSocietySenet, #ancientSocietySenet *{ box-sizing: border-box; }

#ancientSocietySenet{
  color: var(--ivory);
  font-family: Georgia, "Times New Roman", serif;
  line-height: normal;
  isolation: isolate;
}

body.senet-standalone-body{
  margin: 0;
  min-height: 100vh;
  color: var(--ivory);
  background:
    radial-gradient(circle at top, rgba(181,148,86,0.12), transparent 38rem),
    var(--bg);
  font-family: Georgia, "Times New Roman", serif;
}

#ancientSocietySenet button{ font: inherit; }

#ancientSocietySenet .senet-app{
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

#ancientSocietySenet .game-header{ text-align: center; margin-bottom: 24px; }
#ancientSocietySenet .game-header h1{ margin: 2px 0 6px; font-size: clamp(2.5rem, 6vw, 4.5rem); font-weight: 500; }
#ancientSocietySenet .eyebrow{ margin: 0; color: var(--gold); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.78rem; }
#ancientSocietySenet .subtitle{ max-width: 720px; margin: 0 auto; color: var(--muted); line-height: 1.55; }
#ancientSocietySenet .battle-subtitle{ margin: 0 auto 8px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.82rem; }


#ancientSocietySenet .game-shell{
  background: linear-gradient(145deg, rgba(255,255,255,0.025), rgba(255,255,255,0)), var(--panel);
  border: 1px solid rgba(208,169,94,0.45);
  border-radius: 18px;
  box-shadow: 0 24px 60px var(--shadow);
  padding: clamp(16px, 3vw, 30px);
}

#ancientSocietySenet .status-row{
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 2fr) minmax(140px, 1fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 20px;
}

#ancientSocietySenet .player-card, #ancientSocietySenet .turn-status{
  border: 1px solid rgba(234,223,195,0.14);
  background: rgba(0,0,0,0.13);
  border-radius: 12px;
  padding: 12px 14px;
}

#ancientSocietySenet .player-card{ display: flex; flex-direction: column; gap: 4px; }
#ancientSocietySenet .player-card:last-child{ text-align: right; }
#ancientSocietySenet .rival-card{ justify-content: center; }
#ancientSocietySenet .rival-badge{ display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
#ancientSocietySenet .rival-portrait{ width: 54px; height: 54px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(208,169,94,0.75); box-shadow: 0 6px 18px rgba(0,0,0,0.3); background: #22170f; }
#ancientSocietySenet .rival-meta{ display: flex; flex-direction: column; gap: 2px; align-items: flex-end; text-align: right; }
#ancientSocietySenet .player-role{ color: rgba(234,223,195,0.82); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
#ancientSocietySenet .player-card.is-active{ border-color: rgba(208,169,94,0.78); box-shadow: inset 0 0 0 1px rgba(208,169,94,0.15); }
#ancientSocietySenet .player-label{ color: var(--gold); font-size: 1.02rem; }
#ancientSocietySenet .piece-count{ color: var(--muted); font-size: 0.85rem; }
#ancientSocietySenet .turn-status{ text-align: center; display: grid; place-content: center; gap: 3px; min-height: 64px; }
#ancientSocietySenet .turn-status strong{ color: var(--ivory); }
#ancientSocietySenet .turn-status span{ color: var(--muted); font-size: 0.9rem; }

#ancientSocietySenet .board-wrap{
  overflow-x: auto;
  padding: 10px 3px 16px;
}

#ancientSocietySenet .senet-board{
  width: min(100%, 930px);
  min-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(3, 88px);
  border: 8px solid #3f2a1a;
  outline: 2px solid rgba(181,148,86,0.72);
  box-shadow: inset 0 0 28px rgba(0,0,0,0.45), 0 16px 35px rgba(0,0,0,0.25);
  background: #4b311d;
}

#ancientSocietySenet .house{
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(49,31,17,0.85);
  background:
    linear-gradient(rgba(255,255,255,0.035), rgba(0,0,0,0.04)),
    var(--wood-2);
  user-select: none;
}

#ancientSocietySenet .house:nth-child(odd){ background-color: var(--wood-1); }
#ancientSocietySenet .house::after{
  content: attr(data-label);
  position: absolute;
  right: 6px;
  bottom: 4px;
  color: rgba(234,223,195,0.38);
  font: 11px/1 Arial, sans-serif;
}

#ancientSocietySenet .house.special{ background: linear-gradient(rgba(104,166,161,0.10), rgba(0,0,0,0.03)), var(--wood-2); }
#ancientSocietySenet .house[data-square="26"]::before{ content: "nfr"; color: var(--gold); font-size: 1.1rem; letter-spacing: 0.08em; position: absolute; top: 8px; left: 9px; }
#ancientSocietySenet .house[data-square="27"]::before{ content: "≋"; color: #9cc9d0; font-size: 1.8rem; position: absolute; top: 1px; left: 10px; }
#ancientSocietySenet .house[data-square="28"]::before{ content: "III"; color: var(--ivory); font-size: 0.86rem; position: absolute; top: 8px; left: 9px; letter-spacing: 0.08em; }
#ancientSocietySenet .house[data-square="29"]::before{ content: "II"; color: var(--ivory); font-size: 0.86rem; position: absolute; top: 8px; left: 9px; letter-spacing: 0.08em; }
#ancientSocietySenet .house[data-square="30"]::before{ content: "☀"; color: var(--gold); font-size: 1.25rem; position: absolute; top: 5px; left: 9px; }

#ancientSocietySenet .house.legal-move{
  cursor: pointer;
  box-shadow: inset 0 0 0 4px rgba(208,169,94,0.88), inset 0 0 24px rgba(208,169,94,0.22);
}
#ancientSocietySenet .house.legal-move:hover{ filter: brightness(1.12); }

#ancientSocietySenet .piece{
  position: relative;
  z-index: 2;
  width: 38px;
  height: 52px;
  filter: drop-shadow(0 7px 5px rgba(0,0,0,0.32));
  transition: transform 180ms ease, filter 180ms ease;
}
#ancientSocietySenet .piece.human{
  clip-path: polygon(50% 0%, 78% 18%, 88% 100%, 12% 100%, 22% 18%);
  background: linear-gradient(90deg, #d7c9a6, #fff7df 48%, #c7b58c);
}
#ancientSocietySenet .piece.cpu{
  width: 48px;
  height: 36px;
  border-radius: 50% 50% 28% 28%;
  background: linear-gradient(90deg, #3f746f, #78b6af 48%, #315d59);
  border: 2px solid rgba(234,223,195,0.36);
}
#ancientSocietySenet .house.legal-move .piece.human{ transform: translateY(-3px); filter: drop-shadow(0 7px 8px rgba(208,169,94,0.65)); }

#ancientSocietySenet .controls{
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  margin-top: 6px;
}

#ancientSocietySenet .sticks{ display: flex; gap: 7px; align-items: center; min-height: 48px; }
#ancientSocietySenet .stick{
  width: 68px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.35);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 300ms ease;
}
#ancientSocietySenet .stick.light{ background: #e3d5b2; }
#ancientSocietySenet .stick.dark{ background: #4f351f; }
#ancientSocietySenet .sticks.casting .stick:nth-child(1){ transform: translateY(-12px) rotate(18deg); }
#ancientSocietySenet .sticks.casting .stick:nth-child(2){ transform: translateY(8px) rotate(-16deg); }
#ancientSocietySenet .sticks.casting .stick:nth-child(3){ transform: translateY(-8px) rotate(-11deg); }
#ancientSocietySenet .sticks.casting .stick:nth-child(4){ transform: translateY(10px) rotate(14deg); }

#ancientSocietySenet .cast-result{ min-width: 62px; text-align: center; }
#ancientSocietySenet .cast-result span{ display: block; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
#ancientSocietySenet .cast-result strong{ display: block; font-size: 1.7rem; line-height: 1; }

#ancientSocietySenet .primary-button, #ancientSocietySenet .secondary-button{
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  border: 1px solid rgba(208,169,94,0.7);
}
#ancientSocietySenet .primary-button{ background: var(--gold); color: #24180f; font-weight: 700; }
#ancientSocietySenet .primary-button:disabled{ opacity: 0.45; cursor: not-allowed; }
#ancientSocietySenet .secondary-button{ background: transparent; color: var(--ivory); }

#ancientSocietySenet .legend{
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.86rem;
}
#ancientSocietySenet .legend > span{ display: inline-flex; align-items: center; gap: 7px; }
#ancientSocietySenet .legend-piece{ display: inline-block; }
#ancientSocietySenet .legend-piece.cone{ width: 12px; height: 18px; background: var(--ivory); clip-path: polygon(50% 0, 88% 100%, 12% 100%); }
#ancientSocietySenet .legend-piece.spool{ width: 17px; height: 12px; background: var(--turquoise); border-radius: 50%; }
#ancientSocietySenet .legend-dot{ width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gold); }


#ancientSocietySenet .game-options{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

#ancientSocietySenet .game-options label{ color: var(--ivory); }

#ancientSocietySenet .game-options select{
  appearance: none;
  border: 1px solid rgba(208,169,94,0.55);
  border-radius: 999px;
  background: #1d1811;
  color: var(--ivory);
  padding: 8px 34px 8px 13px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 16px) 13px, calc(100% - 11px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

#ancientSocietySenet .history-panel{
  margin-top: 18px;
  border: 1px solid rgba(234,223,195,0.12);
  border-radius: 12px;
  background: rgba(0,0,0,0.10);
  overflow: hidden;
}

#ancientSocietySenet .history-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid rgba(234,223,195,0.10);
}

#ancientSocietySenet .history-header h2{
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

#ancientSocietySenet .history-header span{
  color: var(--muted);
  font-size: 0.76rem;
}

#ancientSocietySenet .move-history{
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 188px;
  overflow-y: auto;
}

#ancientSocietySenet .move-history li{
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  padding: 8px 13px;
  border-bottom: 1px solid rgba(234,223,195,0.07);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

#ancientSocietySenet .move-history li:last-child{ border-bottom: 0; }
#ancientSocietySenet .move-history .who{ color: var(--gold); }
#ancientSocietySenet .move-history .human-entry .who{ color: var(--ivory); }

@keyframes waterPulse {
  0%, 100%{ box-shadow: inset 0 0 0 1px rgba(208,169,94,0.18); }
  40%{ box-shadow: inset 0 0 0 5px rgba(126,192,205,0.9), inset 0 0 36px rgba(126,192,205,0.55); filter: brightness(1.18); }
}

@keyframes beautyPulse {
  0%, 100%{ box-shadow: inset 0 0 0 1px rgba(208,169,94,0.18); }
  45%{ box-shadow: inset 0 0 0 5px rgba(208,169,94,0.9), inset 0 0 40px rgba(208,169,94,0.45); filter: brightness(1.16); }
}

@keyframes exitPulse {
  0%{ outline-color: rgba(181,148,86,0.72); }
  40%{ outline-color: rgba(234,223,195,1); box-shadow: inset 0 0 45px rgba(208,169,94,0.22), 0 16px 45px rgba(208,169,94,0.26); }
  100%{ outline-color: rgba(181,148,86,0.72); }
}

#ancientSocietySenet .house.water-flash{ animation: waterPulse 900ms ease; }
#ancientSocietySenet .house.beauty-flash{ animation: beautyPulse 900ms ease; }
#ancientSocietySenet .senet-board.exit-flash{ animation: exitPulse 850ms ease; }

#ancientSocietySenet .notes{ margin-top: 18px; border-top: 1px solid rgba(234,223,195,0.12); padding-top: 14px; color: var(--muted); }
#ancientSocietySenet .notes summary{ cursor: pointer; color: var(--ivory); }
#ancientSocietySenet .notes p{ line-height: 1.6; }

@media (max-width: 760px) {
  #ancientSocietySenet .status-row{ grid-template-columns: 1fr 1fr; }
  #ancientSocietySenet .turn-status{ grid-column: 1 / -1; grid-row: 1; }
  #ancientSocietySenet .player-card{ grid-row: 2; }
  #ancientSocietySenet .game-options{ justify-content: center; }
  #ancientSocietySenet .controls{ grid-template-columns: 1fr 1fr; }
  #ancientSocietySenet .sticks{ grid-column: 1 / -1; justify-content: center; }
  #ancientSocietySenet .cast-result{ order: 2; }
  #ancientSocietySenet .primary-button{ order: 3; }
  #ancientSocietySenet .secondary-button{ order: 4; }
}

/* v0.2: special houses and reconstruction guide */
#ancientSocietySenet .house[data-square="15"]::before{
  content: "☥";
  color: var(--gold);
  font-size: 1.5rem;
  position: absolute;
  top: 3px;
  left: 9px;
}

#ancientSocietySenet .house[data-square="30"]::before{ content: "☉"; }

#ancientSocietySenet .house.special{
  box-shadow: inset 0 0 0 1px rgba(208,169,94,0.18);
}

#ancientSocietySenet .special-houses{
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(234,223,195,0.12);
}

#ancientSocietySenet .special-houses h2{
  margin: 0 0 5px;
  color: var(--ivory);
  font-size: 1.08rem;
  font-weight: 500;
}

#ancientSocietySenet .special-houses-intro{
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

#ancientSocietySenet .house-guide-buttons{
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

#ancientSocietySenet .house-guide-button{
  border: 1px solid rgba(234,223,195,0.16);
  border-radius: 9px;
  background: rgba(0,0,0,0.13);
  color: var(--muted);
  padding: 9px 7px;
  cursor: pointer;
  line-height: 1.15;
}

#ancientSocietySenet .house-guide-button strong{
  display: block;
  color: var(--gold);
  font-size: 0.8rem;
  margin-bottom: 3px;
}

#ancientSocietySenet .house-guide-button span{
  font-size: 0.74rem;
}

#ancientSocietySenet .house-guide-button:hover, #ancientSocietySenet .house-guide-button.is-selected{
  border-color: rgba(208,169,94,0.68);
  color: var(--ivory);
  background: rgba(208,169,94,0.08);
}

#ancientSocietySenet .house-info-panel{
  margin-top: 10px;
  min-height: 84px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 13px;
  align-items: center;
  border: 1px solid rgba(104,166,161,0.22);
  border-radius: 11px;
  background: rgba(0,0,0,0.11);
  padding: 12px 14px;
}

#ancientSocietySenet .house-info-symbol{
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(208,169,94,0.35);
  border-radius: 8px;
  color: var(--gold);
  font-size: 1.45rem;
}

#ancientSocietySenet .house-info-panel h3{
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 600;
}

#ancientSocietySenet .house-info-panel p{
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.87rem;
}

#ancientSocietySenet .reconstruction-note{
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

#ancientSocietySenet .notes p + p{ margin-top: 10px; }
#ancientSocietySenet .notes strong{ color: var(--ivory); }

@media (max-width: 760px) {
  #ancientSocietySenet .house-guide-buttons{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* v0.4 movement, passed-piece trays, and victory presentation */
#ancientSocietySenet .board-wrap{ position: relative; }
#ancientSocietySenet .motion-layer{ position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: visible; }
#ancientSocietySenet .motion-piece{ position: absolute; margin: 0; transition: left 180ms ease, top 180ms ease, transform 180ms ease; }
#ancientSocietySenet .piece.motion-hidden{ opacity: 0; }

#ancientSocietySenet .move-tooltip{
  position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  z-index: 6; white-space: nowrap; padding: 3px 6px; border-radius: 999px;
  background: rgba(20,16,11,.88); color: var(--ivory); font: 10px/1.1 Arial,sans-serif;
  opacity: 0; pointer-events: none; transition: opacity 140ms ease;
}
#ancientSocietySenet .house.legal-move:hover .move-tooltip, #ancientSocietySenet .house.legal-move:focus .move-tooltip{ opacity: 1; }

#ancientSocietySenet .passed-row{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 2px 0 16px; }
#ancientSocietySenet .passed-tray{ min-height: 58px; border: 1px solid rgba(234,223,195,.12); border-radius: 10px; padding: 8px 10px; background: rgba(0,0,0,.1); }
#ancientSocietySenet .cpu-tray{ text-align: right; }
#ancientSocietySenet .passed-label{ display: block; color: var(--muted); font-size: .73rem; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
#ancientSocietySenet .passed-pieces{ display: flex; align-items: end; gap: 6px; min-height: 28px; }
#ancientSocietySenet .cpu-tray .passed-pieces{ justify-content: flex-end; }
#ancientSocietySenet .passed-pieces .piece{ position: relative; transform: scale(.62); transform-origin: center bottom; margin: -10px -7px -8px; }

@keyframes waterReturn { 0%,100%{ filter: brightness(1); } 50%{ filter: brightness(1.45); transform: scale(1.08); } }
#ancientSocietySenet .motion-piece.water-return{ animation: waterReturn 520ms ease; }

#ancientSocietySenet .victory-overlay{ position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: rgba(10,8,5,.78); backdrop-filter: blur(4px); }
#ancientSocietySenet .victory-overlay[hidden]{ display: none; }
#ancientSocietySenet .victory-card{ width: min(470px,100%); text-align: center; border: 1px solid rgba(208,169,94,.8); border-radius: 18px; padding: 30px 24px; background: linear-gradient(145deg,#2d2418,#17120c); box-shadow: 0 30px 80px rgba(0,0,0,.55); }
#ancientSocietySenet .victory-symbol{ font-size: 3rem; color: var(--gold); margin-bottom: 5px; }
#ancientSocietySenet .victory-card h2{ margin: 7px 0 10px; font-size: clamp(2rem,6vw,3.4rem); font-weight: 500; }
#ancientSocietySenet .victory-card p:not(.eyebrow){ color: var(--muted); line-height: 1.55; margin: 0 auto 20px; }

@keyframes castStickV4 { 0%{ transform: rotate(var(--tilt,0deg)); } 45%{ transform: translate(var(--throw-x,0),var(--throw-y,-16px)) rotate(var(--throw-spin,120deg)); } 100%{ transform: rotate(var(--tilt,0deg)); } }
#ancientSocietySenet .sticks.casting .stick{ animation: castStickV4 420ms ease; }

@media (prefers-reduced-motion: reduce) {
  #ancientSocietySenet .motion-piece, #ancientSocietySenet .stick, #ancientSocietySenet .piece{ transition: none !important; animation: none !important; }
}

/* v0.5 historical visual design, guide, display controls, and sound UI */
#ancientSocietySenet, body.senet-standalone-body{
  --ink: #17100a;
  --ebony: #21150d;
  --wood-dark: #3a2415;
  --wood-mid: #6f4727;
  --wood-light: #9a6a3c;
  --faience: #4ea4a0;
  --faience-light: #91d0c8;
  --faience-dark: #276d6c;
  --bone: #eadcb9;
  --bone-light: #fff5d9;
  --red-ochre: #9a4930;
}

body.senet-standalone-body{
  background:
    radial-gradient(circle at 50% -10%, rgba(201,161,86,.18), transparent 34rem),
    linear-gradient(rgba(9,6,4,.08), rgba(9,6,4,.08)),
    #130e09;
}

#ancientSocietySenet .senet-app{ width: min(1180px, calc(100% - 28px)); }

#ancientSocietySenet .game-header{ margin-bottom: 18px; }
#ancientSocietySenet .game-header h1{
  letter-spacing: .035em;
  text-shadow: 0 2px 18px rgba(208,169,94,.12);
}
#ancientSocietySenet .header-ornament{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: min(380px, 82%);
  margin: 13px auto 0;
  color: var(--gold);
}
#ancientSocietySenet .header-ornament span{
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(208,169,94,.72));
}
#ancientSocietySenet .header-ornament span:last-child{ background: linear-gradient(90deg, rgba(208,169,94,.72), transparent); }
#ancientSocietySenet .header-ornament i{ font-style: normal; font-size: 1.15rem; }

#ancientSocietySenet .game-shell{
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,.025), transparent 34%),
    #21190f;
  border-color: rgba(208,169,94,.58);
}
#ancientSocietySenet .game-shell::before, #ancientSocietySenet .game-shell::after{
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  opacity: .065;
  pointer-events: none;
  background:
    linear-gradient(45deg, transparent 43%, var(--gold) 44% 48%, transparent 49% 58%, var(--gold) 59% 63%, transparent 64%);
}
#ancientSocietySenet .game-shell::before{ left: -38px; top: -36px; transform: rotate(14deg); }
#ancientSocietySenet .game-shell::after{ right: -38px; bottom: -36px; transform: rotate(194deg); }

#ancientSocietySenet .game-tools{
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: -2px 0 17px;
}
#ancientSocietySenet .tool-button{
  border: 1px solid rgba(208,169,94,.33);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  background: rgba(0,0,0,.13);
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: .73rem;
  letter-spacing: .02em;
}
#ancientSocietySenet .tool-button:hover, #ancientSocietySenet .tool-button[aria-pressed="true"]{
  color: var(--bone-light);
  border-color: rgba(208,169,94,.72);
  background: rgba(208,169,94,.09);
}

#ancientSocietySenet .status-row{ position: relative; z-index: 2; }
#ancientSocietySenet .player-card, #ancientSocietySenet .turn-status{
  background: linear-gradient(rgba(255,255,255,.015), rgba(0,0,0,.1)), rgba(0,0,0,.12);
}
#ancientSocietySenet .player-card.is-active{ background: rgba(208,169,94,.055); }

#ancientSocietySenet .board-stage{
  position: relative;
  margin: 3px 0 13px;
  padding: 13px 13px 9px;
  border: 1px solid rgba(208,169,94,.22);
  border-radius: 13px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.018), transparent 20% 80%, rgba(255,255,255,.018)),
    rgba(0,0,0,.105);
}
#ancientSocietySenet .board-caption{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: #9f9073;
  text-align: center;
  font: 10px/1.3 Arial, sans-serif;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin: 0 0 6px;
}
#ancientSocietySenet .caption-mark{ color: rgba(208,169,94,.72); font-size: 1rem; }

#ancientSocietySenet .board-wrap{ padding: 11px 12px 22px; }
#ancientSocietySenet .board-wrap::before, #ancientSocietySenet .board-wrap::after{
  content: "";
  position: absolute;
  z-index: 0;
  left: 3.5%;
  right: 3.5%;
  height: 9px;
  border-radius: 50%;
  background: rgba(0,0,0,.42);
  filter: blur(8px);
  pointer-events: none;
}
#ancientSocietySenet .board-wrap::before{ top: 12px; opacity: .22; }
#ancientSocietySenet .board-wrap::after{ bottom: 8px; }

#ancientSocietySenet .senet-board{
  position: relative;
  z-index: 1;
  width: min(100%, 960px);
  grid-template-rows: repeat(3, 90px);
  border: 14px solid var(--wood-dark);
  outline: 2px solid #a47843;
  border-radius: 5px;
  background: var(--wood-dark);
  box-shadow:
    inset 0 0 0 2px rgba(255,225,167,.08),
    inset 0 0 32px rgba(0,0,0,.55),
    0 7px 0 #24160d,
    0 16px 28px rgba(0,0,0,.38);
}
#ancientSocietySenet .senet-board::before{
  content: "";
  position: absolute;
  pointer-events: none;
  inset: -10px;
  border: 1px solid rgba(219,183,111,.34);
  box-shadow: inset 0 0 0 3px rgba(35,20,11,.38);
  z-index: 7;
}

#ancientSocietySenet .house, #ancientSocietySenet .house:nth-child(odd), #ancientSocietySenet .house.special{
  border: 1px solid rgba(49,31,17,.78);
  background:
    radial-gradient(circle at 28% 23%, rgba(255,255,255,.17), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,.05), transparent 48%),
    var(--faience);
  box-shadow:
    inset 0 0 0 2px rgba(218,244,231,.08),
    inset 0 -8px 14px rgba(18,68,66,.16);
}
#ancientSocietySenet .house:nth-child(4n/**/+2), #ancientSocietySenet .house:nth-child(4n/**/+3){
  background:
    radial-gradient(circle at 28% 23%, rgba(255,255,255,.15), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,.045), transparent 48%),
    #5aa9a3;
}
#ancientSocietySenet .house:nth-child(5n){
  background:
    radial-gradient(circle at 28% 23%, rgba(255,255,255,.12), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,.04), transparent 48%),
    #4b9592;
}
#ancientSocietySenet .house.special{
  background:
    radial-gradient(circle at 50% 35%, rgba(255,247,217,.20), transparent 32%),
    linear-gradient(135deg, rgba(255,255,255,.07), transparent 48%),
    #78b9ad;
  box-shadow:
    inset 0 0 0 3px rgba(224,206,153,.19),
    inset 0 -10px 18px rgba(21,69,65,.16);
}

#ancientSocietySenet .house::after{
  opacity: 0;
  right: 5px;
  bottom: 4px;
  color: rgba(27,22,15,.62);
  font-size: 10px;
  font-weight: 700;
  transition: opacity 160ms ease;
}
#ancientSocietySenet .senet-app.show-house-numbers .house::after{ opacity: .78; }

/* v0.5 uses real child elements for special-house glyphs. */
#ancientSocietySenet .house[data-square="15"]::before, #ancientSocietySenet .house[data-square="26"]::before, #ancientSocietySenet .house[data-square="27"]::before, #ancientSocietySenet .house[data-square="28"]::before, #ancientSocietySenet .house[data-square="29"]::before, #ancientSocietySenet .house[data-square="30"]::before{ content: none !important; }
#ancientSocietySenet .house-glyph{
  position: absolute;
  inset: 6px 7px auto auto;
  z-index: 1;
  min-width: 24px;
  text-align: right;
  color: #43301b;
  font-size: 1.24rem;
  line-height: 1;
  text-shadow: 0 1px rgba(255,255,255,.22);
  pointer-events: none;
}
#ancientSocietySenet .house-glyph.glyph-nefer{ font-size: 1.56rem; }
#ancientSocietySenet .house-glyph.glyph-water{ color: #244f5b; font-size: 1.7rem; letter-spacing: -.09em; }
#ancientSocietySenet .house-glyph.glyph-count{ font: 800 1rem/1 Georgia, serif; letter-spacing: .12em; }
#ancientSocietySenet .house-glyph.glyph-horus{ color: #72522b; font-size: 1.42rem; }
#ancientSocietySenet .house-name-mini{
  position: absolute;
  z-index: 1;
  left: 6px;
  bottom: 5px;
  color: rgba(34,25,15,.62);
  font: 700 8px/1 Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: .05em;
  pointer-events: none;
}
#ancientSocietySenet .senet-app.show-house-numbers .house-name-mini{ bottom: 16px; }

#ancientSocietySenet .house.legal-move{
  box-shadow:
    inset 0 0 0 4px rgba(255,224,137,.9),
    inset 0 0 28px rgba(255,225,157,.42),
    0 0 14px rgba(208,169,94,.16);
}
#ancientSocietySenet .house.legal-move:hover{ filter: brightness(1.08) saturate(1.05); }

#ancientSocietySenet .piece{
  filter: drop-shadow(0 7px 5px rgba(0,0,0,.4));
}
#ancientSocietySenet .piece.human{
  width: 39px;
  height: 54px;
  clip-path: polygon(50% 0%, 70% 10%, 82% 30%, 89% 100%, 11% 100%, 18% 30%, 30% 10%);
  background:
    linear-gradient(90deg, rgba(112,83,50,.28), transparent 19% 68%, rgba(84,57,32,.28)),
    radial-gradient(circle at 45% 17%, #fff8df 0 14%, transparent 15%),
    linear-gradient(90deg, #cdbb91, #f6e9c8 42%, #fff5da 58%, #bba77d);
  border-bottom: 2px solid rgba(72,49,27,.28);
}
#ancientSocietySenet .piece.human::after{
  content: "";
  position: absolute;
  left: 15%; right: 15%; bottom: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(110,82,49,.24);
}
#ancientSocietySenet .piece.cpu{
  width: 50px;
  height: 38px;
  border-radius: 44% 44% 28% 28% / 40% 40% 24% 24%;
  background:
    linear-gradient(90deg, rgba(16,57,55,.34), transparent 19% 68%, rgba(13,48,46,.4)),
    radial-gradient(ellipse at 50% 12%, #9ed8cc 0 30%, #5fa9a1 32% 62%, transparent 64%),
    linear-gradient(90deg, #2d6f6b, #78bbb1 44%, #8bcabd 56%, #245c59);
  border: 2px solid rgba(226,222,183,.3);
  box-shadow: inset 0 -4px 8px rgba(14,49,47,.28);
}
#ancientSocietySenet .piece.cpu::before, #ancientSocietySenet .piece.cpu::after{
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid rgba(219,229,195,.2);
}
#ancientSocietySenet .piece.cpu::before{ top: 4px; }
#ancientSocietySenet .piece.cpu::after{ bottom: 4px; }

#ancientSocietySenet .sticks{
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,.07);
}
#ancientSocietySenet .stick{
  position: relative;
  height: 13px;
  border-color: rgba(63,39,20,.5);
  box-shadow: 0 3px 5px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.18);
}
#ancientSocietySenet .stick.light{
  background:
    repeating-linear-gradient(90deg, transparent 0 13px, rgba(126,87,45,.11) 14px 15px),
    linear-gradient(#f1e4c6, #cfbb91);
}
#ancientSocietySenet .stick.dark{
  background:
    repeating-linear-gradient(90deg, transparent 0 13px, rgba(224,190,122,.08) 14px 15px),
    linear-gradient(#65442a, #3f2818);
}
#ancientSocietySenet .stick::after{
  content: "";
  position: absolute;
  right: -1px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50% 50% 50% 15%;
  background: rgba(68,42,22,.28);
  transform: rotate(45deg);
}

#ancientSocietySenet .primary-button{
  background: linear-gradient(#e1be72, #bc8e40);
  border-color: #e3c37c;
  box-shadow: inset 0 1px rgba(255,255,255,.28), 0 4px 10px rgba(0,0,0,.18);
}
#ancientSocietySenet .primary-button:hover:not(:disabled){ filter: brightness(1.06); }

#ancientSocietySenet .passed-tray{
  background:
    linear-gradient(90deg, rgba(104,166,161,.045), transparent 36%),
    rgba(0,0,0,.1);
}
#ancientSocietySenet .cpu-tray{ background: linear-gradient(270deg, rgba(104,166,161,.05), transparent 36%), rgba(0,0,0,.1); }

#ancientSocietySenet .special-houses{ position: relative; z-index: 2; }
#ancientSocietySenet .house-guide-button strong{ font-size: .86rem; }
#ancientSocietySenet .house-info-symbol{
  background: radial-gradient(circle at 40% 30%, rgba(255,255,255,.08), transparent 60%), rgba(104,166,161,.055);
}

#ancientSocietySenet .source-strip{
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(210px, .8fr);
  gap: 20px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid rgba(208,169,94,.19);
  border-radius: 12px;
  background: rgba(0,0,0,.11);
}
#ancientSocietySenet .source-strip h2{ margin: 4px 0 6px; font-size: 1.05rem; font-weight: 500; }
#ancientSocietySenet .source-strip p:not(.eyebrow){ margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
#ancientSocietySenet .source-links{ display: grid; gap: 7px; align-content: center; }
#ancientSocietySenet .source-links a{
  color: var(--bone);
  text-decoration: none;
  border: 1px solid rgba(104,166,161,.26);
  border-radius: 8px;
  padding: 9px 10px;
  font: 12px/1.35 Arial, sans-serif;
  background: rgba(104,166,161,.045);
}
#ancientSocietySenet .source-links a:hover{ border-color: rgba(104,166,161,.58); color: var(--bone-light); }

#ancientSocietySenet .guide-dialog{
  width: min(830px, calc(100% - 28px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid rgba(208,169,94,.76);
  border-radius: 17px;
  color: var(--ivory);
  background: #1a130c;
  box-shadow: 0 34px 100px rgba(0,0,0,.72);
}
#ancientSocietySenet .guide-dialog::backdrop{ background: rgba(8,6,4,.79); backdrop-filter: blur(3px); }
#ancientSocietySenet .guide-frame{
  position: relative;
  max-height: min(86vh, 760px);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 34px);
  background:
    linear-gradient(135deg, rgba(208,169,94,.045), transparent 28%),
    radial-gradient(circle at 100% 0, rgba(104,166,161,.075), transparent 28rem),
    #1e160e;
}
#ancientSocietySenet .guide-frame::before{
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  border: 1px solid rgba(208,169,94,.18);
  border-radius: 10px;
}
#ancientSocietySenet .dialog-close{
  position: sticky;
  float: right;
  top: 0;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(208,169,94,.38);
  background: #23190f;
  color: var(--ivory);
  cursor: pointer;
  font: 22px/1 Arial, sans-serif;
}
#ancientSocietySenet .guide-heading{ padding-right: 46px; }
#ancientSocietySenet .guide-heading h2{ margin: 4px 0 7px; font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 500; }
#ancientSocietySenet .guide-heading > p:last-child{ margin: 0; color: var(--muted); line-height: 1.5; }
#ancientSocietySenet .guide-tabs{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 17px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(234,223,195,.11);
}
#ancientSocietySenet .guide-tabs button{
  border: 1px solid rgba(234,223,195,.14);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 7px 11px;
  cursor: pointer;
  font: 12px/1 Arial, sans-serif;
}
#ancientSocietySenet .guide-tabs button[aria-selected="true"]{
  color: #20150d;
  border-color: var(--gold);
  background: var(--gold);
}
#ancientSocietySenet .guide-page{ display: none; }
#ancientSocietySenet .guide-page.is-active{ display: block; }
#ancientSocietySenet .rule-cards{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
#ancientSocietySenet .rule-cards article, #ancientSocietySenet .mini-house-grid article{
  position: relative;
  border: 1px solid rgba(234,223,195,.11);
  border-radius: 11px;
  padding: 14px;
  background: rgba(0,0,0,.095);
}
#ancientSocietySenet .rule-number{
  float: left;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin: 0 9px 5px 0;
  border-radius: 50%;
  color: #23180f;
  background: var(--gold);
  font: 700 12px/1 Arial, sans-serif;
}
#ancientSocietySenet .rule-cards h3, #ancientSocietySenet .mini-house-grid h3, #ancientSocietySenet .evidence-list h3{ margin: 2px 0 5px; font-size: .95rem; font-weight: 600; }
#ancientSocietySenet .rule-cards p, #ancientSocietySenet .mini-house-grid p, #ancientSocietySenet .evidence-list p, #ancientSocietySenet .history-story p{ margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
#ancientSocietySenet .throw-key{
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 6px;
  margin-top: 12px;
}
#ancientSocietySenet .throw-key span{
  text-align: center;
  padding: 8px 5px;
  border-radius: 7px;
  background: rgba(104,166,161,.065);
  color: var(--muted);
  font: 11px/1.35 Arial, sans-serif;
}
#ancientSocietySenet .throw-key b{ color: var(--bone); }
#ancientSocietySenet .mini-house-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 9px;
}
#ancientSocietySenet .mini-house-grid article > span{
  position: absolute;
  right: 8px;
  top: 8px;
  color: #82765f;
  font: 700 10px/1 Arial, sans-serif;
}
#ancientSocietySenet .mini-house-grid article > b{
  display: block;
  color: var(--gold);
  font-size: 1.55rem;
  margin-bottom: 6px;
}
#ancientSocietySenet .guide-caution{
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(208,169,94,.68);
  background: rgba(208,169,94,.05);
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
}
#ancientSocietySenet .history-story{
  columns: 2 260px;
  column-gap: 28px;
}
#ancientSocietySenet .history-story p{ break-inside: avoid; margin-bottom: 13px; }
#ancientSocietySenet .evidence-list{ display: grid; gap: 9px; }
#ancientSocietySenet .evidence-list article{
  display: grid;
  grid-template-columns: 15px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(234,223,195,.1);
  border-radius: 10px;
  background: rgba(0,0,0,.08);
}
#ancientSocietySenet .evidence-dot{ width: 11px; height: 11px; border-radius: 50%; margin-top: 5px; }
#ancientSocietySenet .evidence-dot.secure{ background: #8fbf9a; }
#ancientSocietySenet .evidence-dot.strong{ background: #d0a95e; }
#ancientSocietySenet .evidence-dot.reconstructed{ background: #a87c68; }

#ancientSocietySenet .victory-card{
  background:
    radial-gradient(circle at 50% 0, rgba(208,169,94,.12), transparent 16rem),
    linear-gradient(145deg,#2d2418,#17120c);
}
#ancientSocietySenet .victory-symbol{ text-shadow: 0 0 24px rgba(208,169,94,.2); }

@media (max-width: 760px) {
  #ancientSocietySenet .game-tools{ margin-bottom: 14px; }
  #ancientSocietySenet .board-stage{ padding-left: 6px; padding-right: 6px; }
  #ancientSocietySenet .board-caption{ font-size: 8px; gap: 6px; }
  #ancientSocietySenet .source-strip{ grid-template-columns: 1fr; }
  #ancientSocietySenet .rule-cards{ grid-template-columns: 1fr; }
  #ancientSocietySenet .throw-key{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  #ancientSocietySenet .mini-house-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 480px) {
  #ancientSocietySenet .game-tools{ justify-content: stretch; }
  #ancientSocietySenet .tool-button{ flex: 1 1 42%; }
  #ancientSocietySenet .mini-house-grid{ grid-template-columns: 1fr; }
  #ancientSocietySenet .house-guide-buttons{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* v0.6 setup, reconstruction variants, and ISAC water choice */
#ancientSocietySenet .game-options{
  justify-content: space-between;
  flex-wrap: wrap;
}
#ancientSocietySenet .difficulty-control{ display: flex; align-items: center; gap: 10px; }
#ancientSocietySenet .variant-chip{
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid rgba(104,166,161,.28);
  border-radius: 999px;
  background: rgba(104,166,161,.055);
  color: inherit;
  font: 12px/1.2 Arial, sans-serif;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
#ancientSocietySenet .variant-chip:hover{
  border-color: rgba(208,169,94,.68);
  background: rgba(208,169,94,.09);
}
#ancientSocietySenet .variant-chip:active{ transform: translateY(1px); }
#ancientSocietySenet .variant-chip:focus-visible{
  outline: 3px solid rgba(208,169,94,.72);
  outline-offset: 3px;
}
#ancientSocietySenet .variant-chip span{ color: #93bdb8; text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }
#ancientSocietySenet .variant-chip strong{ color: var(--bone-light, var(--ivory)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#ancientSocietySenet .setup-dialog{
  width: min(930px, calc(100% - 28px));
  max-height: min(90vh, 820px);
  padding: 0;
  border: 1px solid rgba(208,169,94,.78);
  border-radius: 17px;
  color: var(--ivory);
  background: #1a130c;
  box-shadow: 0 34px 100px rgba(0,0,0,.72);
}
#ancientSocietySenet .setup-dialog::backdrop{ background: rgba(8,6,4,.82); backdrop-filter: blur(4px); }
#ancientSocietySenet .setup-frame{
  position: relative;
  max-height: min(90vh, 820px);
  overflow-y: auto;
  padding: clamp(22px, 4vw, 36px);
  background:
    linear-gradient(135deg, rgba(208,169,94,.05), transparent 30%),
    radial-gradient(circle at 100% 0, rgba(104,166,161,.09), transparent 30rem),
    #1e160e;
}
#ancientSocietySenet .setup-frame::before{
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  border: 1px solid rgba(208,169,94,.18);
  border-radius: 10px;
}
#ancientSocietySenet .setup-heading{ padding-right: 50px; }
#ancientSocietySenet .setup-heading h2{ margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 500; }
#ancientSocietySenet .setup-heading > p:last-child{ max-width: 720px; margin: 0; color: var(--muted); line-height: 1.55; }
#ancientSocietySenet .ruleset-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin: 24px 0 18px;
}
#ancientSocietySenet .ruleset-card{
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 230px;
  padding: 18px;
  border: 1px solid rgba(234,223,195,.14);
  border-radius: 13px;
  background: rgba(0,0,0,.12);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
#ancientSocietySenet .ruleset-card:hover{ border-color: rgba(208,169,94,.46); transform: translateY(-1px); }
#ancientSocietySenet .ruleset-card.is-selected{
  border-color: rgba(208,169,94,.9);
  background: linear-gradient(145deg, rgba(208,169,94,.08), rgba(104,166,161,.035));
  box-shadow: inset 0 0 0 1px rgba(208,169,94,.11);
}
#ancientSocietySenet .ruleset-card input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
#ancientSocietySenet .ruleset-kicker{
  width: max-content;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .11em;
  font: 9px/1 Arial, sans-serif;
}
#ancientSocietySenet .ruleset-card strong{ color: var(--ivory); font-size: 1.05rem; font-weight: 500; line-height: 1.25; }
#ancientSocietySenet .ruleset-card > span:not(.ruleset-kicker){ color: #92bcb7; font: 11px/1.2 Arial, sans-serif; }
#ancientSocietySenet .ruleset-card p{ margin: 4px 0 0; color: var(--muted); font: 13px/1.55 Arial, sans-serif; }
#ancientSocietySenet .setup-options{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid rgba(234,223,195,.1);
  border-bottom: 1px solid rgba(234,223,195,.1);
}
#ancientSocietySenet .setup-options label{ color: var(--ivory); font-size: .9rem; }
#ancientSocietySenet .setup-options select{
  appearance: none;
  margin-left: auto;
  border: 1px solid rgba(208,169,94,.55);
  border-radius: 999px;
  background: #17110b;
  color: var(--ivory);
  padding: 9px 34px 9px 13px;
}
#ancientSocietySenet .setup-detail{
  margin-top: 14px;
  padding: 14px 16px;
  border-left: 3px solid rgba(104,166,161,.62);
  background: rgba(104,166,161,.045);
}
#ancientSocietySenet .setup-detail strong{ color: var(--ivory); font-weight: 500; }
#ancientSocietySenet .setup-detail p{ margin: 5px 0 0; color: var(--muted); font: 12px/1.55 Arial, sans-serif; }
#ancientSocietySenet .setup-footer{ display: flex; justify-content: flex-end; margin-top: 18px; }

#ancientSocietySenet .water-choice{
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid rgba(105,170,180,.58);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(47,114,128,.16), rgba(0,0,0,.09));
  box-shadow: inset 0 0 25px rgba(62,143,157,.06);
}
#ancientSocietySenet .water-choice[hidden]{ display: none; }
#ancientSocietySenet .water-choice > div:first-child{ display: grid; gap: 3px; }
#ancientSocietySenet .water-choice strong{ color: #b5dadd; font-weight: 500; }
#ancientSocietySenet .water-choice span{ color: var(--muted); font: 12px/1.45 Arial, sans-serif; }
#ancientSocietySenet .water-choice-actions{ display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
#ancientSocietySenet .water-choice-actions .secondary-button, #ancientSocietySenet .water-choice-actions .primary-button{ white-space: nowrap; }

@media (max-width: 820px) {
  #ancientSocietySenet .ruleset-grid{ grid-template-columns: 1fr; }
  #ancientSocietySenet .ruleset-card{ min-height: 0; }
}
@media (max-width: 620px) {
  #ancientSocietySenet .game-options{ justify-content: center; }
  #ancientSocietySenet .variant-chip{ width: 100%; justify-content: center; }
  #ancientSocietySenet .difficulty-control{ width: 100%; justify-content: center; }
  #ancientSocietySenet .water-choice{ align-items: stretch; flex-direction: column; }
  #ancientSocietySenet .water-choice-actions{ justify-content: stretch; }
  #ancientSocietySenet .water-choice-actions button{ flex: 1 1 180px; }
  #ancientSocietySenet .setup-options{ align-items: stretch; flex-direction: column; }
  #ancientSocietySenet .setup-options select{ width: 100%; margin-left: 0; }
}
#ancientSocietySenet .variant-rule-note{
  margin: 0 0 13px;
  padding: 10px 12px;
  border: 1px solid rgba(104,166,161,.2);
  border-radius: 8px;
  background: rgba(104,166,161,.04);
  color: #b5cbc5;
  font: 12px/1.55 Arial, sans-serif;
}
#ancientSocietySenet .piece.is-trapped-water{
  filter: drop-shadow(0 0 10px rgba(91,190,207,.72)) drop-shadow(0 7px 5px rgba(0,0,0,.4));
  animation: trappedWaterPulse 1.6s ease-in-out infinite;
}
@keyframes trappedWaterPulse {
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  #ancientSocietySenet .piece.is-trapped-water{ animation: none; }
}

/* v0.7 guided contextual tutorial */
#ancientSocietySenet .tutorial-setup-option{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  padding-left: 16px;
  border-left: 1px solid rgba(234,223,195,.1);
  cursor: pointer;
}
#ancientSocietySenet .tutorial-setup-option input{
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}
#ancientSocietySenet .tutorial-setup-option span{ display: grid; gap: 2px; }
#ancientSocietySenet .tutorial-setup-option strong{ color: var(--ivory); font: 600 12px/1.2 Arial, sans-serif; }
#ancientSocietySenet .tutorial-setup-option small{ color: var(--muted); font: 11px/1.35 Arial, sans-serif; }

#ancientSocietySenet .tutorial-coach{
  position: fixed;
  z-index: 60;
  right: max(16px, calc((100vw - 1120px) / 2));
  bottom: 18px;
  width: min(410px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(208,169,94,.78);
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(208,169,94,.07), transparent 38%),
    #1c150e;
  box-shadow: 0 24px 70px rgba(0,0,0,.58);
}
#ancientSocietySenet .tutorial-coach[hidden]{ display: none; }
#ancientSocietySenet .tutorial-coach-mark{
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(104,166,161,.48);
  border-radius: 50%;
  color: #9dc9c4;
  background: rgba(104,166,161,.08);
  font-size: 1.6rem;
}
#ancientSocietySenet .tutorial-coach-copy{ min-width: 0; }
#ancientSocietySenet .tutorial-kicker{
  display: block;
  margin-bottom: 3px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .12em;
  font: 9px/1.2 Arial, sans-serif;
}
#ancientSocietySenet .tutorial-coach h3{ margin: 0 0 5px; color: var(--ivory); font-size: 1.05rem; font-weight: 500; }
#ancientSocietySenet .tutorial-coach p{ margin: 0; color: var(--muted); font: 12.5px/1.5 Arial, sans-serif; }
#ancientSocietySenet .tutorial-actions{ display: flex; align-items: center; gap: 9px; margin-top: 12px; }
#ancientSocietySenet .tutorial-actions .primary-button{ padding: 8px 13px; font-size: .78rem; }
#ancientSocietySenet .tutorial-skip{
  border: 0;
  background: transparent;
  color: #a99a7d;
  padding: 7px 2px;
  cursor: pointer;
  font: 11px/1 Arial, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#ancientSocietySenet .tutorial-skip:hover{ color: var(--ivory); }

#ancientSocietySenet .tutorial-target{
  position: relative;
  z-index: 5;
  outline: 3px solid rgba(208,169,94,.9) !important;
  outline-offset: 4px;
  box-shadow: 0 0 0 7px rgba(208,169,94,.13), 0 0 24px rgba(208,169,94,.26) !important;
}
#ancientSocietySenet .house.tutorial-target{ z-index: 8; }
#ancientSocietySenet .sticks.tutorial-target{ border-radius: 10px; }
#ancientSocietySenet .passed-tray.tutorial-target{ border-radius: 12px; }

@media (max-width: 720px) {
  #ancientSocietySenet .setup-options{ align-items: stretch; flex-direction: column; }
  #ancientSocietySenet .setup-options select{ width: 100%; margin-left: 0; }
  #ancientSocietySenet .tutorial-setup-option{ margin-left: 0; padding: 12px 0 0; border-left: 0; border-top: 1px solid rgba(234,223,195,.1); }
  #ancientSocietySenet .tutorial-coach{ left: 14px; right: 14px; bottom: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  #ancientSocietySenet .tutorial-target{ box-shadow: 0 0 0 5px rgba(208,169,94,.12) !important; }
}

/* v0.8 production readiness: autosave, local record, resume flow, and tighter mobile layout */
#ancientSocietySenet .player-record{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "heading reset" "stats reset";
  gap: 9px 16px;
  align-items: center;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(234,223,195,.12);
  border-radius: 12px;
  background: rgba(0,0,0,.10);
}
#ancientSocietySenet .record-heading{ grid-area: heading; display: flex; align-items: center; gap: 12px; min-width: 0; }
#ancientSocietySenet .record-heading .eyebrow{ font-size: .68rem; }
#ancientSocietySenet .save-indicator{ color: var(--muted); font: 11px/1.3 Arial, sans-serif; }
#ancientSocietySenet .record-stats{ grid-area: stats; display: grid; grid-template-columns: repeat(5, minmax(62px, 1fr)); gap: 8px; }
#ancientSocietySenet .record-stats > div{ display: grid; gap: 1px; min-width: 0; }
#ancientSocietySenet .record-stats span{ color: var(--muted); font: 10px/1.25 Arial, sans-serif; text-transform: uppercase; letter-spacing: .07em; }
#ancientSocietySenet .record-stats strong{ color: var(--ivory); font-size: 1.02rem; font-weight: 500; font-variant-numeric: tabular-nums; }
#ancientSocietySenet .record-reset{ grid-area: reset; border: 0; padding: 7px 0; background: transparent; color: var(--muted); cursor: pointer; font: 11px/1.2 Arial, sans-serif; text-decoration: underline; text-underline-offset: 3px; }
#ancientSocietySenet .record-reset:hover{ color: var(--ivory); }

#ancientSocietySenet .resume-panel{
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid rgba(104,166,161,.5);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(104,166,161,.11), rgba(208,169,94,.06));
}
#ancientSocietySenet .resume-panel[hidden]{ display: none; }
#ancientSocietySenet .resume-panel > div:first-child{ display: grid; gap: 4px; }
#ancientSocietySenet .resume-kicker{ color: var(--turquoise); font: 700 10px/1.2 Arial, sans-serif; text-transform: uppercase; letter-spacing: .12em; }
#ancientSocietySenet .resume-panel strong{ color: var(--ivory); font-size: 1.05rem; font-weight: 500; }
#ancientSocietySenet .resume-panel p{ margin: 0; color: var(--muted); font: 12px/1.45 Arial, sans-serif; }
#ancientSocietySenet .resume-actions{ display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
#ancientSocietySenet .resume-actions .primary-button, #ancientSocietySenet .resume-actions .secondary-button{ white-space: nowrap; }

@media (max-width: 700px) {
  #ancientSocietySenet .player-record{ grid-template-columns: 1fr; grid-template-areas: "heading" "stats" "reset"; }
  #ancientSocietySenet .record-stats{ grid-template-columns: repeat(5, 1fr); }
  #ancientSocietySenet .record-reset{ justify-self: start; }
  #ancientSocietySenet .resume-panel{ grid-template-columns: 1fr; }
  #ancientSocietySenet .resume-actions{ justify-content: flex-start; }
}

@media (max-width: 600px) {
  #ancientSocietySenet .senet-app{ width: min(100% - 16px, 1100px); padding-top: 22px; padding-bottom: 38px; }
  #ancientSocietySenet .game-shell{ padding: 12px; border-radius: 14px; }
  #ancientSocietySenet .game-header{ margin-bottom: 15px; }
  #ancientSocietySenet .game-header h1{ font-size: clamp(2.25rem, 14vw, 3.2rem); }
  #ancientSocietySenet .subtitle{ font-size: .9rem; }
  #ancientSocietySenet .status-row{ grid-template-columns: 1fr 1fr; gap: 8px; }
  #ancientSocietySenet .turn-status{ grid-column: 1 / -1; grid-row: 1; min-height: 58px; }
  #ancientSocietySenet .player-card{ grid-row: 2; }
  #ancientSocietySenet .game-options{ align-items: stretch; flex-direction: column; }
  #ancientSocietySenet .difficulty-control{ justify-content: space-between; }
  #ancientSocietySenet .board-wrap{ overflow: visible; padding: 7px 0 12px; }
  #ancientSocietySenet .senet-board{ width: 100%; min-width: 0; grid-template-rows: repeat(3, minmax(48px, 13.7vw)); border-width: 5px; outline-width: 1px; }
  #ancientSocietySenet .house::after{ right: 2px; bottom: 2px; font-size: 8px; }
  #ancientSocietySenet .house-name-mini{ display: none; }
  #ancientSocietySenet .house-glyph{ font-size: clamp(.75rem, 3.2vw, 1.05rem); }
  #ancientSocietySenet .house[data-square="26"]::before, #ancientSocietySenet .house[data-square="28"]::before, #ancientSocietySenet .house[data-square="29"]::before{ left: 3px; top: 3px; font-size: .58rem; }
  #ancientSocietySenet .house[data-square="27"]::before, #ancientSocietySenet .house[data-square="30"]::before{ left: 3px; top: 1px; font-size: .9rem; }
  #ancientSocietySenet .piece.human{ width: 24px; height: 34px; }
  #ancientSocietySenet .piece.cpu{ width: 30px; height: 23px; border-width: 1px; }
  #ancientSocietySenet .controls{ grid-template-columns: 1fr auto; gap: 9px; }
  #ancientSocietySenet .sticks{ grid-column: 1 / -1; justify-content: center; min-height: 40px; }
  #ancientSocietySenet .stick{ width: min(18vw, 58px); height: 10px; }
  #ancientSocietySenet .cast-result{ justify-self: start; }
  #ancientSocietySenet .controls .primary-button, #ancientSocietySenet .controls .secondary-button{ min-height: 44px; padding-inline: 14px; }
  #ancientSocietySenet .legend{ gap: 10px 13px; }
  #ancientSocietySenet .passed-row{ gap: 8px; }
  #ancientSocietySenet .passed-tray{ min-height: 58px; }
  #ancientSocietySenet .record-stats{ grid-template-columns: repeat(3, 1fr); row-gap: 10px; }
  #ancientSocietySenet .game-tools{ gap: 6px; }
  #ancientSocietySenet .tool-button{ flex: 1 1 calc(50% - 6px); min-height: 38px; }
  #ancientSocietySenet .board-caption{ font-size: .66rem; }
  #ancientSocietySenet .house-guide-buttons{ grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 390px) {
  #ancientSocietySenet .record-stats{ grid-template-columns: repeat(2, 1fr); }
  #ancientSocietySenet .house-guide-buttons{ grid-template-columns: repeat(2, 1fr); }
  #ancientSocietySenet .resume-actions{ display: grid; grid-template-columns: 1fr; }
  #ancientSocietySenet .resume-actions button{ width: 100%; }
}


/* v0.9 production accessibility, keyboard, touch, and modal QA */
#ancientSocietySenet .senet-sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
#ancientSocietySenet .senet-skip-link{position:fixed;z-index:1000;left:12px;top:12px;transform:translateY(-180%);padding:10px 14px;border-radius:8px;background:#fff5d9;color:#17100a;font:700 14px/1.2 Arial,sans-serif;box-shadow:0 5px 20px rgba(0,0,0,.35)}
#ancientSocietySenet .senet-skip-link:focus{transform:translateY(0)}
#ancientSocietySenet :where(button,select,a,input,[tabindex]):focus-visible{outline:3px solid #f2d083;outline-offset:3px}
#ancientSocietySenet .house:focus-visible{outline:4px solid #f2d083;outline-offset:-5px;z-index:8}
#ancientSocietySenet .house.legal-move:focus-visible{box-shadow:inset 0 0 0 5px rgba(242,208,131,.95),inset 0 0 30px rgba(208,169,94,.32)}
#ancientSocietySenet .keyboard-guide{margin:14px 0 0;padding:10px 12px;border-left:3px solid rgba(208,169,94,.72);background:rgba(208,169,94,.06);color:var(--muted);line-height:1.55;font-size:.86rem}
#ancientSocietySenet .keyboard-guide strong{color:var(--ivory)}
#ancientSocietySenet .victory-overlay{width:100vw;max-width:none;height:100vh;max-height:none;margin:0;border:0;padding:22px;color:inherit;background:rgba(10,8,5,.78)}
#ancientSocietySenet .victory-overlay::backdrop{background:rgba(10,8,5,.78);backdrop-filter:blur(4px)}
#ancientSocietySenet .victory-overlay[open]{display:grid;place-items:center}
#ancientSocietySenet .victory-overlay:not([open]){display:none}
#ancientSocietySenet .victory-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:10px}
#ancientSocietySenet .tool-button,#ancientSocietySenet .primary-button,#ancientSocietySenet .secondary-button,#ancientSocietySenet .record-reset,#ancientSocietySenet .house-guide-button,#ancientSocietySenet .guide-tabs button,#ancientSocietySenet .dialog-close,#ancientSocietySenet .tutorial-skip{min-height:44px}
#ancientSocietySenet .dialog-close{min-width:44px}
@media(pointer:coarse){#ancientSocietySenet .tool-button,#ancientSocietySenet .primary-button,#ancientSocietySenet .secondary-button,#ancientSocietySenet .record-reset,#ancientSocietySenet .house-guide-button,#ancientSocietySenet .guide-tabs button,#ancientSocietySenet select{min-height:48px}#ancientSocietySenet .house{touch-action:manipulation}}
@media(max-width:600px){#ancientSocietySenet .game-tools{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}#ancientSocietySenet .game-tools .tool-button{width:100%}#ancientSocietySenet .victory-actions{flex-direction:column}#ancientSocietySenet .victory-actions button{width:100%}#ancientSocietySenet .keyboard-guide{font-size:.82rem}}
@media(max-width:390px){#ancientSocietySenet .game-tools{grid-template-columns:1fr}}
@media(prefers-reduced-motion:reduce){#ancientSocietySenet *,#ancientSocietySenet *::before,#ancientSocietySenet *::after{scroll-behavior:auto!important}}

@media (max-width: 640px){
  #ancientSocietySenet .battle-subtitle{ font-size: 0.74rem; }
  #ancientSocietySenet .rival-portrait{ width: 44px; height: 44px; }
  #ancientSocietySenet .player-role{ font-size: 0.64rem; }
}
