/* Intelligence Cafe Arcade — playable game surfaces plus companion rail. */

.cafe-arcade-shell {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  min-height: 100%;
  flex-direction: column;
  border: 1px solid var(--module-border, oklch(0.62 0.014 286.32));
  border-radius: 0.625rem;
  background: var(--module-surface, oklch(1 0 0));
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  padding: 1.25rem;
}

.cafe-arcade-body {
  display: flex;
  min-height: 100%;
  flex: 1 1 auto;
  flex-direction: column;
}

.cafe-arcade-status {
  min-height: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.cafe-arcade-meter {
  font-variant-numeric: tabular-nums;
}

.cafe-play-frame {
  container-name: cafe-play;
  container-type: inline-size;
  width: 100%;
  min-height: 100%;
  flex: 1 1 auto;
}

.cafe-play-stage {
  display: grid;
  width: min(100%, 1100px);
  max-width: 1100px;
  min-height: 100%;
  grid-template-columns: minmax(0, max-content) minmax(260px, 340px);
  align-items: stretch;
  justify-content: start;
  column-gap: 22px;
  row-gap: 14px;
}

.cafe-play-main {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-direction: column;
  gap: 0.9rem;
}

.cafe-play-board {
  min-width: 0;
  max-width: 100%;
}

.cafe-play-board .crossword-board,
.cafe-play-board .sudoku-board,
.cafe-play-board .chess-board,
.cafe-play-board .checkers-board,
.cafe-play-board .memory-grid {
  width: fit-content;
  max-width: 100%;
}

.cafe-play-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.cafe-play-aside {
  display: flex;
  min-width: 260px;
  max-width: 340px;
  min-height: 100%;
  flex-direction: column;
  gap: 0.75rem;
}

.cafe-play-card {
  border: 1px solid var(--module-border, oklch(0.62 0.014 286.32));
  border-radius: 0.7rem;
  background: var(--module-surface, oklch(1 0 0));
  padding: 0.85rem 0.9rem;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
}

.cafe-play-ref {
  flex: 1 1 auto;
}

.cafe-play-kicker {
  margin: 0 0 0.35rem;
  color: var(--module-muted-fg, oklch(0.552 0.016 285.938));
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cafe-play-goal-line,
.cafe-play-note {
  margin: 0;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.9rem;
  line-height: 1.45;
}

.cafe-play-live {
  margin: 0.55rem 0 0;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.cafe-play-formula {
  margin: 0.4rem 0 0;
  color: var(--module-muted-fg, oklch(0.552 0.016 285.938));
  font-size: 0.75rem;
  line-height: 1.4;
  text-wrap: pretty;
}

.cafe-play-best {
  margin: 0.35rem 0 0;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.cafe-board-meter {
  margin: 0 0 0.55rem;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.cafe-play-steps {
  display: flex;
  margin: 0;
  padding-left: 1.15rem;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.8125rem;
  line-height: 1.45;
}

.cafe-clue-heading {
  margin: 0.7rem 0 0.25rem;
  color: var(--module-muted-fg, oklch(0.552 0.016 285.938));
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cafe-clue-heading:first-child {
  margin-top: 0;
}

.cafe-clue-list {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-direction: column;
  gap: 0.35rem;
}

.cafe-clue-list li {
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.8125rem;
  line-height: 1.4;
}

.cafe-clue-dir {
  font-weight: 700;
}

.crossword-cell {
  position: relative;
}

.crossword-cell.is-block {
  border-color: #080d16;
  background: #080d16;
  pointer-events: none;
}

.crossword-num {
  position: absolute;
  top: 0.12rem;
  left: 0.18rem;
  z-index: 1;
  color: #9ca3af;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.crossword-cell.is-correct {
  border-color: rgba(112, 212, 202, 0.55);
  background: rgba(112, 212, 202, 0.12);
}

.crossword-cell.is-wrong {
  border-color: rgba(228, 154, 154, 0.7);
  background: rgba(228, 154, 154, 0.12);
}

.crossword-cell input {
  font-variant-numeric: tabular-nums;
}

.connections-grid {
  width: min(100%, 34rem);
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 639px) {
  .connections-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.word-card {
  min-height: 44px;
  touch-action: manipulation;
}

.word-card:active:not(:disabled) {
  transform: scale(0.96);
}

.connections-solved-bank {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.connections-solved-bank:empty {
  display: none;
}

.connections-solved-row {
  border: 1px solid rgba(112, 212, 202, 0.4);
  border-radius: 0.7rem;
  background: rgba(112, 212, 202, 0.1);
  padding: 0.65rem 0.8rem;
  color: #70d4ca;
}

.sudoku-cell {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  touch-action: manipulation;
}

.sudoku-cell input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  caret-color: var(--module-fg, oklch(0.141 0.005 285.823));
}

.sudoku-cell input:focus {
  outline: 0;
}

.sudoku-cell input:focus-visible {
  outline: 2px solid #d5ae6e;
  outline-offset: -3px;
}

.sudoku-cell.is-conflict {
  border-color: rgba(228, 154, 154, 0.85);
  background: rgba(228, 154, 154, 0.16);
  color: #fecaca;
}

.number-button {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.number-button:active:not(:disabled) {
  transform: scale(0.96);
}

.cafe-play-pad {
  width: fit-content;
  max-width: 100%;
}

.memory-grid {
  display: grid;
  width: fit-content;
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(4.25rem, 5.25rem));
  gap: 0.5rem;
}

.memory-card {
  display: flex;
  min-width: 44px;
  min-height: 44px;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--module-border, oklch(0.62 0.014 286.32));
  border-radius: 0.55rem;
  background: var(--module-surface-raised, oklch(1 0 0));
  padding: 0.2rem;
  color: var(--module-fg, oklch(0.141 0.005 285.823));
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  touch-action: manipulation;
  transition-property: background-color, border-color, transform;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.memory-card.is-up {
  background: var(--module-surface, oklch(1 0 0));
}

.memory-card.is-matched {
  border-color: rgba(112, 212, 202, 0.55);
  background: rgba(112, 212, 202, 0.12);
}

.memory-back {
  color: var(--muted-foreground, #9ca3af);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.memory-card:focus-visible,
.word-card:focus-visible,
.number-button:focus-visible,
.chess-square:focus-visible,
.checkers-square:focus-visible,
.spark-tile:focus-visible,
.crossword-cell input:focus-visible {
  outline: 2px solid #d5ae6e;
  outline-offset: 2px;
}

.memory-card:active:not(:disabled) {
  transform: scale(0.96);
}

.memory-card:disabled,
.memory-card.is-matched,
.chess-square:disabled,
.checkers-square:disabled,
.word-card:disabled {
  opacity: 1;
}

.chess-board {
  touch-action: manipulation;
}

.chess-square {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  cursor: pointer;
}

.chess-square.is-selected {
  box-shadow: inset 0 0 0 3px rgba(213, 174, 110, 0.95);
}

.chess-square.is-origin {
  box-shadow: inset 0 0 0 3px rgba(213, 174, 110, 0.9);
}

.chess-square.is-win {
  box-shadow: inset 0 0 0 3px rgba(112, 212, 202, 0.95);
}

.chess-square.is-miss {
  box-shadow: inset 0 0 0 3px rgba(228, 154, 154, 0.95);
}

.chess-square:active:not(:disabled) {
  transform: scale(0.96);
}

.checkers-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(2.5rem, 3.25rem));
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--module-border, oklch(0.62 0.014 286.32));
  border-radius: 0.5rem;
  touch-action: manipulation;
}

.checkers-square {
  display: flex;
  min-width: 40px;
  min-height: 40px;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: #d2c5ad;
  cursor: pointer;
}

.checkers-square:disabled {
  cursor: default;
}

.checkers-square.is-dark {
  background: #4d5d4a;
}

.checkers-square.is-origin {
  box-shadow: inset 0 0 0 3px rgba(213, 174, 110, 0.55);
}

.checkers-square.is-selected {
  box-shadow: inset 0 0 0 3px rgba(213, 174, 110, 0.95);
}

.checkers-square.is-move {
  box-shadow: inset 0 0 0 3px rgba(213, 174, 110, 0.9);
}

.checkers-square.is-capture {
  box-shadow: inset 0 0 0 3px rgba(228, 154, 154, 0.95);
}

.checkers-square:active:not(:disabled) {
  transform: scale(0.96);
}

.checkers-man {
  display: block;
  width: 68%;
  height: 68%;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.35);
}

.checkers-man.is-dark {
  background: radial-gradient(circle at 32% 28%, #6b4334, #24140f);
}

.checkers-man.is-light {
  background: radial-gradient(circle at 32% 28%, #f6f1e6, #cbbfa6);
}

.checkers-man.is-king {
  box-shadow:
    inset 0 0 0 3px rgba(213, 174, 110, 0.95),
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.35);
}

.spark-pad {
  display: grid;
  width: min(100%, 22.5rem);
  aspect-ratio: 1;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 0.7rem;
}

.spark-tile {
  display: flex;
  min-width: 72px;
  min-height: 72px;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--module-border, oklch(0.62 0.014 286.32));
  border-radius: 1.15rem;
  background: var(--module-surface, oklch(1 0 0));
  padding: 0.35rem;
  color: #1a1208;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  cursor: pointer;
  touch-action: manipulation;
  transition-property: background-color, border-color, transform, box-shadow;
  transition-duration: 180ms;
  transition-timing-function: ease-out;
}

.spark-tile.is-lit {
  border-color: rgba(213, 174, 110, 0.9);
  background: radial-gradient(circle at 38% 30%, #f6e2bc, #d5ae6e 55%, #8a5a22);
  box-shadow: 0 10px 28px rgba(213, 174, 110, 0.28);
  color: #1a1208;
  animation: spark-fade var(--spark-life, 1.2s) linear forwards;
}

@keyframes spark-fade {
  0% {
    filter: saturate(1.05);
    box-shadow: 0 10px 28px rgba(213, 174, 110, 0.34);
  }
  100% {
    filter: saturate(0.7);
    box-shadow: 0 0 0 rgba(213, 174, 110, 0);
    background: var(--module-surface, oklch(1 0 0));
    color: #9ca3af;
  }
}

.spark-tile.is-hit {
  border-color: rgba(112, 212, 202, 0.7);
  background: rgba(112, 212, 202, 0.18);
  color: #d7f7f3;
}

.spark-tile.is-miss {
  border-color: rgba(228, 154, 154, 0.75);
  background: rgba(228, 154, 154, 0.16);
  color: #fecaca;
}

.spark-tile:active:not(:disabled) {
  transform: scale(0.96);
}

.spark-tile:disabled {
  cursor: default;
  opacity: 1;
}

@media (max-width: 639px) {
  .memory-grid {
    width: 100%;
    grid-template-columns: repeat(4, minmax(44px, 1fr));
  }

  .checkers-board {
    grid-template-columns: repeat(8, minmax(40px, 1fr));
    width: 100%;
  }

  .spark-pad {
    width: 100%;
    grid-template-columns: repeat(3, minmax(44px, 1fr));
  }

  .spark-tile {
    min-width: 44px;
    min-height: 44px;
  }
}

@container cafe-play (max-width: 680px) {
  .cafe-play-stage {
    display: flex;
    max-width: none;
    flex-direction: column;
    gap: 0.9rem;
  }

  .cafe-play-main,
  .cafe-play-aside {
    display: contents;
  }

  .cafe-play-aside {
    min-width: 0;
    max-width: none;
  }

  .cafe-play-goal { order: 1; }
  .cafe-play-board { order: 2; }
  .cafe-play-pad { order: 3; }
  .cafe-play-actions { order: 4; }
  .cafe-play-howto { order: 5; }
  .cafe-play-ref { order: 6; }
}

@media (max-width: 720px) {
  .cafe-play-stage {
    display: flex;
    max-width: none;
    flex-direction: column;
    gap: 0.9rem;
  }

  .cafe-play-main,
  .cafe-play-aside {
    display: contents;
  }

  .cafe-play-aside {
    min-width: 0;
    max-width: none;
  }

  .cafe-play-goal { order: 1; }
  .cafe-play-board { order: 2; }
  .cafe-play-pad { order: 3; }
  .cafe-play-actions { order: 4; }
  .cafe-play-howto { order: 5; }
  .cafe-play-ref { order: 6; }
}

@media (prefers-reduced-motion: reduce) {
  .word-card:active:not(:disabled),
  .number-button:active:not(:disabled),
  .memory-card:active:not(:disabled),
  .chess-square:active:not(:disabled),
  .checkers-square:active:not(:disabled),
  .spark-tile:active:not(:disabled) {
    transform: none;
  }

  .memory-card,
  .spark-tile {
    transition-duration: 0ms;
  }

  .spark-tile.is-lit {
    animation: none;
  }
}
