/*
 * Cubo da Velha: a Rubik's cube resting on a notebook.
 * Cube language: glossy stickers set in black plastic frames, in the six classic colors.
 * Tic-tac-toe language: graph paper, pencil handwriting, a marker highlight, X and O tokens.
 */

/* 1. Tokens */
/* ink is writing on the paper; plastic is the cube's black body and the frames around stickers;
   sticker-ink is writing on a sticker; chalk is writing on the plastic. Only the paper side
   changes in the dark theme: the cube's plastic and stickers stay the same toy. */
:root {
  --ink: #1c1b22;
  --ink-soft: #45435a;
  --pencil: #34324a;
  --page: #f8f5ec;
  --paper: #fffdf8;
  --grid-line: #dbe5f3;
  --rule: #e7dfcb;
  --plastic: #1c1b22;
  --sticker-ink: #1c1b22;
  --chalk: #fffdf8;
  --floor: #d8cdb4;
  --glow: linear-gradient(transparent, transparent);
  --tape: rgba(255, 214, 10, 0.55);
  --st-white: #ffffff;
  --st-yellow: #ffd60a;
  --st-red: #c8102e;
  --st-orange: #f26b12;
  --st-blue: #1565e0;
  --st-green: #10a85a;
  --st-sky: #dbe7ff;
  --x: var(--st-red);
  --x-deep: #8f0b20;
  --o: var(--st-blue);
  --o-deep: #0c3f9c;
  --marker: rgba(255, 214, 10, 0.6);
  --note: #fff3a8;
  --gloss: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 48%);
  --graph: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  --paper-shadow: 0 1px 0 rgba(28, 27, 34, 0.08), 0 16px 30px -14px rgba(28, 27, 34, 0.3);
  --sticker-depth: inset 0 -4px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --hand: 'Caveat', 'Comic Sans MS', cursive;
  --chosen: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><circle cx='16' cy='16' r='13' fill='white' stroke='%231c1b22' stroke-width='3'/><path d='M11 11l10 10M21 11L11 21' stroke='%23c8102e' stroke-width='4' stroke-linecap='round'/></svg>");
  font-family: var(--body);
  font-weight: 700;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}
/* Night theme: the notebook on a desk under a deep indigo sky, lit from above with a violet
   glow. Sheets turn navy, the highlighter turns cyan; the cube keeps its toy colors. */
:root[data-theme='dark'] {
  --ink: #f1efff;
  --ink-soft: #aeb3dd;
  --pencil: #d4d8ff;
  --page: #151937;
  --paper: #1f2450;
  --grid-line: rgba(130, 150, 255, 0.1);
  --rule: #343a72;
  --plastic: #0a0c1f;
  --floor: rgba(0, 0, 0, 0.5);
  --glow: radial-gradient(ellipse 120% 70% at 50% -10%, rgba(120, 95, 255, 0.38), transparent 70%);
  --x-deep: #ff7a90;
  --o-deep: #8ab8ff;
  --marker: rgba(77, 200, 255, 0.35);
  --tape: rgba(255, 214, 10, 0.85);
  --note: #2c3270;
  --paper-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 18px 34px -14px rgba(0, 0, 0, 0.75);
  --ui-popover: #1f2450;
  --ui-foreground: #f1efff;
  --ui-muted-foreground: #aeb3dd;
  --ui-accent: #2c3270;
  --ui-muted: #2c3270;
  --ui-border: #0a0c1f;
  color-scheme: dark;
}

/* 2. Base */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--page);
  background-image: var(--glow), var(--graph);
  background-size: 100% 100dvh, 26px 26px, 26px 26px;
  background-repeat: no-repeat, repeat, repeat;
}
button,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  min-height: 44px;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--o);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--o-deep);
}
h1,
h2,
h3,
p {
  margin: 0;
}
select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--paper);
  border: 3px solid var(--plastic);
  border-radius: 10px;
  font-size: 14px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

/* 3. Primitives */

/* Frames: black plastic that holds a row of stickers, like a strip of the cube. */
.choice-group,
.result-actions,
.inspect-controls {
  display: grid;
  gap: 5px;
  padding: 5px;
  background: var(--plastic);
  border-radius: 14px;
}

/* Stickers: glossy tiles inside a frame; pressing sinks the sticker into the plastic. */
.choice-group button,
.result-actions button,
.inspect-controls button,
.icon-button,
.primary-button,
.secondary-button {
  position: relative;
  border: 0;
  border-radius: 9px;
  background: var(--gloss), var(--tone, var(--st-white));
  color: var(--tone-ink, var(--sticker-ink));
  font-weight: 900;
  box-shadow: var(--sticker-depth);
  transition: transform 0.08s ease-out, filter 0.15s, background-color 0.2s;
}
.choice-group button:active:not(:disabled),
.result-actions button:active:not(:disabled),
.inspect-controls button:active:not(:disabled),
.icon-button:active:not(:disabled),
.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}
@media (hover: hover) {
  .choice-group button:hover:not(:disabled),
  .result-actions button:hover:not(:disabled),
  .icon-button:hover:not(:disabled),
  .primary-button:hover:not(:disabled),
  .secondary-button:hover:not(:disabled) {
    filter: brightness(1.05) saturate(1.05);
  }
}
/* Standalone stickers carry their own frame as a thick black border. */
.icon-button,
.primary-button,
.secondary-button {
  border: 4px solid var(--plastic);
  border-radius: 13px;
}
.primary-button {
  --tone: var(--st-green);
}
.secondary-button {
  --tone: var(--st-white);
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-height: 46px;
  font-size: 20px;
  line-height: 1;
}

