* {box-sizing:border-box}
[hidden] {display:none!important}
body {margin:0;background:var(--iwg-soft);color:var(--iwg-ink);font:15px/1.5 var(--iwg-font)}
main {max-width:1140px;margin:auto;padding:24px}
a {color:inherit;text-decoration:none}
.crumb {font-size:12px;color:var(--iwg-muted);word-spacing:2px}
header,.turn,.related>div {display:flex;align-items:center;gap:12px}
header {margin:20px 0}
header button,.turn span,.related>div>a {margin-left:auto}
.logo {width:72px;height:56px;border-radius:14px;background:#e5f0e8}
h1,h2,p {margin:0}
h1 {font-size:clamp(22px,4vw,34px);letter-spacing:-.04em;line-height:1.12}
h2 {font-size:18px;letter-spacing:-.025em}
p,label,#history {color:var(--iwg-muted);font-size:13px}
.layout {display:grid;grid-template-columns:minmax(0,1fr) 285px;gap:18px;align-items:start}
.play {overflow:hidden}
.modes {display:flex;align-items:center;gap:4px;padding:10px 16px;background:var(--iwg-soft);border-bottom:1px solid var(--iwg-border)}
.mode-tools {display:flex;align-items:center;gap:6px;margin-inline-start:auto}
.play-clock {display:inline-flex;align-items:center;gap:5px;padding:4px 6px;color:var(--iwg-muted);font-size:13px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap}
.table {width:min(100%,clamp(365px,64vh,540px));padding:16px;margin:auto}
.turn {margin-bottom:12px}
.turn span {padding:5px 10px;border-radius:14px;font-size:12px;font-weight:700;background:var(--iwg-soft);color:var(--iwg-blue)}
#board {display:grid;grid-template-columns:repeat(8,minmax(0,1fr));overflow:hidden;border:2px solid #527567;border-radius:9px;container-type:inline-size}
#board button {position:relative;display:grid;place-items:center;border:0;padding:0;aspect-ratio:1;cursor:pointer;font:normal 9.4cqw/1 "Apple Symbols","Segoe UI Symbol",serif;touch-action:manipulation}
.light {background:#e4efe5}.dark {background:#83a894}
#board [data-color=w] {color:#fff9e9;-webkit-text-stroke:.9px #353d38;text-shadow:0 1px 2px #34443d}
#board [data-color=b] {color:#233d35}
#board .last {background-image:linear-gradient(#f2d77855,#f2d77855)}
#board .selected {background:#e5c475}
#board .target::after {content:"";width:24%;height:24%;border-radius:50%;position:absolute;background:#35574680}
#board .target:not([data-color=""])::after {width:85%;height:85%;border:3px solid #35574680;background:none}
#board button:focus-visible {outline:2px dashed #233d35;outline-offset:-3px}
#hint {text-align:center;margin-top:10px}
.match-actions {display:flex;justify-content:center;flex-wrap:wrap;gap:6px;margin-top:8px}
.match-actions .iwg-button {min-height:36px;padding:4px 12px;font-size:12px}
@media(pointer:coarse){.match-actions .iwg-button {min-height:44px}}
aside {display:grid;gap:12px}
aside section,dialog {padding:20px}
aside p,aside label {display:block;margin:8px 0}
select {display:block;margin:4px 0 12px;width:100%;min-height:44px;border-radius:10px;background:var(--iwg-soft);border:1px solid var(--iwg-border);color:var(--iwg-ink);padding:8px;font:inherit}
#history {padding:0;margin:8px 0 0;max-height:170px;overflow:auto;list-style:none;font-variant-numeric:tabular-nums}
#history:empty::after {content:"Your moves appear here."}
.related {margin:24px 0}
.related>div>h2 {font-size:20px;letter-spacing:normal}
.related>div>a {color:var(--iwg-blue);font-size:13px;font-weight:700}
.related nav {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:12px}
.related .iwg-card {display:flex;align-items:center;padding:10px;gap:8px}
.related .iwg-card h3 {margin:0;font-size:14px}
.related .iwg-card p {margin-top:5px;font-size:12px}
.related svg {width:55px;flex-shrink:0}
@media(max-width:960px){.related nav{grid-template-columns:1fr}}
@media(max-width:600px){.related>div>h2{font-size:19px}}
dialog {max-width:calc(100% - 24px);border:1px solid var(--iwg-border);background:var(--iwg-paper);color:var(--iwg-ink);border-radius:20px;text-align:center}
dialog::backdrop {background:#142c3b80}
#actions {display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin-top:16px}
#result-dialog {
  --result-accent:var(--iwg-blue);
  width:min(400px,calc(100% - 24px));
  max-height:calc(100dvh - 24px);
  padding:0;
  border-radius:24px;
  box-shadow:0 28px 84px #0b15354d;
}
#result-dialog[data-outcome="win"] {--result-accent:#a0640d}
#result-dialog[data-outcome="loss"] {--result-accent:#79506f}
[data-theme="dark"] #result-dialog[data-outcome="win"] {--result-accent:#ffd07a}
[data-theme="dark"] #result-dialog[data-outcome="loss"] {--result-accent:#deb2d2}
#result-dialog::backdrop {background:#10192b9e}
.result-hero {
  position:relative;
  isolation:isolate;
  overflow:hidden;
  padding:28px 20px 22px;
  border-bottom:1px solid var(--iwg-border);
  background:radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--result-accent) 23%,var(--iwg-paper)),transparent 78%),var(--iwg-soft);
}
.result-hero::before {
  content:"";
  position:absolute;
  z-index:-1;
  inset:-80px -38px;
  background:conic-gradient(from 90deg,transparent 25%,var(--result-accent) 0 50%,transparent 0 75%,var(--result-accent) 0) 0 0 / 40px 40px;
  transform:rotate(-16deg);
  mask-image:radial-gradient(ellipse,transparent 21%,#000 56%,transparent 82%);
  opacity:.13;
}
.result-emblem {
  position:relative;
  display:grid;
  place-items:center;
  width:76px;
  height:76px;
  margin:0 auto 17px;
  border:1px solid color-mix(in srgb,var(--result-accent) 33%,var(--iwg-paper));
  border-radius:24px;
  outline:5px solid color-mix(in srgb,var(--result-accent) 13%,transparent);
  background:linear-gradient(150deg,var(--iwg-paper),color-mix(in srgb,var(--result-accent) 19%,var(--iwg-paper)));
  box-shadow:0 10px 20px color-mix(in srgb,var(--result-accent) 17%,transparent);
  color:var(--result-accent);
  font:700 44px/1 "Apple Symbols","Segoe UI Symbol",var(--iwg-font);
}
#result-dialog[data-outcome="loss"] #result-icon {transform:rotate(-13deg)}
#result-dialog[data-outcome="win"] .result-emblem::before,
#result-dialog[data-outcome="win"] .result-emblem::after {
  content:"✦";
  position:absolute;
  inset:auto auto 3px -23px;
  font-size:19px;
}
#result-dialog[data-outcome="win"] .result-emblem::after {inset:2px -21px auto auto;font-size:15px}
#result-title {font-size:clamp(27px,8vw,36px);font-weight:800;letter-spacing:-.045em;line-height:1.1}
.result-body {padding:18px clamp(16px,5vw,26px) 24px}
#result-reason {font-size:14px;overflow-wrap:anywhere;text-wrap:pretty}
.result-actions {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(135px,100%),1fr));
  gap:8px;
  margin-top:16px;
}
.result-actions .iwg-button {padding:10px 12px}
#result-status:not(:empty) {margin-top:12px}
@media(prefers-reduced-motion:no-preference) {
  #result-dialog[open].celebrate .result-emblem {animation:result-pop 480ms ease-out both}
  #result-dialog[open].celebrate .result-emblem::before,
  #result-dialog[open].celebrate .result-emblem::after {animation:result-spark 420ms 65ms ease-out both}
  @keyframes result-pop {
    0% {opacity:.55;transform:translateY(5px) scale(.86)}
    62% {opacity:1;transform:scale(1.07)}
    100% {transform:scale(1)}
  }
  @keyframes result-spark {
    from {opacity:0;transform:scale(.3)}
    65% {opacity:1;transform:scale(1.2)}
    to {transform:scale(1)}
  }
}
@media(max-width:760px){main{padding:16px 12px}.layout{grid-template-columns:1fr}.table{padding:12px}.logo{width:44px;height:44px}.related>div{flex-wrap:wrap}header{gap:8px}header p{font-size:12px}}
header #full {margin-left:auto;min-width:44px;padding:0;font-size:20px}
header #quit {margin-left:0}
.modes {flex-wrap:wrap}
#online {padding:16px}
#lobby {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:end}
#lobby :is(input,select) {display:block;width:100%;padding:10px 12px;min-height:44px;margin-top:4px;border:1px solid var(--iwg-border);border-radius:10px;background:var(--iwg-soft);color:var(--iwg-ink);font:inherit}
#seats {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px}
#players {overflow-wrap:anywhere}
#room-move-settings {
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;
  min-width:0;margin:0;padding:0;border:0;
}
#room-move-settings legend {padding:0;margin-bottom:4px;font-weight:700}
#room-move-settings select {margin-bottom:0}
#room-join-rules {font-size:12px}
#notice:not(:empty) {margin-top:8px}
@media(max-width:450px){header{gap:5px}header .iwg-button{padding-inline:12px}.modes{padding:6px}.modes .iwg-mode{padding-inline:10px}#lobby{grid-template-columns:1fr}#lobby button{width:100%}}
#settings {display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap;padding:4px 12px;border-bottom:1px solid var(--iwg-border)}
#settings label {display:inline-flex;align-items:center;gap:8px;margin-right:auto;font:650 12px/1.2 var(--iwg-font)}
.skill-field {position:relative;display:inline-flex;align-items:center}
#settings select,#settings #new {min-height:36px;margin:0;border-radius:10px;font:700 12px/1.2 var(--iwg-font)}
#settings #new {padding:0 12px}
#settings select {appearance:none;width:auto;padding:0 27px 0 10px;background:var(--iwg-soft);color:var(--iwg-ink);cursor:pointer}
.skill-icon {position:absolute;right:11px;width:7px;height:7px;border:solid var(--iwg-muted);border-width:0 1.5px 1.5px 0;transform:translateY(-2px) rotate(45deg);pointer-events:none}
#settings .move-settings {display:flex;flex-wrap:wrap;gap:6px 12px;margin-right:auto}
#settings .move-limit {appearance:auto;padding:0 8px}
#room-move-limits {font-variant-numeric:tabular-nums}
#settings select:disabled {opacity:1;cursor:default;color:var(--iwg-muted)}
#settings select:disabled + .skill-icon {width:9px;height:7px;border:1.5px solid var(--iwg-muted);border-radius:2px;transform:translateY(2px)}
#settings select:disabled + .skill-icon::before {content:"";position:absolute;left:0;right:0;bottom:100%;height:5px;border:1.5px solid var(--iwg-muted);border-bottom:0;border-radius:5px 5px 0 0}
@media(pointer:coarse){#settings select,#settings #new {min-height:44px}}
#history {max-height:210px;margin-top:12px}
#history:empty {background:var(--iwg-soft);padding:14px;border-radius:12px}
#history li {display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:9px 2px;border-bottom:1px solid var(--iwg-border)}
#history li:first-child {background:var(--iwg-soft);border-radius:8px;padding-inline:8px}
#history strong {color:var(--iwg-ink);margin-left:auto}
.history-player {display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:var(--iwg-ink)}
.history-player::before {content:"";width:10px;height:10px;border-radius:50%;border:1px solid #87949d;background:#fff}
.history-player.black::before {background:#253832}
.guide dl {margin:18px 0}
.guide dl div {position:relative;padding-left:48px;margin:16px 0}
.guide dt {font-size:13px;font-weight:750}
.guide dt span {position:absolute;left:0;top:0;display:grid;place-items:center;width:36px;height:36px;border-radius:9px;background:#d7ebdf;color:#285642;font:24px/1 Georgia,serif}
.guide dl div:nth-child(2) span {background:#f3e3bf;color:#704b16}
.guide dl div:nth-child(3) span {background:#e7def3;color:#584270}
.guide dd,.guide p {margin:4px 0;color:var(--iwg-muted);font-size:12px;line-height:1.65}
.guide .guide-tip {border-top:1px solid var(--iwg-border);padding-top:14px}
.guide-tip strong {display:block;color:var(--iwg-ink)}

#seats h2 { font-size: 18px; margin: 0 0 4px; }
#seats p { margin: 0; color: var(--iwg-muted); }
.room-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
#room-number { padding:8px 12px; border-radius:10px; background:var(--iwg-soft); letter-spacing:.12em; }
#saved-room,#round-tools {display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:12px;border:1px solid var(--iwg-border);border-radius:14px;background:var(--iwg-soft)}
#saved-room {max-width:540px;margin:0 auto 16px}
#saved-room .seat-piece {font-size:26px;color:var(--iwg-blue)}
#saved-room div,#round-tools div {flex:1;min-width:105px}
#saved-room small,#round-tools small {display:block;color:var(--iwg-muted)}
#round-tools {margin-top:12px}
aside {min-width:0}

#notice input { width:min(100%,340px); color:var(--iwg-ink); background:var(--iwg-soft); }

#lobby {max-width:540px;margin:auto;grid-template-columns:1fr;gap:14px}
.lobby-choices {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.lobby-choices button {display:flex;gap:10px;align-items:center;text-align:left;border:1px solid var(--iwg-border);border-radius:16px;background:var(--iwg-paper);color:var(--iwg-ink);padding:12px;font:inherit;cursor:pointer}
.lobby-choices button[aria-pressed=true] {border-color:var(--iwg-blue);background:color-mix(in srgb,var(--iwg-blue) 9%,var(--iwg-paper));box-shadow:inset 0 0 0 1px var(--iwg-blue)}
.lobby-choices i {display:grid;place-items:center;border-radius:10px;width:36px;height:38px;background:#303c69;color:#ffe3ac;font:26px/1 Georgia,serif}
.lobby-choices small,.lobby-choices strong {display:block}.lobby-choices small {font-size:12px;color:var(--iwg-muted)}
#room-chat {
  --chat-accent-surface: color-mix(in srgb, var(--iwg-blue) 12%, var(--iwg-paper));
  min-width: 0;
  overflow: hidden;
}

#room-chat summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 12px;
  list-style: none;
  font-weight: 750;
  cursor: pointer;
}

#room-chat summary::-webkit-details-marker {display: none}
#room-chat summary:hover {background: var(--iwg-soft)}
#room-chat[open] summary {border-bottom: 1px solid var(--iwg-border)}

.chat-icon {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--chat-accent-surface);
  color: var(--iwg-blue);
}

#chat-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--chat-accent-surface);
  color: var(--iwg-blue);
  font-size: 11px;
  white-space: nowrap;
}

#chat-badge:empty {display: none}

.chat-chevron {
  flex: 0 0 8px;
  height: 8px;
  margin: -4px 3px 0 auto;
  border: solid var(--iwg-muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

#room-chat[open] .chat-chevron {margin-top: 4px; transform: rotate(225deg)}

.chat-transcript {position: relative; background: var(--iwg-soft)}

#chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 168px;
  max-height: 240px;
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.chat-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 3px;
  margin: 0;
  padding: 12px;
  text-align: center;
  pointer-events: none;
}

.chat-empty strong {color: var(--iwg-ink)}
#chat-log:not(:empty) + .chat-empty {display: none}

#chat-log .chat-message {display: grid; justify-items: start; gap: 3px; margin: 0}
#chat-log .chat-mine {justify-items: end}
.chat-author {max-width: 100%; padding-inline: 3px; font-size: 11px; overflow-wrap: anywhere}
.chat-bubble {
  max-width: 90%;
  padding: 7px 10px;
  border: 1px solid var(--iwg-border);
  border-radius: 4px 12px 12px;
  background: var(--iwg-paper);
  color: var(--iwg-ink);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-mine .chat-bubble {
  border-color: transparent;
  border-radius: 12px 4px 12px 12px;
  background: var(--chat-accent-surface);
}

.chat-controls {
  display: grid;
  gap: 8px;
  padding: 9px 12px 12px;
  border-top: 1px solid var(--iwg-border);
}

#reactions {display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px}
#reactions button {
  min-height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--iwg-soft);
  color: var(--iwg-ink);
  font-size: 18px;
  cursor: pointer;
}

#reactions button:hover {
  background: var(--chat-accent-surface);
  border-color: var(--iwg-border);
}

#room-chat :is(summary,#chat-log,#reactions button):focus-visible {
  outline: 2px solid var(--iwg-blue);
  outline-offset: -3px;
}

#chat-form {display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px}
#chat-form input {
  min-width: 0;
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--iwg-muted) 35%, var(--iwg-border));
  border-radius: 10px;
  background: var(--iwg-paper);
  color: var(--iwg-ink);
  font: inherit;
}

