:root {
  --bg: #f4f1ea;
  --paper: #fffcf7;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #d6d3cd;
  --accent: #0f3d4c;
  --accent-2: #c45c26;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: clip !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.65;
  overflow-x: clip !important;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: #1c1917; }

.shell {
  display: grid;
  grid-template-columns: minmax(180px, 200px) 1fr;
  min-height: 100vh;
}

.identity {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 48px 18px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.brand {
  width: 100%;
  text-align: center;
}

.brand .wordmark {
  display: block;
}

.wordmark {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.4;
}

.place {
  margin: -22px 0 28px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--muted);
}

.brand .place {
  margin: 6px 0 28px;
  text-align: center;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}
nav a { color: var(--muted); text-decoration: none; }
.nav-at { display: none; }
nav a:hover { color: var(--ink); }

.mail {
  margin-top: auto;
  width: 100%;
  font-size: 15px;
  text-align: center;
}
.mail a {
  display: block;
  margin-bottom: 8px;
  overflow-wrap: break-word;
  text-align: center;
}
.looks { font-size: 13px; color: var(--muted); }

.main {
  padding: 56px 64px 88px;
  max-width: 760px;
}

/* Years in Selected work margin (home only via .work). */
.work-year {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}

.kicker {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.4;
  color: var(--muted);
}

h1 {
  font-size: clamp(24px, 2.8vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 20px;
}

.lede {
  font-size: 20px;
  color: var(--muted);
  margin: 0 0 28px;
}

.how {
  margin: 0 0 16px;
}

.lived {
  margin: 0 0 40px;
  font-size: 14px;
  color: var(--muted);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 0 0 40px;
  padding: 0;
}

.pair article,
.entry .callout,
.entry .rules li {
  padding: 20px 22px 20px 20px;
  background: #edf3f4;
  border-left: 3px solid #0f3d4c;
}

.pair h2 {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

.pair p { margin: 0; font-size: 16px; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 36px;
  margin: 0 0 8px;
  padding: 16px 22px;
  background: #edf3f4;
  border-left: 3px solid #0f3d4c;
}

.stat b {
  font-size: 20px;
  font-weight: 600;
  margin-right: 8px;
  color: var(--accent);
}

.stat span {
  font-size: 14px;
  color: var(--muted);
}

.note {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 56px;
}

section h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 20px;
}

.work article {
  padding: 0 0 28px;
}

.work h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
}

.work p, .gems p, .also p { margin: 0 0 12px; }

@media (min-width: 641px) {
  .main {
    max-width: 820px;
  }

  /* Compact nav under the signature; 32px air after reykjavík. */
  .identity {
    gap: 32px;
    min-width: 0;
  }
  .brand .place {
    margin-bottom: 0;
  }
  nav {
    gap: 8px;
    align-items: center;
    width: 100%;
    min-width: 0;
    font-size: 15px;
    line-height: 1.25;
  }
  nav a {
    display: block;
    min-height: 0;
    padding: 2px 0;
    text-align: center;
    line-height: 1.25;
  }
  .mail {
    margin-top: auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    text-align: center;
  }
  .mail a {
    display: block;
    max-width: 100%;
    margin-inline: auto;
    margin-bottom: 0;
    text-align: center;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.35;
    hyphens: none;
  }

  /* Shared year gutter so titles line up; wide enough for ranges like 2018–present. */
  .work article {
    display: grid;
    grid-template-columns: 9.75rem minmax(0, 1fr);
    column-gap: 1.1rem;
    align-items: start;
  }

  .work-year {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    margin-top: 0.35em;
    font-size: clamp(15px, 1.55vw, 20px);
    white-space: nowrap;
    opacity: 0.8;
  }

  .work article > h3 {
    grid-column: 2;
    grid-row: 1;
  }

  .work article > p {
    grid-column: 2;
  }
}

@media (min-width: 1025px) {
  .work article {
    grid-template-columns: 10.25rem minmax(0, 1fr);
    column-gap: 1.25rem;
  }

  .work-year {
    font-size: clamp(16px, 1.3vw, 20px);
  }
}

.gems ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.gems li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  font-size: 16px;
}