/* Chosen sticker: it lights up in its color and gets an X token, as if marked on the board. */
.choice-group button[aria-pressed='true'] {
  background: var(--gloss), var(--pick);
  color: var(--pick-ink, var(--sticker-ink));
}
.choice-group button[aria-pressed='true']::after {
  content: '';
  position: absolute;
  top: -8px;
  right: -6px;
  width: 30px;
  height: 30px;
  background: var(--chosen) center / contain no-repeat;
  animation: bounce-in 0.3s ease-out;
}
/* Unchosen stickers stay white with a corner chip of their color, so every option keeps its identity. */
.choice-group button::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 7px;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--pick);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.2);
}
.choice-group button[aria-pressed='true']::before {
  display: none;
}
[data-setting='game-mode'][data-value='local'] {
  --pick: var(--st-blue);
  --pick-ink: var(--st-white);
}
[data-setting='game-mode'][data-value='bot'] {
  --pick: var(--st-orange);
}
[data-setting='series'][data-value='1'] {
  --pick: var(--st-white);
}
[data-setting='series'][data-value='3'] {
  --pick: var(--st-blue);
  --pick-ink: var(--st-white);
}
[data-setting='line-color'][data-value='any'] {
  --pick: var(--st-white);
}
[data-setting='line-color'][data-value='same'] {
  --pick: var(--st-green);
  --pick-ink: var(--st-white);
}
.line-color-choices,
.series-choices {
  grid-template-columns: 1fr 1fr;
}
.skin-choices {
  grid-template-columns: repeat(3, 1fr);
}
.skin-choices button {
  --pick: var(--st-yellow);
}
.skin-choices button::before {
  display: none;
}
/* Each skin shows six of its stickers set in its own plastic. */
.skin-swatch {
  display: grid;
  grid-template-columns: repeat(3, 16px);
  gap: var(--skin-gap);
  justify-content: center;
  width: max-content;
  margin: 0 auto 8px;
  padding: var(--skin-gap);
  background: var(--skin-body);
  border-radius: 6px;
}
.skin-swatch canvas {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}
/* Names go on paper labels next to each player's token. */
.name-fields {
  display: grid;
  gap: 8px;
}
.name-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.name-field[hidden] {
  display: none;
}
.name-field input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  border: 3px solid var(--plastic);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--sticker-depth);
  /* 16px or more keeps iOS from zooming in on focus. */
  font: 800 16px var(--body);
  color: var(--ink);
}
.name-field input::placeholder {
  color: var(--ink-soft);
  opacity: 0.6;
}
.name-field input:focus-visible {
  outline: 3px solid var(--st-yellow);
  outline-offset: 2px;
}
/* Pencil: headings and notes are handwritten; the marker underline points out the important ones. */
.panel-title,
.setup-field h2,
.setup-field > label,
.menu-heading h2,
.rules-dialog h3 {
  font-family: var(--hand);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--pencil);
}
.panel-title::after,
.setup-field h2::after,
.setup-field > label::after {
  content: '';
  display: block;
  width: 64px;
  height: 7px;
  margin-top: 3px;
  background: var(--marker);
  border-radius: 4px;
  transform: rotate(-2deg);
}
.feedback,
.setup-copy,
.setup-summary,
.board-caption,
.face-hint,
.eyebrow,
.setup-badge,
.action-help,
.game-goal {
  font-family: var(--hand);
  font-weight: 700;
  color: var(--pencil);
}

/* Paper: sheets of graph paper that hold the setup and the side panels. */
.setup-form,
.match-panel,
.control-panel,
.face-view,
.game-menu,
.rules-dialog {
  background: var(--graph), var(--paper);
  background-size: 26px 26px, auto;
  border: 2px solid var(--plastic);
  border-radius: 18px;
  box-shadow: var(--paper-shadow);
}

