:root {
  --stick-paper: #fffaf0;
  --stick-yellow: #ffd95a;
  --stick-blue: #7cc8ff;
  --stick-red: #f04e4e;
  --stick-green: #2fbf71;
  --stick-shadow: 0 8px 0 var(--toy-ink);
}

html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; overflow-x: hidden; }
button, input { -webkit-tap-highlight-color: transparent; }

.stick-header,
.stick-main,
.stick-footer {
  margin-inline: auto;
  width: min(calc(100% - 36px), 1120px);
}

.stick-header {
  align-items: center;
  border-bottom: 3px dashed rgb(50 43 95 / 24%);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
}

.stick-header nav,
.stick-footer nav {
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 16px;
}

.stick-header nav a,
.stick-footer nav a { color: var(--toy-muted); }
.stick-header nav a:hover,
.stick-footer nav a:hover { color: var(--toy-cyan-text); }

.intro {
  align-items: center;
  display: grid;
  gap: clamp(28px, 7vw, 90px);
  grid-template-columns: minmax(0, 1.25fr) minmax(230px, .75fr);
  padding: clamp(44px, 8vw, 84px) 0 38px;
}

.intro-copy { position: relative; }
.intro-copy::after {
  background: var(--stick-yellow);
  border: 3px solid var(--toy-ink);
  border-radius: 50%;
  content: "";
  height: 17px;
  left: min(68vw, 440px);
  position: absolute;
  top: 11px;
  transform: rotate(-9deg);
  width: 35px;
}

.intro .toy-eyebrow { color: var(--toy-coral-text); margin: 0 0 9px; }
.intro h1 {
  font-size: clamp(4.4rem, 12vw, 8.2rem);
  line-height: .72;
  margin: 0 0 30px;
  transform: rotate(-1deg);
}
.intro h1 span {
  color: var(--toy-coral-text);
  display: inline-block;
  margin-left: clamp(18px, 6vw, 80px);
  transform: rotate(1.2deg);
}
.intro .toy-lede { margin: 0; max-width: 670px; }

.intro-note {
  color: var(--toy-ink);
  display: grid;
  filter: drop-shadow(0 7px 0 rgb(50 43 95 / 16%));
  justify-items: center;
  position: relative;
  transform: rotate(3deg);
}
.intro-note svg { display: block; max-width: 290px; width: 100%; }
.intro-note b {
  bottom: 27px;
  font: 800 clamp(15px, 2vw, 19px)/1.15 var(--toy-font-display);
  left: 35%;
  position: absolute;
  text-align: center;
  transform: translateX(-50%) rotate(-2deg);
  width: 105px;
}

.game-card {
  background: var(--stick-yellow);
  border: 4px solid var(--toy-ink);
  border-radius: 32px;
  box-shadow: 0 12px 0 var(--toy-ink);
  margin-bottom: 72px;
  overflow: hidden;
}

.game-topline {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 19px 24px 17px;
}

.game-kicker {
  color: var(--toy-coral-text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .11em;
  margin: 0 0 2px;
  text-transform: uppercase;
}
.game-topline h2 {
  color: var(--toy-ink);
  font: 800 clamp(1.5rem, 3vw, 2rem)/1 var(--toy-font-display);
  margin: 0;
}

.live-cluster {
  align-items: center;
  color: var(--toy-ink);
  display: flex;
  font-size: 13px;
  font-weight: 900;
  gap: 8px;
}
.connection-dot {
  background: var(--toy-muted);
  border: 2px solid var(--toy-ink);
  border-radius: 50%;
  box-shadow: 0 2px 0 var(--toy-ink);
  height: 12px;
  width: 12px;
}
.connection-dot[data-state="live"] { animation: live-pulse 1.8s ease-out infinite; background: var(--stick-green); }
.connection-dot[data-state="working"] { animation: working-blink .8s steps(2) infinite; background: var(--stick-yellow); }
.connection-dot[data-state="error"] { background: var(--stick-red); }
.player-pill {
  background: rgb(255 255 255 / 72%);
  border: 2px solid var(--toy-ink);
  border-radius: 999px;
  margin-left: 5px;
  padding: 2px 9px;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgb(47 191 113 / 55%), 0 2px 0 var(--toy-ink); }
  70% { box-shadow: 0 0 0 8px rgb(47 191 113 / 0%), 0 2px 0 var(--toy-ink); }
  100% { box-shadow: 0 0 0 0 rgb(47 191 113 / 0%), 0 2px 0 var(--toy-ink); }
}
@keyframes working-blink { 50% { opacity: .38; } }