.gems li span {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
}

@media (min-width: 1025px) {
  .gems ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 48px;
  }

  .gems li {
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    padding-top: 11px;
    padding-bottom: 10px;
  }

  .gems li span { font-variant-numeric: tabular-nums; }
}

.also { margin: 48px 0 0; }

footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--muted);
}

footer a { margin-right: 14px; }

/* Tablets: same narrow rail as desktop; keep 44px tap targets. */
@media (min-width: 641px) and (max-width: 1024px) {
  .shell { grid-template-columns: minmax(180px, 200px) 1fr; }
  .identity { padding: 36px 16px; }
  .main { padding: 40px 28px 72px; }
  .pair { gap: 24px; }
  nav a {
    position: relative;
    display: block;
    min-height: 0;
    padding: 2px 0;
  }
  /* 44px tap without stretching the list into six huge rows. */
  nav a::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 44px;
    transform: translateY(-50%);
  }
  .gems a,
  footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .mail a {
    display: block;
    min-height: 44px;
    margin-bottom: 0;
    text-align: center;
    overflow-wrap: break-word;
  }
  .gems li { min-height: 44px; align-items: center; }
}

/* Phones only. Tablets (e.g. iPad 768) keep the ad3 split + sticky rail. */
@media (max-width: 640px) {
  /* Masthead collapse must not rewrite scrollY (that undid .is-scrolled). */
  html { overflow-anchor: none; }
  body { line-height: 1.55; }
  a:hover { color: var(--accent-2); }

  .shell {
    display: block;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: auto;
  }

  .identity {
    position: sticky;
    top: 0;
    z-index: 20;
    align-self: auto;
    height: auto;
    padding: 12px 0 8px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    gap: 0;
  }

  /* Toy rails that stay 100dvh must not stick over the play area. */
  .shell.toy-shell .identity {
    position: static;
  }

  .wordmark {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    line-height: 1.4;
    color: var(--ink);
    min-height: 0;
    padding: 0;
  }

  .mail {
    display: none;
  }

  .brand .place {
    display: block;
    margin: 6px 0 14px;
    padding: 0;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    text-align: center;
    color: var(--muted);
    line-height: 1.2;
  }

  body.is-scrolled .brand .place {
    display: none;
  }

  nav a .nav-word { display: none; }
  nav a .nav-at { display: inline; }

  nav {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0 8px;
    width: 100%;
    max-width: 100%;
    font-size: 13px;
    white-space: nowrap;
  }
  body.is-scrolled nav {
    margin-top: 8px;
  }
  nav a {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: 0;
    padding: 0;
    line-height: 1.2;
    white-space: nowrap;
  }

  .main {
    padding: 40px 0 0;
    max-width: none;
  }

  .kicker {
    display: block;
    margin: 0 0 12px;
  }

  h1 {
    font-size: clamp(24px, 5.5vw, 32px);
    margin: 0 0 16px;
  }

  .lede { max-width: 40em; }

  .how {
    border-left: 3px solid var(--accent);
    padding: 4px 0 4px 16px;
    margin: 0 0 16px;
  }

  .lived { margin: 0 0 32px; }

  .pair {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0 0 48px;
    padding: 0;
    border: none;
  }
  .pair article {
    background: #edf3f4;
    border: none;
    border-left: 3px solid #0f3d4c;
    padding: 20px 22px;
  }
  .pair h2 {
    color: var(--accent);
    margin: 0 0 8px;
  }

  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    margin: 0 0 16px;
    padding: 16px 18px;
    background: #edf3f4;
    border-left: 3px solid #0f3d4c;
  }
  .stat {
    padding: 4px 0;
    border-top: none;
  }
  .stat b {
    display: block;
    font-size: 22px;
    margin-right: 0;
    letter-spacing: -0.02em;
  }
  .stat span { font-size: 13px; }

  .note { margin: 0 0 48px; }

  .work article {
    display: block;
    padding: 18px 0;
    border-top: 1px solid var(--line);
  }
  .work-year {
    display: block;
    grid-column: auto;
    grid-row: auto;
    justify-self: start;
    width: auto;
    max-width: none;
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.08em;
    margin: 0 0 6px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: visible;
  }
  .work h3 {
    font-size: 20px;
    margin: 0 0 6px;
  }

  .gems ul { margin: 0 0 16px; }
  .gems li {
    padding: 10px 0;
    border-top: 1px solid var(--line);
    min-height: 44px;
    align-items: center;
  }
  .gems a,
  .note a,
  .also a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .also {
    margin: 48px 0;
    padding: 22px 20px;
    background: var(--paper);
    border: 1px solid var(--line);
  }
  .also h2 { margin-bottom: 10px; }

  footer {
    margin-top: 0;
    padding: 28px 0 48px;
  }
  footer p:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
  }
  footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-right: 12px;
    padding: 6px 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .gems li { flex-direction: column; gap: 2px; align-items: flex-start; }
}