/* 4. Top bar and wordmark */
.shell {
  max-width: 1080px;
  margin: auto;
  padding: 0 32px;
}
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sound-toggle {
  width: 40px;
  min-height: 40px;
}
/* A pencil slash over the icon says "muted" without relying on color. */
.sound-toggle[aria-pressed='false'] {
  opacity: 0.7;
}
.sound-toggle[aria-pressed='false']::after {
  content: '';
  position: absolute;
  inset: 45% 6px auto;
  height: 3px;
  border-radius: 2px;
  background: var(--sticker-ink);
  transform: rotate(-45deg);
}
/* The menu's copy is only needed where the top bar hides it. */
#toggle-theme-menu {
  display: none;
}
@media (max-width: 420px) {
  body:not([data-stage='setup']) #toggle-theme-menu {
    display: flex;
  }
}
/* The button shows where it leads: a moon on the light page, a sun on the dark one. */
.theme-toggle {
  width: 40px;
  min-height: 40px;
}
:root[data-theme='dark'] .theme-moon,
:root:not([data-theme='dark']) .theme-sun {
  display: none;
}
.setup-badge {
  font-size: 24px;
  transform: rotate(-3deg);
}
/* The setup screen already shows the large wordmark, so the small one returns only during a match. */
body[data-stage='setup'] .topbar .brand {
  visibility: hidden;
}
body[data-stage='setup'] .topbar {
  height: 52px;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.wordmark-cube {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--plastic);
  border-radius: 10px;
}
.wordmark-cube b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--gloss), var(--sticker);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: var(--st-white);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.wordmark-cube b:nth-child(3) {
  color: var(--sticker-ink);
  text-shadow: none;
}
.wordmark-hand {
  font-family: var(--hand);
  font-size: 28px;
  line-height: 1;
  color: var(--pencil);
  transform: rotate(-4deg) translateY(2px);
}
.brand:hover .wordmark-cube b,
.wordmark-cube.scrambling b {
  animation: sticker-swap 0.9s steps(1) both;
}
.wordmark-cube b:nth-child(even) {
  animation-delay: 0.15s;
}

/* 5. Setup screen */
/* Columns share a top edge; on tall screens the pair is centered so it never sticks to the top. */
.setup-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  align-content: center;
  gap: 90px;
  max-width: 920px;
  min-height: calc(100dvh - 52px - 64px);
  margin: auto;
  padding: 0 0 24px;
}
/* On wide screens the title leads and the cube sits under it, so the name is the first thing read. */
.setup-intro {
  display: flex;
  flex-direction: column;
}
.setup-art {
  order: 1;
  position: relative;
  display: block;
  width: 300px;
  aspect-ratio: 240 / 262;
  margin: 26px 0 0 24px;
}
.hero-fallback {
  display: block;
  width: 100%;
  height: auto;
  animation: float 4s ease-in-out infinite;
}
.setup-art.is-live .hero-fallback {
  display: none;
}
.setup-art.is-live canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  pointer-events: none;
}
.setup-art.is-live::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 6%;
  border-radius: 50%;
  background: var(--floor);
}
.eyebrow {
  font-size: 26px;
  margin-bottom: 6px;
}
.hero-title {
  margin: 4px 0 10px;
}
.wordmark-large {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}
.wordmark-large .wordmark-cube {
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  transform: rotate(-2deg);
  box-shadow: 0 14px 24px -12px rgba(28, 27, 34, 0.5);
}
.wordmark-large .wordmark-cube b {
  width: 66px;
  height: 66px;
  border-radius: 11px;
  font-size: 48px;
  animation: bounce-in 0.4s ease-out both;
}
.wordmark-large .wordmark-cube b:nth-child(2) {
  animation-delay: 0.08s;
}
.wordmark-large .wordmark-cube b:nth-child(3) {
  animation-delay: 0.16s;
}
.wordmark-large .wordmark-cube b:nth-child(4) {
  animation-delay: 0.24s;
}
.wordmark-large .wordmark-hand {
  font-size: 66px;
  margin: -6px 0 0 110px;
}
.setup-copy {
  font-size: 25px;
  line-height: 1.2;
  max-width: 340px;
}
.setup-form {
  position: relative;
  min-width: 0;
  padding: 24px 24px 18px;
}
/* A strip of tape holds the sheet to the page. */
.setup-form::before {
  content: '';
  position: absolute;
  top: -13px;
  left: 50%;
  width: 104px;
  height: 26px;
  background: var(--tape);
  border-left: 2px dashed rgba(28, 27, 34, 0.15);
  border-right: 2px dashed rgba(28, 27, 34, 0.15);
  transform: translateX(-50%) rotate(-3deg);
}
/* Setup tabs: a plastic frame like the board switch; the open tab is the lit yellow sticker. */
.setup-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 16px;
  padding: 5px;
  background: var(--plastic);
  border-radius: 14px;
}
.setup-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--chalk);
  font-family: var(--display);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.setup-tabs button[aria-selected='true'] {
  background: var(--gloss), var(--st-yellow);
  color: var(--sticker-ink);
  box-shadow: var(--sticker-depth);
}
.setup-tabs svg {
  width: 18px;
  height: 18px;
}
/* The panels share one cell, so the sheet keeps the tallest one's height and the start button
   stays put when switching tabs. */
