/* Arcade: loaded after portfolio.css and reuses its tokens and components. */
:root {
  --cube-panel: #d9dee0;
  --chess-panel: #e3dccf;
}
@view-transition {
  navigation: auto;
}
::view-transition-group(*) {
  animation-duration: 420ms;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
.site-header nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 5px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Arcade index */
.project-info .game-card-title {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}
.game-card-title a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 6px;
}
.game-card-title a:hover {
  text-decoration-color: currentColor;
}
@media (max-width: 1000px) {
  .project-info .game-card-title {
    font-size: 25px;
  }
}
.arcade-hero h1 {
  margin-top: 58px;
}
.arcade-hero {
  border-top: 1px solid var(--line);
}
.arcade-intro {
  margin-top: 28px;
  padding-bottom: 32px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.arcade-games {
  padding-top: 70px;
}
.arcade-games .project-pair {
  margin-top: 0;
}
.game-visual {
  gap: 20px;
}
.game-visual .visual-bottomline {
  justify-content: flex-end;
}
.cube-visual {
  background: var(--cube-panel);
  color: #2e3a40;
}
.chess-visual {
  background: var(--chess-panel);
  color: #423a2c;
}
.game-stage-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1.3;
  transform: rotate(-3deg);
  transition: transform 0.35s;
}
.chess-visual .game-stage-preview {
  transform: rotate(2deg);
}
.game-visual:is(:hover, :focus-visible) .game-stage-preview {
  transform: rotate(0);
}
.game-stage-preview img,
.game-stage-preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.game-stage-preview canvas {
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.game-stage-preview canvas.is-live {
  opacity: 1;
}
.game-stage-preview img {
  transition: opacity 0.25s;
}
.game-stage-preview.is-live img {
  opacity: 0;
}
.cube-visual .game-stage-preview,
.cube-page .stage {
  view-transition-name: cube-stage;
}
.chess-visual .game-stage-preview,
.chess-page .stage {
  view-transition-name: chess-stage;
}
.project-pair .game-visual {
  aspect-ratio: auto;
}
.game-record {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.game-record .text-link {
  gap: 20px;
  padding-block: 4px;
  font-size: 13px;
}

/* Game pages */
.game-page {
  padding-block: 30px 90px;
}
.back-link {
  font-size: 13px;
  gap: 20px;
  padding-block: 6px;
}
.back-link::before {
  content: "←";
  font-family: var(--mono);
}
.game-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 40px;
  border-bottom: 1px solid var(--line);
  padding-block: 40px 30px;
  margin-bottom: 36px;
}
.game-heading h1 {
  font-size: clamp(48px, 6.5vw, 92px);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 550;
}
.game-lede {
  max-width: 330px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  padding-bottom: 6px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 45px;
  align-items: start;
}
.stage {
  position: relative;
  height: min(72svh, 760px);
  min-height: 420px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.cube-page .stage {
  background: var(--cube-panel);
}
.chess-page .stage {
  background: var(--chess-panel);
}
.stage-poster,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.stage-poster {
  object-fit: contain;
  padding: 6%;
  transition: opacity 0.25s;
}
.stage.is-live .stage-poster {
  opacity: 0;
}
.stage canvas {
  display: block;
  touch-action: none;
  outline: none;
}
.stage canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--red);
}
.stage-message {
  position: absolute;
  inset: auto 20px 20px;
  background: var(--paper);
  padding: 18px 20px;
  font-size: 14px;
  box-shadow: 0 10px 24px #25251f1f;
  max-width: 420px;
}
.stage-message p + p,
.stage-message p + .button-row {
  margin-top: 12px;
}
.stage-status {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-block: 16px 6px;
  font-size: 12px;
  min-height: 42px;
}
.stage-hint {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.game-panel {
  position: sticky;
  top: 30px;
  display: grid;
  gap: 26px;
}
.stats {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--ink);
}
.stats > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-block: 12px;
}
.stats dt {
  font-size: 13px;
  color: var(--muted);
}
.stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats dd.is-highlight {
  color: var(--red);
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.button {
  min-height: 46px;
  padding: 10px 20px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.button:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}
.button-primary {
  background: var(--ink);
  color: var(--paper);
  flex: 1 1 100%;
}
.button-primary:hover:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
}
.button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.button-small {
  min-height: 44px;
  padding: 6px 14px;
  font-size: 13px;
}
.game-actions .button:not(.button-primary) {
  flex: 1 1 0;
}
.confirm {
  border-left: 2px solid var(--red);
  padding: 4px 0 4px 16px;
  font-size: 14px;
}
.confirm p {
  margin-bottom: 10px;
}
.panel-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
}
.panel-block > .mono,
.panel-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.scramble-text {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  word-spacing: 0.25em;
  min-height: 1.8em;
}
.game-panel details {
  border-top: 1px solid var(--line);
}
.game-panel details summary {
  font-size: 13px;
}
.game-panel details > :not(summary) {
  margin-bottom: 18px;
}
.move-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.move-pad button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
}
.move-pad button:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}
.move-pad button:disabled {
  opacity: 0.38;
}
.key-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.key-list dt {
  font-family: var(--mono);
  color: var(--ink);
}
.key-list dd {
  margin: 0;
}
kbd {
  font-family: var(--mono);
  font-size: 12px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-size: 13px;
  cursor: pointer;
}
.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  margin: 0;
}
.toggle + .toggle {
  margin-top: -6px;
}
.choice-group {
  border: 0;
  margin: 0;
  padding: 0;
}
.choice-group legend {
  padding: 0;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  margin-bottom: 8px;
}
.segmented {
  display: flex;
  border: 1px solid var(--ink);
}
.segmented label {
  flex: 1;
  position: relative;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-size: 13px;
}
.segmented label + label span {
  border-left: 1px solid var(--ink);
}
.segmented input:checked + span {
  background: var(--ink);
  color: var(--paper);
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.choice-group + .choice-group {
  margin-top: 16px;
}

/* Chess */
.move-input {
  display: flex;
  gap: 8px;
}
.move-input input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 8px 12px;
  font: 14px var(--mono);
  color: var(--ink);
}
.move-input input:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.move-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--red);
  min-height: 1.4em;
}
.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 13px;
  counter-reset: none;
}
.move-list li {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  padding-block: 4px;
  border-bottom: 1px solid #cccac180;
}
.move-list .index-number {
  color: var(--muted);
  font-size: 12px;
}
.move-list .is-last {
  color: var(--red);
}
.move-list-empty {
  font-size: 13px;
  color: var(--muted);
}
.captures {
  display: grid;
  gap: 6px;
  font-size: 18px;
  line-height: 1;
}
.captures > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.captures > div:empty {
  display: none;
}
.captures .mono {
  font-size: 11px;
  color: var(--muted);
}
.promotion {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 18px;
  box-shadow: 0 14px 30px #25251f2e;
}
.promotion p {
  font-size: 13px;
  margin-bottom: 12px;
}
.promotion .button-row .button {
  min-width: 64px;
  font-size: 22px;
  padding: 4px 10px;
}
.game-over {
  position: absolute;
  inset: auto 20px 20px;
  max-width: 360px;
  background: var(--paper);
  padding: 20px 22px;
  box-shadow: 0 14px 30px #25251f2e;
}
.game-over h2 {
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}
.game-over .button-primary {
  flex: 1 1 auto;
}
dialog.new-game {
  border: 0;
  padding: 26px;
  width: min(92vw, 380px);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 50px #25251f40;
}
dialog.new-game::backdrop {
  background: #25251f66;
}
dialog.new-game h2 {
  font-size: 34px;
  margin-bottom: 20px;
  letter-spacing: -0.04em;
}
dialog.new-game .button-row {
  margin-top: 24px;
}
.thinking::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--red);
  vertical-align: middle;
  animation: pulse 0.9s ease-in-out infinite alternate;
}
@keyframes pulse {
  from {
    opacity: 0.2;
  }
}