.board-wrap {
  background: var(--stick-paper);
  border-bottom: 4px solid var(--toy-ink);
  border-top: 4px solid var(--toy-ink);
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

#world-canvas {
  background: var(--stick-paper);
  cursor: crosshair;
  display: block;
  height: auto;
  max-height: min(67vh, 630px);
  min-height: 300px;
  outline: none;
  touch-action: none;
  width: 100%;
}
#world-canvas:focus-visible { box-shadow: inset 0 0 0 5px var(--toy-focus); }
.board-vignette {
  border: 8px solid rgb(50 43 95 / 5%);
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.lobby-card {
  background: rgb(255 254 248 / 96%);
  border: 4px solid var(--toy-ink);
  border-radius: 25px;
  box-shadow: 0 8px 0 var(--toy-ink);
  left: 50%;
  max-width: 480px;
  padding: clamp(21px, 4vw, 33px);
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-.4deg);
  width: calc(100% - 42px);
  z-index: 4;
}
.lobby-card[hidden] { display: none; }
.lobby-overline {
  color: var(--toy-green-text);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  margin: 0 0 7px;
  text-transform: uppercase;
}
.lobby-card h3 {
  color: var(--toy-ink);
  font: 800 clamp(1.8rem, 5vw, 2.6rem)/1.02 var(--toy-font-display);
  margin: 0 auto 9px;
}
.lobby-card > p:not(.lobby-overline) { margin: 0 auto 18px; max-width: 400px; }

.lobby-doodle {
  height: 42px;
  left: 20px;
  position: absolute;
  top: 18px;
  transform: rotate(-8deg);
  width: 42px;
}
.lobby-doodle span {
  border: 3px solid var(--toy-ink);
  border-radius: 50%;
  display: block;
  height: 14px;
  margin: 0 auto;
  width: 14px;
}
.lobby-doodle i,
.lobby-doodle b {
  background: var(--toy-ink);
  display: block;
  height: 3px;
  left: 20px;
  position: absolute;
  top: 15px;
  transform-origin: 0 50%;
  width: 23px;
}
.lobby-doodle i { transform: rotate(125deg); }
.lobby-doodle b { transform: rotate(55deg); }

.make-button {
  background: var(--toy-coral);
  font-size: 1.15rem;
  min-height: 52px;
  width: 100%;
}
.make-button[disabled], .join-button[disabled] { cursor: wait; opacity: .65; }
.lobby-divider {
  align-items: center;
  color: var(--toy-muted);
  display: flex;
  font-size: 11px;
  font-weight: 900;
  gap: 10px;
  margin: 17px 0 11px;
  text-transform: uppercase;
}
.lobby-divider::before,
.lobby-divider::after { border-top: 2px dashed rgb(50 43 95 / 25%); content: ""; flex: 1; }
.join-form label {
  color: var(--toy-ink);
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
  text-align: left;
}
.join-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; }
.join-row input {
  background: white;
  border: 3px solid var(--toy-ink);
  border-radius: 12px;
  color: var(--toy-ink);
  font: 900 17px/1 var(--toy-font-body);
  letter-spacing: .11em;
  min-width: 0;
  padding: 11px 13px;
  text-transform: uppercase;
}
.join-row input::placeholder { color: rgb(85 80 128 / 50%); font-size: 13px; }
.join-button { background: var(--stick-blue); white-space: nowrap; }
.form-error { color: var(--toy-coral-text); font-size: 12px; font-weight: 800; min-height: 18px; padding-top: 6px; text-align: left; }