.setup-panels {
  display: grid;
}
.setup-panel {
  grid-area: 1 / 1;
}
.setup-panel:not(.is-open) {
  visibility: hidden;
}
.theme-choices {
  grid-template-columns: 1fr 1fr;
}
.theme-choices .choice-icon {
  margin-bottom: 2px;
}
[data-theme-choice='light'] {
  --pick: var(--st-yellow);
}
[data-theme-choice='dark'] {
  --pick: var(--st-blue);
  --pick-ink: var(--st-white);
}
.setup-field {
  margin-bottom: 14px;
}
.setup-field h2,
.setup-field > label {
  display: block;
  margin-bottom: 8px;
}
.opponent-choices {
  grid-template-columns: repeat(3, 1fr);
}
[data-setting='game-mode'][data-value='online'] {
  --pick: var(--st-green);
}
/* Online: the two ways in are full-width stickers, the code goes on a paper label beside its button. */
.online-choices,
.online-wait {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.online-choices[hidden],
.online-wait[hidden] {
  display: none;
}
.online-choices > button {
  width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: left;
}
.online-choices small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}
.join-room {
  display: flex;
  gap: 8px;
}
.join-room input {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  padding: 8px 12px;
  border: 3px solid var(--plastic);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--sticker-depth);
  /* 16px or more keeps iOS from zooming in on focus. */
  font: 900 20px var(--body);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--ink);
}
.join-room input::placeholder {
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-soft);
  opacity: 0.6;
}
.join-room input:focus-visible {
  outline: 3px solid var(--st-yellow);
  outline-offset: 2px;
}
.online-note,
.online-status {
  font-family: var(--hand);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--pencil);
}
.online-status.error {
  color: var(--x);
}
.room-code {
  justify-self: center;
  padding: 6px 18px;
  font: 400 40px var(--display);
  letter-spacing: 8px;
  background: var(--paper);
  border: 3px dashed var(--ink);
  border-radius: 12px;
  user-select: all;
}
.online-wait-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.online-wait-actions button {
  flex: 1 1 140px;
}
.choice-group button {
  padding: 12px 8px 10px;
  font-size: 15px;
  line-height: 1.25;
  text-align: center;
}
.choice-group small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}
.choice-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.choice-icon svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.5;
}
.match-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-family: var(--hand);
  font-size: 23px;
  color: var(--pencil);
}
.match-details summary::-webkit-details-marker {
  display: none;
}
.primary-button,
.secondary-button {
  min-height: 54px;
  padding: 12px 18px;
  font-size: 16px;
}
.start-game {
  --tone: var(--st-yellow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 66px;
  border-width: 6px;
  border-radius: 16px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.4px;
}
.start-game span {
  font-size: 22px;
}
.setup-summary {
  margin-top: 12px;
  font-size: 22px;
  text-align: center;
}
.rules-link {
  display: block;
  margin: 6px auto 0;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  font-family: var(--hand);
  font-size: 23px;
  color: var(--pencil);
  cursor: pointer;
}
.rules-link::after {
  content: '↗';
  margin-left: 8px;
}
.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 20px 0 24px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--ink-soft);
}
.site-footer span {
  letter-spacing: 0;
}
body[data-stage='playing'] .site-footer,
body[data-stage='result'] .site-footer {
  display: none;
}

/* 6. Match layout: during a match the page never scrolls; panels and board share the viewport. */
body[data-stage='playing'],
body[data-stage='result'] {
  height: 100dvh;
  overflow: hidden;
}
body[data-stage='playing'] .shell,
body[data-stage='result'] .shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1400px;
}
body[data-stage='playing'] main,
body[data-stage='result'] main {
  flex: 1;
  min-height: 0;
  padding-bottom: 18px;
}
.play-screen {
  height: 100%;
}
.match-panel,
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
}
.board-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.board-area {
  flex: 1;
  min-height: 0;
}

/* Who plays: the player's piece is a sticker in its frame, red for X and blue for O. */
.game-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.turn-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}
.turn-symbol {
  --tone: var(--st-white);
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 5px solid var(--plastic);
  border-radius: 14px;
  background: var(--gloss), var(--tone);
  box-shadow: var(--sticker-depth);
  color: var(--sticker-ink);
  font-family: var(--display);
  font-size: 34px;
  font-weight: 400;
  animation: bounce-in 0.35s ease-out;
}
.turn-symbol.player-X {
  --tone: var(--x);
  color: var(--st-white);
}
.turn-symbol.player-O {
  --tone: var(--o);
  color: var(--st-white);
}
.turn-symbol.flip {
  animation: cubie-flip 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}