/* Keep rail chrome even when a toy page redefines :root tokens for the game. */
.identity {
  --ink: #1c1917;
  --muted: #57534e;
  --paper: #fffcf7;
}
nav a[aria-current="page"] { color: var(--ink); }

.writing .when {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.writing article { padding-bottom: 36px; }

.writing h3 a {
  color: inherit;
  text-decoration: none;
}
.writing h3 a:hover { color: var(--accent); }

.writing article p:last-child {
  margin: 0;
  color: var(--muted);
}

/* Blog index: image left of title / date / lede. Own classes; not .toy. */
.post-list {
  margin: 22px 0 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.post-card {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.post-card__media {
  flex: 0 0 auto;
  line-height: 0;
  text-decoration: none;
}

.post-card__img {
  display: block;
  width: 130px;
  max-width: 130px;
  height: 150px;
  max-height: 150px;
  object-fit: cover;
  object-position: center;
}

.post-card__body {
  min-width: 0;
  flex: 1 1 auto;
}

.post-card__body h3 {
  margin: 0 0 6px;
}

.post-card__body > p:last-child {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 640px) {
  .post-card {
    gap: 12px;
  }

  .post-card__img {
    width: 96px;
    max-width: 96px;
    height: 120px;
    max-height: 120px;
  }
}

.entry h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 36px 0 14px;
}

.entry p { margin: 0 0 16px; }

.entry strong { font-weight: 600; }

.entry ul {
  margin: 0 0 16px;
  padding-left: 1.15em;
}

.entry li { margin: 0 0 8px; }
.entry li:last-child { margin-bottom: 0; }

.entry .rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
}

.entry .rules li { margin: 0; }

.post-nav {
  margin: 36px 0 0;
  font-size: 15px;
}

.share-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 10px;
  vertical-align: middle;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  border-radius: 2px;
}

.share-btn:hover {
  color: var(--ink);
}

.share-btn:focus-visible {
  color: var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.share-btn svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-status {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.share-status.is-visible {
  opacity: 1;
}

.writing .when .share-actions {
  margin-left: 2px;
}

/* Play index: one row of tag filters (All, Game, Simulation, and the rest). */
.play-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 4px;
  margin: 18px 0 0;
  max-width: 100%;
  container-type: inline-size;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
}

.play-filter__btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px 0;
  margin: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.2;
}

.play-filter__btn:hover {
  color: var(--ink);
}

.play-filter__btn[aria-pressed="true"] {
  color: var(--ink);
}