@media (max-width: 1000px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
  }
}
@media (max-width: 800px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .game-heading {
    flex-direction: column;
    align-items: start;
    gap: 14px;
    padding-block: 26px 22px;
    margin-bottom: 0;
    border-bottom: 0;
  }
  .game-heading h1 {
    font-size: 56px;
  }
  .stage {
    margin-inline: calc(var(--gutter) * -1);
    height: min(100vw, 62svh);
    min-height: 300px;
  }
  .stage-hint {
    display: none;
  }
  .game-panel {
    position: static;
    gap: 22px;
  }
  .stats {
    grid-template-columns: repeat(3, 1fr);
    border-top: 0;
  }
  .stats > div {
    flex-direction: column;
    gap: 2px;
  }
  .stats dd {
    font-size: 18px;
  }
  .game-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-inline: calc(var(--gutter) * -1);
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--line);
    flex-wrap: nowrap;
    order: -1;
  }
  .game-actions .button {
    min-height: 48px;
    padding-inline: 10px;
  }
  .game-actions .button-primary {
    flex: 1.4 1 0;
  }
  .game-over,
  .stage-message {
    inset: auto 12px 12px;
  }
}
@media (max-width: 700px) {
  .arcade-hero h1 {
    margin-top: 45px;
  }
  .arcade-games {
    padding-top: 45px;
  }
  .game-stage-preview {
    aspect-ratio: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .thinking::after {
    animation: none;
  }
}

/* ── Homepage cohesion: rounded panels, pill controls, liquid-metal actions ── */
.cohesion .arcade-hero { border-top: 0; text-align: center; padding-top: 44px; }
.cohesion .arcade-hero h1 { margin-top: 0; font-size: clamp(42px, 5.6vw, 76px); font-weight: 600; letter-spacing: -.05em; line-height: 1.08; }
.cohesion .arcade-hero h1 em { font-size: 1.12em; }
.arcade-eyebrow { display: inline-block; margin-bottom: 20px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 30px; font-size: 12px; color: var(--muted); }
.cohesion .arcade-intro { margin-top: 16px; padding-bottom: 0; border-bottom: 0; font-size: 16px; }
.cohesion .arcade-games { padding-top: 34px; }
.cohesion .game-visual { border-radius: 32px; padding: 30px 30px 24px; }
.cohesion .game-visual .visual-bottomline { position: static; justify-content: flex-end; }
.cohesion .project-info .game-card-title { font-size: 32px; font-weight: 600; }
.cohesion .game-card-title a { text-decoration: none; }
.play-pill { text-transform: none; letter-spacing: -.01em; padding: 12px 26px; font-family: var(--sans); font-size: 14px; pointer-events: none; }
.game-visual:is(:hover, :focus-visible) .play-pill { transform: translateY(-2px); }
.game-visual:focus-visible { outline: 2px solid var(--red); outline-offset: 5px; }

/* Game pages */
.cohesion .back-link { font-size: 13px; }
.cohesion .game-heading { border-bottom: 0; padding-block: 34px 6px; margin-bottom: 26px; }
.cohesion .game-heading h1 { font-weight: 600; letter-spacing: -.055em; }
.cohesion .stage { border-radius: 32px; }
.cohesion .stage-message, .cohesion .promotion, .cohesion .game-over { border-radius: 22px; background: #fff; box-shadow: 0 16px 34px -12px #17172938; }
.cohesion dialog.new-game { border-radius: 28px; background: #fff; }
.cohesion dialog.new-game::backdrop { background: #17172966; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.cohesion .stage-hint { border-top: 0; padding-top: 4px; }
.cohesion .game-panel { padding: 26px; border-radius: 32px; background: #f8f8fa; }
.cohesion .panel-block, .cohesion .game-panel details { border-top-color: #e7e7eb; }
.cohesion .stats { border-top-color: #e7e7eb; }
.cohesion .stats > div { border-bottom-color: #e7e7eb; }

.cohesion .button {
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #dcdce3;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s, background .2s, color .2s;
}
.cohesion .button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); border-color: transparent; }
.cohesion .button:active:not(:disabled) { transform: translateY(1px); }
.cohesion .button-primary { background: var(--ink); color: #fff; box-shadow: 0 10px 20px -10px #171719a6; }
.cohesion .button-primary:hover:not(:disabled) { background: #000; color: #fff; box-shadow: 0 12px 22px -10px #171719c0; }
.cohesion .button:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.cohesion .segmented { border: 0; padding: 4px; gap: 2px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px #dcdce3; }
.cohesion .segmented span { border-radius: 999px; min-height: 36px; }
.cohesion .segmented label + label span { border-left: 0; }
.cohesion .segmented input:checked + span { background: var(--ink); color: #fff; }
.cohesion .move-pad button { border: 0; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1px #dcdce3; }
.cohesion .move-input input { border-radius: 999px; }
@media (max-width: 720px) {
  .cohesion .game-visual { padding: 22px 20px 18px; border-radius: 26px; }
  .cohesion .game-panel { padding: 20px; border-radius: 26px; }
  .cohesion .stage { border-radius: 26px; }
}