/* The coin toss that picks who opens the match. */
.turn-symbol.coin {
  animation: coin-toss 1.1s cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes coin-toss {
  0% {
    transform: translateY(0) rotateY(0);
  }
  45% {
    transform: translateY(-18px) rotateY(900deg);
  }
  100% {
    transform: translateY(0) rotateY(1800deg);
  }
}
/* Long names shrink to an ellipsis instead of pushing the goal off the phone's screen. */
.turn-identity,
.turn-identity > div {
  min-width: 0;
}
#status {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.3px;
}
/* The lead is a pencil note; the name keeps the big type and shrinks a size when long. */
.status-lead {
  font-family: var(--hand);
  font-size: 20px;
  line-height: 0.9;
  color: var(--pencil);
}
.status-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-main.long {
  font-size: 0.8em;
}
#status.player-X {
  color: var(--x-deep);
}
#status.player-O {
  color: var(--o-deep);
}
.opponents {
  display: none;
}
/* The goal is underlined with the yellow marker, like a note on the margin. */
.game-goal {
  padding: 0 4px;
  font-size: 25px;
  line-height: 1.1;
  white-space: nowrap;
  background: linear-gradient(
    transparent 52%,
    var(--marker) 52%,
    var(--marker) 92%,
    transparent 92%
  );
}
.game-goal::before {
  content: 'meta: ';
}
.players {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.players li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 900;
  opacity: 0.45;
  transition: opacity 0.2s;
}
.players[data-turn='X'] li[data-player='X'],
.players[data-turn='O'] li[data-player='O'] {
  opacity: 1;
}
.players[data-turn='X'] li[data-player='X']::after,
.players[data-turn='O'] li[data-player='O']::after {
  content: '← joga';
  font-family: var(--hand);
  font-size: 22px;
  color: var(--pencil);
  animation: nudge 1.2s ease-in-out infinite;
}
.mini-token {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--plastic);
  border-radius: 9px;
  background: var(--gloss), var(--tone);
  box-shadow: var(--sticker-depth);
  color: var(--st-white);
  font-family: var(--display);
  font-size: 19px;
}
.mini-token.player-X {
  --tone: var(--x);
  color: var(--st-white);
}
.mini-token.player-O {
  --tone: var(--o);
  color: var(--st-white);
}
body[data-stage='result'] .players[data-turn='X'] li[data-player='X']::after,
body[data-stage='result'] .players[data-turn='O'] li[data-player='O']::after {
  content: '← venceu';
}
/* Win chance: a strip of the two players' colors, with draws in pencil gray between them. */
.win-chance {
  display: grid;
  gap: 4px;
}
.chance-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--plastic);
  border-radius: 6px;
  background: var(--paper);
}
.chance-bar span {
  flex: var(--grow) 1 0;
  transition: flex-grow 0.6s ease-out;
}
.chance-bar .chance-X {
  --grow: var(--chance-X);
  background: var(--x);
}
.chance-bar .chance-draw {
  --grow: var(--chance-draw);
  background: var(--rule);
}
.chance-bar .chance-O {
  --grow: var(--chance-O);
  background: var(--o);
}
.chance-text {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chance-text .chance-label {
  font-family: var(--hand);
  font-size: 18px;
  line-height: 0.8;
  color: var(--pencil);
}
.chance-text .chance-X {
  color: var(--x-deep);
}
.chance-text .chance-draw {
  color: var(--ink-soft);
}
.chance-text .chance-O {
  color: var(--o-deep);
}
/* Round mode: the round count in pencil and the next cube turn on a note with the marker. */
.round-info {
  display: grid;
  gap: 6px;
}
.round-count {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--pencil);
}
.next-turn {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: 10px;
}
/* The room's clock: a quiet pencil note that turns red in the last seconds of your turn. */
.turn-clock {
  font-family: var(--hand);
  font-size: 22px;
  font-weight: 700;
  color: var(--pencil);
}
.turn-clock.urgent {
  color: var(--x);
  animation: bounce-in 0.3s ease-out;
}
.series-wins {
  margin-left: auto;
  font-family: var(--hand);
  font-size: 20px;
  color: var(--pencil);
}
/* The last move is a sticky note left on the notebook. */
.feedback {
  padding: 10px 14px;
  font-size: 24px;
  line-height: 1.15;
  background: var(--note);
  border-radius: 4px;
  box-shadow: var(--paper-shadow);
  transform: rotate(-1.2deg);
}
.win-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}
.win-summary h3 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
}
.win-summary p {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.win-shape-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 4px solid var(--plastic);
  color: var(--sticker-ink);
  border-radius: 11px;
  background: var(--gloss), var(--st-green);
  box-shadow: var(--sticker-depth);
  font-size: 22px;
  font-weight: 900;
}
body[data-stage='result'] .turn-symbol {
  animation: cheer 0.8s ease-in-out 2;
}

/* Board: the cube stands free on the notebook, over its own shadow, with no sheet around it. */
.cube-panel {
  position: relative;
  height: 100%;
}
.cube-panel::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 4%;
  height: 5%;
  border-radius: 50%;
  background: var(--floor);
  filter: blur(6px);
  opacity: 0.8;
  pointer-events: none;
}
.board-tools {
  position: absolute;
  top: 10px;
  left: 18px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.board-tools button {
  pointer-events: auto;
}
.board-caption {
  font-size: 21px;
}
#cube-stage {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#cube-stage canvas {
  display: block;
  max-width: 100%;
  touch-action: none;
  cursor: grab;
}
#cube-stage canvas:active {
  cursor: grabbing;
}

/* Actions: Marcar is the red sticker and Girar the blue one. */
.turn-controls {
  display: grid;
  gap: 12px;
}
.result-actions {
  grid-template-columns: 1fr 1fr;
}
.action-help {
  font-size: 21px;
  line-height: 1.15;
  text-align: center;
}
.result-actions .primary-button,
.result-actions .secondary-button {
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  font-size: 15px;
}