#chat-form input::placeholder {color: var(--iwg-muted)}
#chat-form button {padding: 0 13px; border-radius: 10px}
#chat-error {margin: 0; overflow-wrap: anywhere}
#chat-error:empty {display: none}

@media (max-width: 760px) {
  .chat-controls {padding-inline: 9px}
  #reactions {gap: 2px}
  #chat-form input {font-size: 16px}
}
@media(max-width:450px){.lobby-choices button {align-items:flex-start;flex-direction:column;padding:10px}.lobby-choices small{font-size:11px}}


body.chess-expanded {overflow:hidden}
body.chess-expanded :is(iwebgames-header,iwebgames-footer,.crumb,main > header,.layout > aside,.related) {visibility:hidden}
.play.is-expanded {position:fixed;inset:0;z-index:10000}
.play:is(:fullscreen,.is-expanded) {
  display:flex;
  flex-direction:column;
  width:100%;
  height:100dvh;
  overflow:auto;
  border:0;
  border-radius:0;
  background:var(--iwg-paper);
}
.play:is(:fullscreen,.is-expanded) .play-controls {position:relative;flex:none;z-index:2}
.play:is(:fullscreen,.is-expanded) .play-workspace {
  position:relative;
  display:flex;
  flex:1 0 0;
  min-height:225px;
  min-width:0;
}
.play #full {
  display:grid;
  place-items:center;
  margin-left:auto;
  min-width:44px;
  height:44px;
  padding:0;
}
.play:is(:fullscreen,.is-expanded) .table {
  display:flex;
  flex:1 1 0;
  flex-direction:column;
  width:100%;
  min-height:0;
  margin:0;
  padding:clamp(8px,1.8vmin,18px);
}
.play:is(:fullscreen,.is-expanded) .turn {
  width:min(100%,70dvh);
  margin:0 auto 8px;
}
.play:is(:fullscreen,.is-expanded) .board-stage {
  display:grid;
  place-items:center;
  flex:1 0 0;
  min-height:0;
  container-type:size;
}
.play:is(:fullscreen,.is-expanded) #board {
  width:min(100%,calc(100dvh - 160px));
  width:min(100cqw,100cqh);
  aspect-ratio:1;
  grid-template-rows:repeat(8,minmax(0,1fr));
}
.play:is(:fullscreen,.is-expanded) #hint {margin-top:8px}