.play-filter__btn:focus-visible {
  color: var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.toy-list .toy.is-filtered-out {
  display: none;
}

/* Toys index: image left, title + brief line right.
   Scoped under .toy-list so game pages' <main class="toy"> are not shrink-wrapped. */
.toy-list {
  margin: 22px 0 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.toy-list .toy {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.toy__media {
  flex: 0 0 auto;
  line-height: 0;
  text-decoration: none;
}

.toy__img {
  display: block;
  width: 120px;
  max-width: 120px;
  height: 150px;
  max-height: 150px;
  object-fit: cover;
  object-position: center;
}

/* Viking II cassette is landscape: show it whole. Letterbox matches the photo border. */
.toy__media--contain {
  background: #d2c5b4;
}

.toy__img--contain {
  object-fit: contain;
  background: #d2c5b4;
}

.toy__body {
  min-width: 0;
  flex: 1 1 auto;
}

.toy__body h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.toy__body h3 a {
  color: inherit;
  text-decoration: none;
}

.toy__body h3 a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toy__body p {
  margin: 0;
  color: var(--muted);
}

.toy__why {
  margin-top: 6px;
  font-size: 0.95em;
  color: var(--muted);
}

/* Tags sit beside the title. Soft wash per kind, one radius, one height. */
.toy__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  margin: 0 0 8px;
  min-width: 0;
  max-width: 100%;
}

.toy__body .toy__head h3 {
  margin: 0;
  flex: 0 0 auto;
  max-width: 100%;
  line-height: 22px;
}

.toy__body p.toy__play {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 0;
  max-width: 100%;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--ink);
}

.toy__tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 22px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1;
}

button.toy__tag {
  appearance: none;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-decoration: none;
  min-height: 0;
}

.play-filter .toy__tag {
  flex: 0 0 auto;
}

/* Slightly tighter than the card tags so the mic fits the desktop row. */
.play-filter .toy__tag:not(.toy__tag--voice) {
  padding-left: 6px;
  padding-right: 6px;
}

/* Under one line (~680px), break after the fifth pill so the wrap is 5 + 4. */
@container (min-width: 400px) and (max-width: 679px) {
  .play-filter > .toy__tag:nth-child(5) {
    margin-right: calc(100% - 400px);
  }
}

button.toy__tag:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.toy__tag[aria-pressed="true"] {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor;
}

.toy__tag--all {
  background: #efeae3;
  border-color: #ddd4c8;
  color: #3a342c;
}

/* Washed fills on the page ground. Not the brand teal, not the LLM card tint. */
.toy__tag--count {
  background: #ddd4c4;
  border-color: #cfc4b0;
  color: #3a342c;
}

.toy__tag--pass {
  background: #ead0b6;
  border-color: #d8b898;
  color: #5c3b24;
}

.toy__tag--online {
  background: #d0d8ea;
  border-color: #b8c4dc;
  color: #243044;
}

.toy__tag--voice {
  width: 22px;
  padding: 0;
  background: #e2d0dc;
  border-color: #d0b8c8;
  color: #4a3142;
}

.toy__tag--voice svg {
  display: block;
  width: 13px;
  height: 13px;
}

.toy__tag--sim {
  background: #d2dec4;
  border-color: #bccbb0;
  color: #323f28;
}

/* Washed pewter. Not the site teal #0f3d4c, not the sage of Simulation. */
.toy__tag--game {
  background: #d7dbe0;
  border-color: #c0c6ce;
  color: #2a3138;
}

/* Play title row. The h1 stays "Play"; the mark sits beside it. */
.play-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
}

.play-title h1 {
  margin: 0;
}

/* Not a filter: smaller than the tags, not clickable, and a washed ochre no tag uses. */
.play-title__beta {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  height: 18px;
  padding: 0 6px;
  border: 1px solid #dfc884;
  border-radius: 5px;
  background: #f3e4b0;
  color: #4a3a10;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  cursor: default;
}

/* Share on the Play index: the blog's bare .share-btn, so it reads as an action, not a tag. */
.play-title .share-actions {
  margin-left: 0;
}

/* Cards: the share floats right on the name row only, so tags that drop below keep the full width.
   It sits before the tags in the markup; a float after them would fall to the next line. */
.toy-list .toy__head {
  display: block;
  margin-bottom: 2px;
  font-size: 0;
}