/* Faces view: the front and the four faces a turn can bring in, unfolded as a cross. */
.face-view {
  height: 100%;
  padding: 14px 16px;
  overflow-y: auto;
}
.face-hint {
  font-size: 21px;
}
.face-board {
  --board-pad: 8px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 14px auto 0;
  padding: var(--board-pad);
  background: var(--plastic);
  border-radius: 20px;
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--tile-art, var(--gloss)) center / cover, var(--tile-color, var(--paper));
  box-shadow: var(--sticker-depth);
  color: var(--sticker-ink);
  font-family: var(--display);
  font-size: 40px;
  line-height: 1;
  transition: transform 0.08s ease-out;
}
.cell:active:not([aria-disabled='true']) {
  transform: scale(0.94);
}
.cell[aria-disabled='true'] {
  cursor: default;
}
.cell.player-X span,
.cell.player-O span {
  display: grid;
  place-items: center;
  width: 72%;
  aspect-ratio: 1;
  background: var(--st-white);
  border: 3px solid var(--plastic);
  border-radius: 50%;
  animation: bounce-in 0.3s ease-out;
}
.coordinate {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--body);
  font-size: 9px;
  font-weight: 900;
  opacity: 0.7;
}
.cell.winning {
  box-shadow: inset 0 0 0 4px var(--st-white), 0 0 0 3px var(--st-green);
}
.mark-svg {
  width: 74%;
  height: 74%;
  overflow: visible;
}
.mark-svg path,
.mark-svg circle {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.player-X .mark-svg path {
  stroke: var(--x);
}
.player-O .mark-svg circle {
  stroke: var(--o);
}
.cell .mark-svg {
  filter: drop-shadow(0 2px 0 rgba(28, 27, 34, 0.25));
}
.cell.fresh span {
  animation: none;
}
.cell.fresh .mark-svg path:nth-child(1),
.cell.fresh .mark-svg circle {
  animation: pen 0.28s ease-out both;
}
.cell.fresh .mark-svg path:nth-child(2) {
  animation: pen 0.24s 0.2s ease-out both;
}
.cross-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    '. U .'
    'L F R'
    '. D .';
  gap: 4px 6px;
  /* The cross is about as tall as it is wide, so it fits between the header and the help strip. */
  width: min(100%, 460px, calc(100dvh - 300px));
  margin: 8px auto 0;
}
.cross-face[data-face='U'] {
  grid-area: U;
}
.cross-face[data-face='L'] {
  grid-area: L;
}
.cross-face[data-face='F'] {
  grid-area: F;
}
.cross-face[data-face='R'] {
  grid-area: R;
}
.cross-face[data-face='D'] {
  grid-area: D;
}
.cross-face h3 {
  margin: 0 0 2px;
  font-family: var(--hand);
  font-size: 16px;
  line-height: 1.1;
  text-align: center;
  color: var(--pencil);
}
.cross-face[data-face='F'] h3 {
  color: var(--ink);
}
.cross-board .face-board {
  --board-pad: 4px;
  gap: 3px;
  width: auto;
  max-width: none;
  margin: 0;
  border-radius: 10px;
}
/* The front is where lines count, so its frame gets the marker yellow. */
.cross-face[data-face='F'] .face-board {
  box-shadow: 0 0 0 3px var(--st-yellow), 0 0 0 5px var(--plastic);
}
.cross-board .cell {
  min-width: 0;
  min-height: 0;
  border-radius: 6px;
  font-size: 18px;
}
.cross-board .cell.player-X span,
.cross-board .cell.player-O span {
  border-width: 2px;
}
.cross-board .coordinate {
  display: none;
}
/* The layer the cube is about to turn gets a white ring and pulses, like the blinking layer on
   the 3D cube; with reduced motion the ring alone marks it. */
.cell.incoming {
  box-shadow: var(--sticker-depth), inset 0 0 0 2px var(--st-white);
  animation: incoming 0.9s ease-in-out infinite alternate;
}
@keyframes incoming {
  to {
    filter: brightness(1.3) saturate(1.1);
  }
}
.winning-overlay {
  position: absolute;
  inset: var(--board-pad);
  z-index: 2;
  width: calc(100% - 2 * var(--board-pad));
  height: calc(100% - 2 * var(--board-pad));
  overflow: visible;
  pointer-events: none;
}
.winning-overlay polyline {
  stroke-dasharray: 1;
  animation: pen 0.6s 0.2s ease-in-out both;
}
.player-X {
  color: var(--x);
}
.player-O {
  color: var(--o);
}