.room-ribbon {
  align-items: center;
  background: rgb(255 217 90 / 96%);
  border: 3px solid var(--toy-ink);
  border-radius: 15px;
  box-shadow: 0 4px 0 var(--toy-ink);
  display: flex;
  font-size: 12px;
  font-weight: 900;
  gap: 12px;
  justify-content: space-between;
  left: 17px;
  padding: 7px 9px 7px 13px;
  position: absolute;
  right: 17px;
  top: 15px;
  z-index: 3;
}
.room-ribbon[hidden] { display: none; }
.room-ribbon > span { align-items: center; display: flex; gap: 7px; }
#copy-code {
  align-items: center;
  appearance: none;
  background: white;
  border: 2px solid var(--toy-ink);
  border-radius: 8px;
  color: var(--toy-ink);
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  letter-spacing: .08em;
  padding: 4px 7px;
}
.room-ribbon > div { display: flex; gap: 6px; }
.ribbon-button {
  appearance: none;
  border: 2px solid var(--toy-ink);
  border-radius: 8px;
  box-shadow: 0 2px 0 var(--toy-ink);
  color: var(--toy-ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  min-height: 30px;
  padding: 4px 9px;
}
.share-button { background: var(--toy-panel); }
.leave-button { background: #ffe9e8; }

.reconnect-card {
  align-items: center;
  background: rgb(255 254 248 / 96%);
  border: 3px solid var(--toy-ink);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--toy-ink);
  display: grid;
  gap: 2px;
  justify-items: center;
  left: 50%;
  padding: 16px 22px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(1deg);
  z-index: 5;
}
.reconnect-card[hidden] { display: none; }
.reconnect-card b { color: var(--toy-ink); font-family: var(--toy-font-display); }
.reconnect-card small { color: var(--toy-muted); }
.pencil-spinner { animation: pencil-search .9s ease-in-out infinite alternate; font-size: 25px; }
@keyframes pencil-search { from { transform: translateX(-10px) rotate(-25deg); } to { transform: translateX(10px) rotate(8deg); } }

.controls-row {
  align-items: center;
  display: grid;
  gap: 26px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 22px 25px 25px;
}
.keyboard-help { align-items: center; display: grid; gap: 6px 16px; grid-template-columns: auto minmax(0, 1fr); }
.help-label {
  color: var(--toy-ink);
  font: 800 1.15rem/1 var(--toy-font-display);
  grid-column: 1 / -1;
}
.key-demo { display: grid; gap: 3px; justify-items: center; }
.key-demo span { display: flex; gap: 3px; }
kbd {
  align-items: center;
  background: white;
  border: 2px solid var(--toy-ink);
  border-radius: 6px;
  box-shadow: 0 3px 0 var(--toy-ink);
  color: var(--toy-ink);
  display: inline-flex;
  font: 900 12px/1 var(--toy-font-body);
  height: 24px;
  justify-content: center;
  min-width: 24px;
}
.keyboard-help p { color: var(--toy-ink); font-size: 13px; font-weight: 700; margin: 0; max-width: 430px; }

.dpad {
  display: grid;
  gap: 5px;
  grid-template: repeat(3, 47px) / repeat(3, 47px);
  touch-action: none;
}
.dpad button,
.dpad-center {
  align-items: center;
  border: 3px solid var(--toy-ink);
  border-radius: 12px;
  color: var(--toy-ink);
  display: flex;
  font-size: 22px;
  font-weight: 900;
  justify-content: center;
}
.dpad button {
  appearance: none;
  background: white;
  box-shadow: 0 3px 0 var(--toy-ink);
  cursor: pointer;
  padding: 0;
  user-select: none;
}
.dpad button:active,
.dpad button.is-pressed { background: var(--stick-blue); box-shadow: 0 1px 0 var(--toy-ink); transform: translateY(2px); }
.dpad-up { grid-area: 1 / 2; }
.dpad-left { grid-area: 2 / 1; }
.dpad-center { background: var(--toy-coral); font-size: 12px; grid-area: 2 / 2; }
.dpad-right { grid-area: 2 / 3; }
.dpad-down { grid-area: 3 / 2; }

.how-it-works {
  align-items: start;
  display: grid;
  gap: clamp(32px, 8vw, 100px);
  grid-template-columns: minmax(230px, .65fr) minmax(0, 1.35fr);
  padding: 8px 0 65px;
}
.how-it-works .toy-eyebrow { margin: 0 0 6px; }
.how-it-works h2 { font-size: clamp(2.8rem, 7vw, 5rem); margin: 0; }
.how-it-works ol { display: grid; gap: 13px; list-style: none; margin: 0; padding: 0; }
.how-it-works li {
  align-items: center;
  background: var(--toy-panel);
  border: 3px solid var(--toy-ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--toy-ink);
  display: grid;
  gap: 15px;
  grid-template-columns: auto 1fr;
  padding: 14px 17px;
  transform: rotate(var(--tilt, 0deg));
}
.how-it-works li:nth-child(1) { --tilt: -.4deg; }
.how-it-works li:nth-child(2) { --tilt: .5deg; }
.how-it-works li:nth-child(3) { --tilt: -.2deg; }
.how-it-works li > span {
  align-items: center;
  background: var(--stick-yellow);
  border: 3px solid var(--toy-ink);
  border-radius: 50%;
  color: var(--toy-ink);
  display: flex;
  font: 900 19px/1 var(--toy-font-display);
  height: 42px;
  justify-content: center;
  width: 42px;
}
.how-it-works li:nth-child(2) > span { background: var(--stick-blue); }
.how-it-works li:nth-child(3) > span { background: #8de1b2; }
.how-it-works li b { color: var(--toy-ink); font: 800 1.15rem/1.1 var(--toy-font-display); }
.how-it-works li p { font-size: 13px; margin: 2px 0 0; }

.privacy-note {
  align-items: center;
  background: var(--toy-blue-soft);
  border: 3px solid var(--toy-ink);
  border-radius: 18px;
  display: grid;
  gap: 14px;
  grid-template-columns: auto 1fr;
  margin-bottom: 60px;
  padding: 17px 20px;
}
.privacy-note > span {
  align-items: center;
  background: var(--toy-cyan);
  border: 2px solid var(--toy-ink);
  border-radius: 50%;
  color: white;
  display: flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}
.privacy-note p { font-size: 13px; margin: 0; }

.stick-footer {
  align-items: center;
  border-top: 3px dashed rgb(50 43 95 / 24%);
  color: var(--toy-muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 18px;
  justify-content: space-between;
  padding: 26px 0 38px;
}

@media (max-width: 760px) {
  .intro { gap: 12px; grid-template-columns: 1fr; padding-top: 42px; }
  .intro-note { display: none; }
  .intro h1 { font-size: clamp(4rem, 20vw, 6.8rem); }
  .game-card { border-radius: 24px; margin-inline: -6px; }
  .how-it-works { gap: 26px; grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .stick-header { align-items: flex-start; flex-direction: column; gap: 11px; padding: 15px 0; }
  .stick-header nav { gap: 12px; }
  .game-topline { align-items: flex-start; padding-inline: 17px; }
  .live-cluster { align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; max-width: 170px; }
  .player-pill { margin-left: 20px; }
  #world-canvas { min-height: 540px; }
  .lobby-card { padding: 24px 17px 18px; top: 54%; width: calc(100% - 24px); }
  .lobby-doodle { display: none; }
  .join-row { grid-template-columns: 1fr; }
  .join-button { width: 100%; }
  .room-ribbon { align-items: flex-start; flex-direction: column; }
  .room-ribbon > div { width: 100%; }
  .ribbon-button { flex: 1; }
  .controls-row { grid-template-columns: 1fr auto; padding: 18px 15px 21px; }
  .keyboard-help .key-demo { display: none; }
  .keyboard-help { display: block; }
  .keyboard-help p { margin-top: 6px; }
  .dpad { grid-template: repeat(3, 42px) / repeat(3, 42px); }
  .stick-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 430px) {
  .stick-header, .stick-main, .stick-footer { width: min(calc(100% - 24px), 1120px); }
  .intro h1 span { margin-left: 12px; }
  .intro .toy-lede { font-size: 1rem; }
  .game-card { margin-inline: -4px; }
  .game-topline h2 { font-size: 1.35rem; }
  .controls-row { gap: 12px; }
  .keyboard-help p { font-size: 11px; }
  .privacy-note { align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