.toy-list .toy__body .toy__head h3 {
  display: inline-block;
  vertical-align: top;
  margin: 0 10px 6px 0;
}

.toy-list .toy__body p.toy__play {
  display: inline-flex;
  vertical-align: top;
  margin-bottom: 6px;
}

.toy-list .toy__share {
  position: relative;
  float: right;
  margin: -3px -6px 0 4px;
}

/* Above the icon, so the tags beside it are never covered. */
.toy-list .toy__share .share-status {
  position: absolute;
  right: 6px;
  bottom: 100%;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .play-title {
    margin-bottom: 16px;
  }
}

@media (max-width: 640px) {
  .toy-list .toy {
    gap: 12px;
  }

  .toy__img {
    width: 96px;
    max-width: 96px;
    height: 120px;
    max-height: 120px;
  }
}

/* Play pieces: shared language + sound controls (top of game content, not the rail). */
.toy-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.lang-switch {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  flex: 0 1 auto;
  min-width: 0;
}

.lang-switch button[data-lang] {
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  min-height: 0;
  cursor: pointer;
  opacity: 0.72;
}

.lang-switch button[data-lang][aria-pressed="true"] {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 0.28em;
}

.lang-switch button[data-lang]:hover,
.lang-switch button[data-lang]:focus-visible {
  opacity: 1;
}

.sound-btn {
  margin-left: 0.2rem;
  opacity: 0.9;
  color: inherit;
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  text-decoration: none;
  flex: 0 0 auto;
}