/* 7. Options: inline in the side panel on wide screens, a side drawer on phones. */
.game-menu {
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: 85dvh;
  padding: 22px;
  overflow: auto;
}
.rules-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: 88dvh;
  padding: 22px;
  overflow: auto;
  color: var(--ink);
}
.rules-dialog[open] {
  animation: rules-in 0.2s ease-out;
}
@keyframes rules-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
.rules-dialog::backdrop,
.game-menu::backdrop {
  background: rgba(28, 27, 34, 0.5);
  backdrop-filter: blur(3px);
}
.rules-dialog h3 {
  margin: 18px 0 8px;
  font-size: 24px;
}
.rules-lead {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.55;
}
.rules-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.rules-steps li {
  position: relative;
  padding: 10px 12px 10px 48px;
  border: 2px solid var(--plastic);
  border-radius: 12px;
  background: var(--paper);
  font-size: 14px;
  line-height: 1.55;
  counter-increment: step;
}
.rules-steps li::before {
  content: counter(step);
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gloss), var(--st-yellow);
  box-shadow: var(--sticker-depth);
  font-weight: 900;
}
.rules-options {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}
.rules-options dt {
  font-weight: 900;
}
.rules-options dd {
  margin: 0;
  color: var(--ink-soft);
}
.rules-notes {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.rules-close {
  width: 100%;
  margin-top: 20px;
  --tone: var(--st-yellow);
}
@media (max-width: 480px) {
  .rules-options {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .rules-options dd {
    margin-bottom: 8px;
  }
}
.menu-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.game-menu > .primary-button {
  width: 100%;
  margin-bottom: 10px;
}
.menu-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
}
.menu-button:hover:not(:disabled) {
  background: linear-gradient(
    transparent 55%,
    var(--marker) 55%,
    var(--marker) 90%,
    transparent 90%
  );
}
.match-details {
  margin-top: 8px;
  border-top: 2px dashed var(--rule);
}
.match-details p {
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.match-details .secondary-button {
  width: 100%;
  min-height: 46px;
  font-size: 14px;
}
.match-details a {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.inspect-controls {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 12px;
}
.inspect-controls button {
  font-size: 18px;
}

/* 8. Map */

/* 9. Selects (shadcn islands): a white sticker in a thin frame. */

.shadcn-select-trigger {
  font-family: var(--body) !important;
  border: 3px solid var(--plastic) !important;
  border-radius: 10px !important;
  box-shadow: var(--sticker-depth) !important;
  font-weight: 800;
}
.shadcn-select-trigger[data-state='open'] {
  background: var(--note);
}
.shadcn-select-content {
  border: 3px solid var(--plastic) !important;
  border-radius: 12px !important;
  box-shadow: var(--paper-shadow) !important;
  font-family: var(--body) !important;
  font-weight: 800;
}
.shadcn-select-content [role='option'] {
  cursor: pointer;
}
.shadcn-select-content [role='option'][data-state='checked'] {
  background: var(--st-yellow);
  color: var(--sticker-ink);
  font-weight: 900;
}

/* 10. Motion */
/* Hand-drawn strokes have pathLength 1, so the pen draws them from dashoffset 1 to 0. */
.hero-mark {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: pen 0.35s ease-out both;
}
.hero-x {
  stroke: var(--x);
  stroke-width: 6;
}
.hero-o {
  stroke: var(--o);
  stroke-width: 5;
}
.hero-token {
  transform-box: fill-box;
  transform-origin: center;
  animation: bounce-in 0.3s ease-out both;
}
.hero-win {
  fill: none;
  stroke: var(--sticker-ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: pen 0.5s 2.6s ease-in-out both;
}
.hero-step-1 {
  animation-delay: 0.5s;
}
.hero-step-2 {
  animation-delay: 0.9s;
}
.hero-step-3 {
  animation-delay: 1.3s;
}
.hero-step-4 {
  animation-delay: 1.7s;
}
.hero-step-5 {
  animation-delay: 2.1s;
}
/* One staggered reveal on the setup screen; the rest of the motion lives in moments that matter. */
.setup-intro,
.setup-form .setup-field,
.setup-form .start-game {
  animation: rise-in 0.45s ease-out both;
}
.setup-form .setup-field:nth-of-type(1) {
  animation-delay: 0.08s;
}
.setup-form .setup-field:nth-of-type(2) {
  animation-delay: 0.16s;
}
.setup-form .start-game {
  animation-delay: 0.24s;
}
.confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}
.confetti i {
  position: absolute;
  top: -24px;
  left: var(--x0);
  width: var(--size);
  height: var(--size);
  border: 2px solid var(--plastic);
  border-radius: 4px;
  background: var(--gloss), var(--sticker);
  animation: confetti-fall var(--time) var(--delay) cubic-bezier(0.25, 0.6, 0.4, 1) both;
}
@keyframes pen {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes bounce-in {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}
@keyframes cheer {
  0%,
  100% {
    transform: rotate(0) scale(1);
  }
  25% {
    transform: rotate(-10deg) scale(1.12);
  }
  75% {
    transform: rotate(10deg) scale(1.12);
  }
}
@keyframes cubie-flip {
  0% {
    transform: perspective(300px) rotateY(0);
  }
  50% {
    transform: perspective(300px) rotateY(90deg) scale(0.9);
  }
  100% {
    transform: perspective(300px) rotateY(0);
  }
}
@keyframes nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-4px);
  }
}
@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0);
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin));
  }
}
@keyframes sticker-swap {
  0%,
  100% {
    background-color: var(--sticker);
  }
  33% {
    background-color: var(--swap-a);
  }
  66% {
    background-color: var(--swap-b);
  }
}
@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: none;
  }
}

/* 11. Responsive */
@media (min-width: 900px) {
  .play-screen {
    display: grid;
    grid-template-columns: minmax(230px, 290px) minmax(0, 1fr) minmax(250px, 310px);
    gap: 22px;
  }
  .control-panel .game-menu {
    display: block;
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 14px 0 0;
    overflow: visible;
    background: none;
    border: 0;
    border-top: 2px dashed var(--rule);
    border-radius: 0;
    box-shadow: none;
  }
  /* The modal's own open/close controls only make sense on phones. */
  #close-menu,
  #resume-game,
  #open-menu {
    display: none !important;
  }
}