#room-details-toggle,#fullscreen-chat-toggle {
  flex:none;
  gap:6px;
  padding:0 10px;
  font-size:12px;
}
#room-details-toggle[aria-expanded="true"],#fullscreen-chat-toggle[aria-expanded="true"] {
  background:var(--iwg-soft);
  border-color:var(--iwg-blue);
}
.room-caret {
  width:7px;
  height:7px;
  margin-top:-3px;
  border:solid currentColor;
  border-width:0 1.5px 1.5px 0;
  transform:rotate(45deg);
}
#room-details-toggle[aria-expanded="true"] .room-caret {margin-top:3px;transform:rotate(225deg)}
#fullscreen-chat-badge:not(:empty) {
  padding:1px 5px;
  border-radius:99px;
  background:var(--iwg-blue);
  color:var(--iwg-paper);
  font-size:10px;
}
.room-in-fullscreen #online {
  position:absolute;
  top:calc(100% + 8px);
  right:8px;
  width:min(690px,calc(100% - 16px));
  max-height:70dvh;
  overflow:auto;
  overscroll-behavior:contain;
  background:var(--iwg-paper);
  border:1px solid var(--iwg-border);
  border-radius:16px;
  box-shadow:0 16px 42px #0b153532;
}
.room-in-fullscreen #online:has(> #room-information[hidden]) {width:fit-content;max-width:calc(100% - 16px);padding:10px 12px}
.room-in-fullscreen #online:has(> #room-information[hidden]) #notice {margin:0}
.room-in-fullscreen #online:has(> #room-information[hidden]):has(> #notice:empty) {display:none}
.play.room-in-fullscreen .play-workspace {
  display:grid;
  grid-template-columns:minmax(0,1fr) clamp(235px,23vw,302px);
  grid-template-rows:minmax(0,1fr);
  gap:clamp(8px,1vw,16px);
  align-self:center;
  width:min(100%,calc(100dvh + 302px));
  padding-inline-end:clamp(8px,1.8vmin,18px);
}
.room-in-fullscreen .play-workspace #room-chat {align-self:start;margin-top:clamp(8px,1.8vmin,18px)}
.room-in-fullscreen #chat-log {min-height:90px;height:clamp(90px,calc(100dvh - 270px),420px);max-height:none}
@media (max-width:900px), (max-height:460px) {
  .play.room-in-fullscreen .play-workspace {display:flex;padding-inline-end:0}
  .room-in-fullscreen .play-workspace #room-chat {
    position:absolute;
    z-index:1;
    top:8px;
    right:8px;
    width:min(320px,calc(100% - 16px));
    max-height:calc(100% - 16px);
    margin:0;
    overflow:auto;
    overscroll-behavior:contain;
    box-shadow:0 12px 34px #0b153532;
  }
  .room-in-fullscreen #room-chat:not([open]) {display:none}
  .room-in-fullscreen #chat-log {height:clamp(80px,26dvh,225px);min-height:0}
}
@media (max-width:760px) {
  .room-in-fullscreen .modes > [data-mode] {display:none}
  .room-in-fullscreen .mode-tools {flex-wrap:wrap;justify-content:flex-end}
}