.sound-btn .mute-ico {
  width: 1.7rem;
  height: 1.7rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-btn .mute-ico[hidden] {
  display: none !important;
}

.sound-btn[aria-pressed="true"] {
  opacity: 0.62;
}

.sound-btn:hover,
.sound-btn:focus-visible {
  opacity: 1;
}

/* Same row as language and the speaker. Icon only; the name is the aria-label.
   Color follows the control row so it stays readable on paper and on a dark board. */
.toy-controls .fs-btn {
  margin-left: 0.2rem;
  opacity: 0.9;
  color: inherit;
  background: transparent;
  border: 0;
  width: 2.15rem;
  height: 2.15rem;
  min-width: 2.15rem;
  min-height: 2.15rem;
  padding: 0;
  gap: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  text-decoration: none;
  flex: 0 0 auto;
  line-height: 1;
  border-radius: 0;
}

.toy-controls .fs-btn .fs-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toy-controls .fs-btn .fs-ico {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toy-controls .fs-btn .fs-ico[hidden] {
  display: none !important;
}

.toy-controls .fs-btn[aria-pressed="true"],
.toy-controls .fs-btn:hover,
.toy-controls .fs-btn:focus-visible {
  opacity: 1;
  color: inherit;
  background: transparent;
  text-decoration: none;
}

@media (max-width: 640px) {
  [data-toy-fs] .top,
  [data-toy-fs] .title-row,
  [data-toy-fs] .toy-head,
  [data-toy-fs] .snake-bar,
  [data-toy-fs] .head {
    max-width: 100%;
  }
  [data-toy-fs] .toy-controls {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 0.15rem 0.28rem;
  }
  .lang-switch {
    gap: 0.28rem;
  }
  .lang-switch button[data-lang] {
    font-size: 0.65rem;
  }
  .sound-btn,
  .toy-controls .fs-btn {
    width: 1.9rem;
    height: 1.9rem;
    min-width: 1.9rem;
    min-height: 1.9rem;
  }
  .sound-btn .mute-ico {
    width: 1.45rem;
    height: 1.45rem;
  }
  .toy-controls .fs-btn .fs-ico {
    width: 1.2rem;
    height: 1.2rem;
  }
}

/* Desktop native fullscreen: the element itself is the viewport. Do not
   restyle `.is-fs` here — that class is the mobile fill (≤700px). */
[data-toy-fs]:fullscreen {
  box-sizing: border-box !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  padding: 10px 12px 12px !important;
  background-color: var(--toy-fs-bg, #fffcf7) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

[data-toy-fs]:fullscreen > .toy-fs-fit {
  box-sizing: border-box;
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

[data-toy-fs]:fullscreen .toy-fs-out {
  display: none !important;
}

@media (max-width: 700px) {
  html.toy-fs-open,
  html.toy-fs-open body {
    overflow: hidden !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overscroll-behavior: none;
  }

  html.toy-fs-open .identity,
  html.toy-fs-open .identity nav {
    display: none !important;
  }

  [data-toy-fs]:fullscreen,
  [data-toy-fs].is-fs {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    inset: 0 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100% !important;
    height: 100dvh !important;
    height: 100svh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    overflow-x: hidden !important;
    z-index: 2147483000 !important;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)) !important;
    background-color: var(--toy-fs-bg, #fffcf7) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
  }

  [data-toy-fs]:fullscreen > .toy-fs-fit,
  [data-toy-fs].is-fs > .toy-fs-fit {
    box-sizing: border-box;
    flex: 1 1 auto;
    align-self: stretch;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: none !important;
  }

  [data-toy-fs].is-fs .toy-fs-out,
  [data-toy-fs]:fullscreen .toy-fs-out {
    display: none !important;
  }

  [data-toy-fs].is-fs .play,
  [data-toy-fs].is-fs .play-row,
  [data-toy-fs].is-fs .slot,
  [data-toy-fs].is-fs .stage,
  [data-toy-fs].is-fs .playset {
    min-width: 0;
    min-height: 0;
  }

  [data-toy-fs].is-fs .play,
  [data-toy-fs].is-fs .play-row {
    flex: 1 1 auto;
  }

  [data-toy-fs].is-fs .stage,
  [data-toy-fs].is-fs .board-wrap {
    max-width: 100% !important;
  }

  [data-toy-fs].is-fs .stage canvas,
  [data-toy-fs].is-fs canvas#board {
    width: 100%;
    height: 100%;
    max-width: 100%;
  }
}

/* Signature inside the play zone (bottom-left), also in full screen. */
[data-toy-fs] {
  position: relative;
  overflow-x: clip;
  max-width: 100%;
}

[data-toy-fs]:not(:fullscreen):not(.is-fs) {
  padding-bottom: 2.65rem !important;
}

[data-toy-fs] .toy-sign {
  position: absolute;
  z-index: 6;
  left: 0.55rem;
  bottom: 0.3rem;
  margin: 0;
  padding: 0;
  width: max-content;
  max-width: 8.5rem;
  pointer-events: none;
  user-select: none;
  text-align: left;
  text-indent: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 400;
  font-style: normal;
  font-variant: normal;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-transform: lowercase;
  text-decoration: none;
  color: #1c1917;
  background: none;
  border: 0;
  box-shadow: none;
  text-shadow: none;
}

[data-toy-fs] .toy-sign__name,
[data-toy-fs] .toy-sign__place {
  display: block;
  margin: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
}

[data-toy-fs] .toy-sign__place {
  margin-top: 1px;
  font-size: 10px;
  color: #57534e;
}

[data-toy-fs] .toy-sign--on-dark {
  color: #fffcf7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

[data-toy-fs] .toy-sign--on-dark .toy-sign__place {
  color: rgba(255, 252, 247, 0.78);
}

.figure:has(> .toy-sign) {
  position: relative;
  padding-bottom: 2.6rem !important;
}

[data-toy-fs]:fullscreen > .toy-sign,
[data-toy-fs].is-fs > .toy-sign {
  position: absolute;
  bottom: 0.4rem;
  left: 0.65rem;
  top: auto;
  transform: none;
}

/* Contagion's credit sits on the bottom-left. Keep the mark just above it. */
body.sim-page [data-toy-fs] > .toy-sign {
  bottom: 7.2rem;
}

@media (max-width: 720px) {
  body.sim-page [data-toy-fs] > .toy-sign {
    bottom: 0.3rem;
  }
}