@media (max-width: 899px) {
  .shell {
    padding: 0 16px;
  }
  .topbar {
    height: 64px;
  }
  body[data-stage='playing'] .topbar,
  body[data-stage='result'] .topbar {
    height: 56px;
  }
  .setup-badge {
    font-size: 20px;
  }
  .setup-screen {
    display: block;
    min-height: 0;
    max-width: 440px;
    padding: 0 0 22px;
  }
  .setup-intro {
    position: relative;
    margin-bottom: 26px;
  }
  .setup-intro {
    display: block;
  }
  .setup-art {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 124px;
    margin: 0;
  }
  .eyebrow {
    font-size: 22px;
  }
  .wordmark-large .wordmark-cube b {
    width: 50px;
    height: 50px;
    font-size: 36px;
  }
  .wordmark-large .wordmark-hand {
    font-size: 50px;
    margin-left: 84px;
  }
  .setup-copy {
    font-size: 22px;
  }
  .setup-form {
    padding: 22px 14px 14px;
  }
  /* Phones: every tab fits one screen with the start button, so the setup never scrolls.
     The title shrinks, notes under the options go, and the pickers get tighter. */
  .setup-intro {
    margin-bottom: 20px;
  }
  .eyebrow,
  .setup-copy,
  .setup-summary,
  .skin-choices small {
    display: none;
  }
  .setup-art {
    top: -10px;
    width: 96px;
  }
  .hero-title {
    margin: 0;
  }
  .wordmark-large .wordmark-cube {
    padding: 6px;
  }
  .wordmark-large .wordmark-cube b {
    width: 42px;
    height: 42px;
    font-size: 30px;
  }
  .wordmark-large .wordmark-hand {
    font-size: 42px;
    margin: -4px 0 0 64px;
  }
  .setup-tabs {
    margin-bottom: 12px;
  }
  .setup-field {
    margin-bottom: 10px;
  }
  .setup-field h2,
  .setup-field > label {
    margin-bottom: 4px;
    font-size: 22px;
  }
  .choice-icon {
    margin-bottom: 2px;
  }
  .choice-icon svg {
    width: 22px;
    height: 22px;
  }
  .skin-swatch {
    margin-bottom: 4px;
  }
  .skin-choices button,
  .theme-choices button {
    padding: 9px 4px 8px;
  }
  .theme-choices button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .theme-choices .choice-icon {
    margin: 0;
  }
  .name-field input {
    min-height: 42px;
  }
  .start-game {
    min-height: 58px;
  }
  .rules-link {
    margin-top: 0;
  }
  .choice-group button {
    padding: 10px 6px 9px;
    font-size: 14px;
  }
  .choice-group small {
    font-size: 11px;
  }
  .play-screen {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .match-panel,
  .control-panel {
    flex: none;
    gap: 8px;
    padding: 10px 12px;
    overflow: visible;
    border-radius: 14px;
  }
  .control-panel {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .match-panel > .panel-title,
  .control-panel > .panel-title,
  .players,
  .round-count {
    display: none;
  }
  .next-turn {
    padding: 4px 10px;
    font-size: 13px;
  }
  .game-heading {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .turn-symbol {
    width: 46px;
    height: 46px;
    border-width: 4px;
    border-radius: 11px;
    font-size: 26px;
  }
  #status {
    font-size: 24px;
  }
  .game-goal {
    font-size: 21px;
  }
  .feedback {
    display: block;
    padding: 4px 10px;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: none;
  }
  .board-column {
    flex: 1;
    gap: 8px;
  }
  .board-caption,
  .face-hint {
    font-size: 18px;
  }
  .turn-controls {
    gap: 8px;
  }
  .action-help {
    font-size: 18px;
  }
  .face-view {
    padding: 10px 12px;
  }
  /* On phones the options open as a drawer sliding in from the side. */
  .game-menu {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(360px, 88vw);
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-width: 0 0 0 2px;
    border-radius: 0;
  }
  .game-menu[open] {
    animation: drawer-in 0.25s ease-out;
  }
}

@media (max-width: 899px) and (max-height: 700px) {
  .setup-art {
    width: 84px;
  }
  .setup-intro {
    margin-bottom: 16px;
  }
  .wordmark-large .wordmark-cube b {
    width: 38px;
    height: 38px;
    font-size: 27px;
  }
  .wordmark-large .wordmark-hand {
    font-size: 36px;
    margin: -6px 0 0 60px;
  }
  .setup-form {
    padding-top: 18px;
  }
  .setup-tabs button {
    min-height: 40px;
  }
  body[data-stage='setup'] .site-footer {
    display: none;
  }
  .setup-screen {
    padding-bottom: 0;
  }
  .setup-form {
    padding-bottom: 12px;
  }
  .setup-copy {
    display: none;
  }
  .setup-field {
    margin-bottom: 14px;
  }
  .choice-icon {
    margin-bottom: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* The sound toggles take the topbar's spare room on narrow phones. */
@media (max-width: 420px) {
  /* Mid-match the theme switch moves into the menu, leaving the wordmark its room. */
  body:not([data-stage='setup']) .theme-toggle {
    display: none;
  }
  .setup-badge {
    display: none;
  }
  /* The goal folds into two short lines, leaving the line's width to the player's name. */
  .game-goal {
    flex: none;
    max-width: 4.8em;
    font-size: 21px;
    line-height: 1.05;
    text-align: right;
    white-space: normal;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
}
