:root {
  --ink: #283c49;
  --paper: #fcf5e8;
  --coral: #ef796f;
  --blue: #65baca;
  --gold: #e4b34e;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    15px/1.45 system-ui,
    -apple-system,
    sans-serif;
  background-image: radial-gradient(#dfd1bd 1px, transparent 1px);
  background-size: 22px 22px;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fffaf0;
  padding: 11px 18px;
  font-weight: 750;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
button:focus-visible,
canvas:focus-visible {
  outline: 4px solid #bd4b79;
  outline-offset: 4px;
}
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px 18px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}
.label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 850;
  margin-bottom: 8px;
  color: #866447;
}
h1 {
  font-size: clamp(27px, 4vw, 46px);
  letter-spacing: -2px;
  line-height: 1.05;
  margin: 0;
  font-weight: 950;
}
h1 em {
  font-style: normal;
  color: #d95a55;
}
.tag {
  font-size: 12px;
  max-width: 190px;
  text-align: right;
  color: #68716d;
}
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #fffcf4;
  border: 2px solid var(--ink);
  border-radius: 14px 14px 0 0;
  border-bottom: 0;
}
.layers {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-label {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.mini-cakes {
  display: flex;
  gap: 5px;
}
.mini-cakes span {
  font-size: 22px;
  line-height: 1;
}
.mini-cakes .gone {
  filter: grayscale(1);
  opacity: 0.2;
}
.balance {
  display: flex;
  gap: 10px;
  align-items: center;
}
.balance-track {
  width: 130px;
  height: 10px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: #e6e4d9;
  overflow: hidden;
}
.balance-fill {
  height: 100%;
  width: 0;
  background: #79b999;
}
.level-tag {
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #866447;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.time {
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  font-size: 20px;
  min-width: 58px;
  text-align: right;
}
.hud-end {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mute {
  padding: 0;
  width: 38px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--ink);
  flex: none;
}
.mute[aria-pressed="true"] {
  background: #e6e4d9;
}
.lang {
  font-size: 16px;
  opacity: 0.55;
}
.reactbar {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  max-width: 96%;
  overflow-x: auto;
  padding: 3px 4px 5px;
  z-index: 3;
  scrollbar-width: none;
}
.reactbar button,
.react-row button {
  flex: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 11px;
  border-radius: 16px;
  background: #f6e4b9;
  box-shadow: 0 2px 0 var(--ink);
}
.react-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 8px 0;
}
@media (orientation: portrait) and (max-width: 650px) {
  .reactbar {
    bottom: auto;
    top: 6px;
  }
}
.react-title {
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.5px;
  text-align: center;
  margin-top: 8px;
}
.lang[aria-pressed="true"] {
  background: #f6e4b9;
  opacity: 1;
}
@media (max-width: 650px) {
  .hud {
    gap: 8px;
    padding: 10px 12px;
  }
  .hud-end {
    gap: 6px;
  }
  .time {
    min-width: 40px;
    font-size: 17px;
  }
  .mute {
    width: 34px;
  }
}
@media (max-width: 420px) {
  .balance-track {
    width: 84px;
  }
  .layers .hud-label {
    display: none;
  }
}
.game-shell {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 0 0 18px 18px;
  overflow: hidden;
  background: #eddcc1;
  box-shadow: 6px 7px 0 #283c49;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fcf5e81f;
  backdrop-filter: blur(2px);
  padding: 16px;
}
/* A panel taller than the stage (the job board) scrolls inside the overlay; margin:auto keeps short panels centred without cropping tall ones. */
.overlay {
  overflow-y: auto;
  overscroll-behavior: contain;
  align-items: flex-start;
}
.overlay > .panel {
  margin: auto;
  flex: none;
}
.overlay[hidden] {
  display: none;
}
.panel {
  max-width: 470px;
  width: 100%;
  text-align: center;
  padding: 27px 32px 26px;
  background: #fffcf4;
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 7px 8px 0 #283c49;
  transform: rotate(-1deg);
}
.panel .kicker {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 1.4px;
  font-weight: 900;
  background: #f3d88f;
  border-radius: 5px;
  padding: 5px 9px;
  text-transform: uppercase;
}
.panel h2 {
  font-size: 36px;
  line-height: 1.06;
  letter-spacing: -1.5px;
  margin: 13px 0;
  font-weight: 950;
}
.panel p {
  font-size: 14px;
  margin: 0 0 17px;
  color: #607075;
}
.mode-options {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.mode-options button {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  background: #f4eddf;
  box-shadow: none;
  border-color: #c6c3b8;
}
.mode-options button.selected {
  background: #d9eced;
  border-color: var(--ink);
}
.mode-options small {
  display: block;
  font-weight: 500;
  font-size: 10px;
  margin-top: 3px;
}
.start {
  background: var(--coral);
  font-size: 17px;
  width: 100%;
  padding: 13px;
}
.start-note {
  margin-top: 12px;
  font-size: 11px;
  color: #6f7470;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
}
.control-copy {
  font-size: 13px;
}
.control-copy strong {
  display: block;
  margin-bottom: 3px;
}
.control-copy span {
  font-size: 11px;
  color: #64736f;
}
.buttons {
  display: flex;
  gap: 9px;
  align-items: center;
}
.steady {
  background: #c6e4e4;
  min-width: 140px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.steady.held {
  background: #78c3c9;
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.icon-button {
  padding: 11px 13px;
  font-size: 17px;
  min-width: 45px;
}
.speech {
  position: absolute;
  left: 50%;
  bottom: 17px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff9e9;
  padding: 9px 17px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 750;
  max-width: 85%;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 3px 0 #17242b33;
}
.speech[hidden] {
  display: none;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 10px;
  color: #707970;
  margin-top: 22px;
}
.key {
  display: inline-block;
  border: 1px solid #a2b0aa;
  border-radius: 4px;
  padding: 1px 5px;
  font:
    11px ui-monospace,
    monospace;
  background: #fffdf4;
}
.pink {
  color: #c15172;
}
.blue {
  color: #267c99;
}
.result-score {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
}
.result-score strong {
  display: block;
  font-size: 25px;
}
.result-score span {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.stars {
  font-size: 32px;
  letter-spacing: 8px;
  color: #dca642;
}
.two-buttons {
  display: flex;
  gap: 10px;
}
.two-buttons button {
  flex: 1;
}
.subtle-button {
  background: #f4e9d6;
}
.mode-badge {
  position: absolute;
  left: 16px;
  top: 13px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #fffaf0dc;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.7px;
  pointer-events: none;
}
.instructions-inline {
  background: #fffaf0;
  border: 1px solid #d6ccb8;
  padding: 11px 15px;
  border-radius: 9px;
  font-size: 12px;
  margin-top: 17px;
  display: none;
}
.instructions-inline.open {
  display: block;
}
@media (max-width: 650px) {
  .wrap {
    padding: 17px 12px;
  }
  header {
    margin-bottom: 16px;
  }
  .label {
    font-size: 8px;
    letter-spacing: 1.2px;
  }
  h1 {
    font-size: 29px;
    letter-spacing: -1.3px;
  }
  .tag {
    display: none;
  }
  .hud {
    padding: 10px;
  }
  .hud-label {
    font-size: 8px;
  }
  .mini-cakes span {
    font-size: 17px;
  }
  .balance {
    gap: 6px;
  }
  .balance-track {
    width: 65px;
    height: 9px;
  }
  .time {
    font-size: 16px;
    min-width: 45px;
  }
  .layers {
    gap: 6px;
  }
  .game-shell {
    box-shadow: 3px 4px 0 var(--ink);
  }
  .panel {
    padding: 16px 20px;
    max-width: 345px;
  }
  .panel h2 {
    font-size: 27px;
    margin: 8px 0;
  }
  .panel p {
    font-size: 12px;
    margin-bottom: 11px;
  }
  .panel .kicker {
    font-size: 8px;
    padding: 3px 6px;
  }
  .mode-options {
    margin-bottom: 10px;
    gap: 7px;
  }
  .mode-options button {
    padding: 7px;
    font-size: 11px;
  }
  .start {
    padding: 9px;
    font-size: 14px;
  }
  .start-note {
    font-size: 9px;
    margin-top: 8px;
  }
  .overlay {
    padding: 10px;
  }
  .controls {
    align-items: start;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 15px;
  }
  .control-copy {
    font-size: 12px;
  }
  .buttons {
    margin-left: auto;
  }
  .steady {
    min-width: 110px;
    font-size: 12px;
    padding: 10px;
  }
  .icon-button {
    padding: 8px 10px;
    min-width: 38px;
  }
  .speech {
    font-size: 10px;
    bottom: 9px;
    padding: 6px 10px;
  }
  .mode-badge {
    font-size: 8px;
    top: 8px;
    left: 8px;
  }
  footer {
    font-size: 9px;
    flex-direction: column;
    gap: 3px;
  }
  .result-score {
    margin: 9px 0;
    gap: 18px;
  }
  .result-score strong {
    font-size: 21px;
  }
  .stars {
    font-size: 23px;
  }
  .panel.result h2 {
    font-size: 26px;
  }
  .panel.result p {
    font-size: 11px;
  }
  .two-buttons button {
    padding: 8px;
    font-size: 12px;
  }
}
@media (max-width: 650px) {
  .level-tag {
    font-size: 9px;
    letter-spacing: 0.3px;
  }
}
@media (max-width: 650px) and (orientation: portrait) {
  .level-name {
    display: none;
  }
  .game-shell {
    min-height: 310px;
  }
  .overlay {
    background: #fcf5e83d;
  }
  .panel {
    transform: none;
  }
  .balance .hud-label {
    display: none;
  }
}
@media (max-width: 380px) and (orientation: portrait) {
  .panel.result .two-buttons {
    flex-wrap: wrap;
  }
  .panel.result .two-buttons button {
    flex: 0 0 100%;
    width: 100%;
  }
  .panel.result .two-buttons .start {
    order: -1;
  }
}
@media (prefers-reduced-motion: reduce) {
  button:hover {
    transform: none;
  }
  .panel {
    transform: none;
  }
}
.link-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 12px;
}
.link-row input {
  flex: 1;
  min-width: 0;
  font:
    12px ui-monospace,
    monospace;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.link-row button {
  padding: 9px 14px;
}
.net-status {
  font-size: 12px;
  color: #607075;
  margin: 12px 0 0 !important;
}
.net-warn {
  font-size: 11px !important;
  background: #f8e3c4;
  border-radius: 8px;
  padding: 7px 10px;
  color: #7a5530 !important;
  margin: 10px 0 0 !important;
}
.touchpad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  pointer-events: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.touchpad[hidden] {
  display: none;
}
.stick {
  pointer-events: auto;
  touch-action: none;
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: #fffaf066;
  border: 2px dashed #283c4988;
  flex: none;
}
.stick[hidden] {
  display: none;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: #fffaf0;
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  pointer-events: none;
}
.stick.pink .knob {
  background: #f6b6c7;
}
.stick.blue .knob {
  background: #b9e1ea;
}
.touch-actions {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  pointer-events: none;
}
.touch-steady {
  pointer-events: auto;
  touch-action: none;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: #c6e4e4ee;
  flex: none;
}
.touch-steady span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.5px;
  margin-top: 3px;
}
.touch-steady.held {
  background: #78c3c9;
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.touch-steady[hidden] {
  display: none;
}
.touch-poke {
  pointer-events: auto;
  touch-action: manipulation;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 0;
  font-size: 23px;
  background: #ffe6b6;
  flex: none;
}
.touch-poke[hidden] {
  display: none;
}
.is-touch .controls .steady,
.is-touch .controls .poke {
  display: none;
}
@media (max-width: 650px) {
  .stick {
    width: 96px;
    height: 96px;
  }
  .knob {
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
  }
  .touch-steady {
    width: 70px;
    height: 70px;
    font-size: 20px;
  }
  .touch-poke {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}
.is-touch .speech {
  bottom: auto;
  top: 44px;
}
@media (orientation: portrait) {
  .is-touch .wrap {
    height: 100dvh;
    padding: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .is-touch header,
  .is-touch footer {
    display: none;
  }
  .is-touch .hud {
    flex: none;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .is-touch .game-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .is-touch canvas {
    height: auto;
    aspect-ratio: auto;
    flex: 1;
    min-height: 0;
  }
  .is-touch .touchpad {
    position: relative;
    flex: none;
    padding: 12px 18px 14px;
    background: #e4d2b5;
    border-top: 2px solid var(--ink);
  }
  .is-touch .controls {
    flex: none;
    margin: 0;
    padding: 7px 10px;
    justify-content: flex-end;
  }
  .is-touch .control-copy {
    display: none;
  }
  .is-touch .speech {
    top: 40px;
  }
}
.room-cards {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}
.room-card {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: #fff;
}
.room-card strong {
  font-size: 13px;
}
.room-card small {
  display: block;
  font-size: 10px;
}
.room-dot {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
}
.room-mode {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
}
.room-mode button {
  flex: 1;
  font-size: 12px;
  padding: 7px;
  box-shadow: none;
}
.room-mode .selected {
  background: #f3d88f;
}
.room-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.room-side {
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  display: grid;
  gap: 6px;
  align-content: start;
}
.room-side h3 {
  margin: 0;
  font-size: 13px;
}
.room-side .room-card {
  padding: 6px 7px;
  font-size: 12px;
}
.room-side.pink {
  background: #fdeef2;
}
.room-side.blue {
  background: #eaf6f9;
}
.room-format {
  display: flex;
  gap: 6px;
  margin: 6px 0;
}
.room-format button,
.room-format span {
  flex: 1;
  font-size: 12px;
  padding: 7px;
  box-shadow: none;
  text-align: center;
  border: 2px solid var(--ink);
  border-radius: 10px;
}
.room-format .selected {
  background: #f3d88f;
}
.room-card.bot {
  opacity: 0.72;
}
.race-hint {
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  margin: 4px 0;
  color: #8b5a2b;
}
.room-card button {
  margin-left: auto;
  padding: 5px 7px;
  font-size: 11px;
  box-shadow: none;
}
.room-style {
  display: flex;
  gap: 7px;
  margin: 10px 0;
}
.room-style button {
  flex: 1;
  padding: 7px;
  font-size: 11px;
  box-shadow: none;
}
.room-style .selected {
  background: #c6e4e4;
}
.panel:has(.room-cards) {
  max-height: calc(100dvh - 30px);
  overflow: auto;
}
.text-button {
  border: 0;
  box-shadow: none;
  background: none;
  text-decoration: underline;
  font-weight: 600;
  font-size: 12px;
  padding: 8px;
  margin-top: 6px;
}
.panel:has(.job-list) {
  max-width: 590px;
  max-height: calc(100dvh - 24px);
  overflow: auto;
  text-align: left;
  transform: none;
  padding: 18px;
}
.job-head {
  background: var(--ink);
  color: #fffaf0;
  border-radius: 14px;
  padding: 13px 15px;
}
.job-head h2 {
  font-size: 22px;
  margin: 0;
}
.job-head p {
  color: #d7e3df;
  margin: 3px 0 0;
  font-size: 12px;
}
.board-top {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  align-items: stretch;
}
.board-top > div {
  flex: 1;
  background: #e1f0ed;
  border: 1px solid #a9c9c8;
  border-radius: 10px;
  padding: 8px;
  font-size: 11px;
}
.board-top strong {
  display: block;
}
.board-style {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.board-style button {
  font-size: 11px;
  padding: 5px;
  box-shadow: none;
  flex: 1;
}
.board-style .selected {
  background: #f3d88f;
}
.board-filters {
  display: flex;
  gap: 6px;
  overflow: auto;
  margin: 10px 0;
}
.board-filters button {
  font-size: 11px;
  padding: 6px 9px;
  white-space: nowrap;
  box-shadow: none;
  background: #eee6d7;
}
.board-filters .selected {
  background: #f3d88f;
}
.job-list {
  display: grid;
  gap: 8px;
}
.chapter {
  margin: 9px 0 1px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #e1f0ed;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.chapter strong {
  font-size: 14px;
}
.chapter-medal {
  font-weight: 850;
  white-space: nowrap;
}
.job-badge {
  font-weight: 850;
  color: #91611d;
}
.job {
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px;
  background: #fffcf4;
  box-shadow: 2px 2px 0 var(--ink);
}
.job.chosen {
  outline: 2px solid var(--gold);
}
.job.locked {
  background: #efebe3;
}
.job-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}
.job-line strong {
  font-size: 14px;
}
.job-route,
.job-meta,
.board-saved {
  font-size: 11px;
  color: #647372;
}
.job-meta {
  margin: 5px 0;
}
.job-stars {
  color: #bc8227;
  font-weight: 900;
  letter-spacing: 1px;
}
.job button {
  padding: 6px 10px;
  font-size: 11px;
  box-shadow: none;
}
.job.locked button {
  background: #eee6d7;
}
.board-notice {
  background: #fff2d5;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  margin: 8px 0;
}
.board-saved {
  margin: 10px 0 0;
}
@media (max-width: 650px) {
  .panel:has(.job-list) {
    width: 100%;
    padding: 12px;
    max-height: calc(100dvh - 16px);
  }
  .board-top {
    flex-direction: column;
  }
  .job-head h2 {
    font-size: 19px;
  }
}
.hint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.hint > * {
  position: absolute;
}
.h-cap {
  left: 50%;
  top: 14%;
  translate: -50% 0;
  max-width: calc(100% - 24px);
  background: #fffaf0;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px 16px;
  font-weight: 850;
  font-size: clamp(15px, 4.2vw, 24px);
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 4px 0 var(--ink);
}
.h-cap small {
  display: block;
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 650;
  color: #607075;
}
.is-touch .h-cap {
  top: 10px;
}
.h-ring {
  border-radius: 50%;
  border: 4px solid var(--gold);
  animation: h-ring 1.2s ease-out infinite;
}
@keyframes h-ring {
  0% {
    scale: 0.9;
    opacity: 1;
  }
  100% {
    scale: 1.35;
    opacity: 0;
  }
}
.h-thumb {
  font-size: 44px;
  line-height: 1;
  filter: drop-shadow(0 3px 0 #283c4955);
  animation: h-drag 1.6s ease-in-out infinite;
}
@keyframes h-drag {
  0% {
    translate: -18px 0;
    opacity: 0;
  }
  15% {
    translate: -18px 0;
    opacity: 1;
  }
  70% {
    translate: 34px 0;
    opacity: 1;
  }
  100% {
    translate: 34px 0;
    opacity: 0;
  }
}
.h-tap {
  animation-name: h-tap;
}
@keyframes h-tap {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 10px;
  }
}
.h-tapring {
  animation-duration: 1.2s;
}
.h-key {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-weight: 850;
  font-size: 20px;
  box-shadow: 0 4px 0 var(--ink);
  animation: h-press 1s ease-in-out infinite;
}
.h-key.pink {
  background: #fde3ea;
  color: var(--ink);
}
.h-key.blue {
  background: #e2f3f6;
  color: var(--ink);
}
@keyframes h-press {
  0%,
  40% {
    translate: 0 0;
    box-shadow: 0 4px 0 var(--ink);
  }
  50%,
  90% {
    translate: 0 3px;
    box-shadow: 0 1px 0 var(--ink);
  }
}
.h-bub {
  translate: -50% -100%;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 11px;
  font-weight: 850;
  font-size: clamp(13px, 3.6vw, 17px);
  white-space: nowrap;
  animation: h-bob 1s ease-in-out infinite alternate;
}
.h-bub:after {
  content: "";
  position: absolute;
  left: calc(50% + var(--tx, 0px));
  bottom: -11px;
  margin-left: -7px;
  border: 7px solid transparent;
  border-top-color: var(--ink);
}
.h-bub.pink {
  background: #fde3ea;
  color: var(--ink);
}
.h-bub.blue {
  background: #e2f3f6;
  color: var(--ink);
}
@keyframes h-bob {
  to {
    translate: -50% calc(-100% - 6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hint {
    transition: none;
  }
  .hint * {
    animation: none !important;
  }
  .h-thumb {
    translate: 16px 0;
  }
  .h-key {
    translate: 0 3px;
    box-shadow: 0 1px 0 var(--ink);
    background: #f9d993;
  }
  .h-ring {
    opacity: 0.9;
  }
}
.mini-cakes .gone {
  filter: grayscale(1);
  opacity: 0.3;
  text-decoration: line-through;
}
.mini-cakes .just-broke {
  animation: meter-break 0.55s ease-out;
}
@keyframes meter-break {
  50% {
    transform: rotate(22deg) scale(1.35);
  }
}
.overlay.result-open {
  position: fixed;
  z-index: 20;
  background: #283c49aa;
  backdrop-filter: blur(4px);
}
.panel.result {
  max-width: 520px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  transform: none;
  padding: 20px 24px;
}
.panel.result h2 {
  margin: 8px 0 3px;
  font-size: clamp(29px, 6vw, 40px);
}
.panel.result .team-copy {
  margin: 0 0 10px;
}
.blame-chart {
  display: grid;
  gap: 6px;
  text-align: left;
  margin: 12px 0;
}
.blame-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(75px, 1.3fr) 28px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.blame-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.blame-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  margin-right: 5px;
}
.blame-track {
  height: 13px;
  border: 1px solid #b5c4c2;
  border-radius: 8px;
  background: #e7e9df;
  overflow: hidden;
}
.blame-bar {
  height: 100%;
}
.blame-icons {
  font-size: 13px;
  line-height: 1.2;
  min-height: 14px;
}
.blame-count {
  text-align: right;
  font-weight: 900;
}
.blame-award {
  background: #f6e4b9;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 850;
}
.blame-roast {
  background: #f8e6dc;
  border-left: 4px solid var(--coral);
  border-radius: 5px;
  padding: 8px 10px;
  margin: 9px 0;
  font-size: 12px;
  font-weight: 700;
}
.blame-pin {
  width: 100%;
  padding: 7px;
  background: #d9eced;
  font-size: 12px;
  margin-bottom: 12px;
}
.panel.result .result-score {
  margin: 9px 0;
}
.panel.result .result-score strong {
  font-size: 19px;
}
.panel.result .stars {
  font-size: 21px;
}
@media (max-width: 650px) {
  .panel.result {
    padding: 14px 16px;
    max-width: 360px;
  }
  .blame-row {
    font-size: 11px;
    grid-template-columns: minmax(74px, 1fr) minmax(65px, 1.2fr) 23px;
    gap: 5px;
  }
  .panel.result .blame-chart {
    margin: 8px 0;
  }
  .panel.result .result-score {
    gap: 12px;
  }
}
.nudge-card {
  position: relative;
  margin-top: 13px;
  padding: 12px 14px;
  border: 1.5px solid #d0ad68;
  border-radius: 12px;
  background: #fff3d9;
  text-align: left;
}
.nudge-card p {
  margin: 0 30px 9px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}
.nudge-card .nudge-start {
  padding: 7px 11px;
  font-size: 12px;
  background: #f3d88f;
  box-shadow: 0 2px 0 var(--ink);
}
.nudge-card .nudge-dismiss {
  position: absolute;
  right: 7px;
  top: 5px;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
}
.commentary-line {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3d88f;
  font-size: 12px;
  font-weight: 800;
}
.party-actions {
  flex: 1 1 460px;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.party-actions small {
  width: 100%;
  font-weight: 800;
  color: #866447;
}
.party-actions button {
  padding: 7px 9px;
  font-size: 12px;
  box-shadow: 0 2px 0 var(--ink);
}
.party-actions button[disabled] {
  opacity: 0.5;
  cursor: default;
}
.party-actions.offline-only[hidden],
.party-actions > div[hidden] {
  display: none;
}
/* Only while a round is on; the space stays so the page does not jump when one starts. */
.party-actions.idle {
  visibility: hidden;
}
.party-actions > div {
  display: grid;
  grid-template-columns: 32px repeat(4, minmax(0, 1fr));
  width: 100%;
  align-items: center;
  gap: 5px;
}
.party-actions b {
  font-size: 12px;
  min-width: 32px;
}
.party-actions kbd {
  font:
    10px ui-monospace,
    monospace;
  opacity: 0.7;
}
.party-actions button {
  min-height: 38px;
  padding: 6px 4px;
  white-space: nowrap;
}
.party-actions [data-cd] {
  display: block;
  min-height: 12px;
  line-height: 12px;
  font-size: 10px;
}
.party-actions .blue-actions b {
  color: #267c99;
}
@media (pointer: coarse) {
  .party-actions button {
    min-height: 44px;
  }
  .party-actions kbd {
    display: none;
  }
}
.emote-corner {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 5;
  display: grid;
  justify-items: end;
  gap: 5px;
  max-width: calc(100% - 16px);
}
.emote-corner[hidden] {
  display: none;
}
.emote-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 23px;
  background: #fff8e9;
}
.emote-quick {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff8e9;
  box-shadow: 0 3px 0 var(--ink);
  max-width: 100%;
  overflow-x: auto;
}
.emote-quick[hidden] {
  display: none;
}
.sticker-pick {
  width: 46px;
  height: 46px;
  padding: 1px;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 2px 0 var(--ink);
  background: #fffaf0;
}
.sticker-pick svg,
.sticker-pick .gif-media {
  width: 38px;
  height: 38px;
}
.sticker-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin: 7px 0;
}
.sticker-row .sticker-pick {
  width: 44px;
  height: 44px;
}
.sticker-row .sticker-pick svg,
.sticker-row .sticker-pick .gif-media {
  width: 36px;
  height: 36px;
}
.gif-media {
  display: block;
  object-fit: cover;
  border-radius: 7px;
  max-width: 100%;
  max-height: 100%;
}
.gif-media[hidden] {
  display: none;
}
.gif-fallback {
  display: none;
}
.gif-media[hidden] + .gif-fallback {
  display: grid;
  place-items: center;
}
.sticker-title {
  margin-top: 9px;
}
.sticker-bubble {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  transform: translate(-50%, -100%);
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  background: #fff8e9;
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
}
.sticker-bubble svg,
.sticker-bubble .gif-media {
  width: 53px;
  height: 53px;
}
.sticker-bubble:after {
  content: "";
  position: absolute;
  bottom: -9px;
  border: 7px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}
.sticker-notice {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: #fff8e9;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.sticker-notice[hidden] {
  display: none;
}
.sticker-notice svg,
.sticker-notice .gif-media {
  width: 34px;
  height: 34px;
  flex: none;
}
.room-card .sticker-mark {
  width: 29px;
  height: 29px;
  margin-left: auto;
}
.room-card .sticker-mark svg,
.room-card .sticker-mark .gif-media {
  width: 29px;
  height: 29px;
}
@media (max-width: 650px) {
  .emote-corner {
    right: 5px;
    top: 5px;
  }
  .emote-toggle {
    width: 40px;
    height: 40px;
  }
  .emote-quick {
    max-width: min(290px, calc(100vw - 16px));
  }
  .sticker-pick {
    width: 42px;
    height: 42px;
  }
  .sticker-pick svg,
  .sticker-pick .gif-media {
    width: 35px;
    height: 35px;
  }
}
@media (orientation: portrait) and (max-width: 650px) {
  .reactbar {
    top: 56px;
  }
  .emote-corner:has(.emote-quick:not([hidden])) ~ .reactbar {
    top: 118px;
  }
}
.preview-mode .hud,
.preview-mode .game-shell,
.preview-mode .controls,
.preview-mode .instructions-inline,
.preview-mode footer {
  display: none;
}
.level-preview h2 {
  margin: 0 0 5px;
}
.level-preview p {
  margin: 5px 0 12px;
}
.preview-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.preview-links a {
  padding: 5px 9px;
  border: 1px solid #8c9994;
  border-radius: 7px;
  color: var(--ink);
  background: #fffaf0;
  text-decoration: none;
}
.preview-links a[aria-current] {
  background: #f3d88f;
  border-color: var(--ink);
}
.preview-scroll {
  overflow-x: auto;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #efdfc5;
}
.preview-scroll svg {
  display: block;
  width: 100%;
  min-width: 900px;
  height: auto;
}
.preview-key {
  font-size: 12px;
  color: #607075;
}
#game3d {
  display: none;
  position: absolute;
  z-index: -1;
  pointer-events: none;
  aspect-ratio: auto;
}
.game-shell {
  isolation: isolate;
}
/* The text label keeps the automatic-audio control explicit without crowding the HUD. */
.auto-commentary {
  width: auto;
  min-width: 48px;
  padding: 0 7px;
  font-size: 10px;
  letter-spacing: 0.2px;
}
@media (max-width: 650px) {
  .auto-commentary {
    width: auto;
    min-width: 45px;
    padding: 0 5px;
  }
}
@media (max-width: 420px) {
  .hud-end {
    gap: 3px;
  }
  .auto-commentary {
    min-width: 42px;
    font-size: 9px;
    padding: 0 3px;
  }
}
/* isolation keeps #game3d behind the 2D canvas, but it also traps a full-screen menu's z-index inside the shell,
   so later page content (the half-transparent disabled comedy buttons) painted over it. Lift the shell while one is open. */
.game-shell:has(.overlay.result-open) {
  z-index: 21;
}
.view3d #game3d {
  display: block;
}
.view-toggle {
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.5px;
}
.view-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: #fffaf0;
}
/* UI polish: livelier meter, softer overlay, panels that pop in, and a warmer start button. */
.balance-fill {
  background: linear-gradient(90deg, #79b999, #e4b34e 70%, #ef796f);
  background-size: 130px 100%;
  transition: width 0.15s ease-out;
}
.overlay {
  backdrop-filter: blur(5px) saturate(1.1);
  background: #fcf5e85c;
}
.panel {
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96) rotate(-1deg);
  }
}
.start {
  background: linear-gradient(180deg, #f3897f, var(--coral));
  transition:
    filter 0.15s,
    transform 0.15s;
}
.start:hover {
  filter: brightness(1.06) drop-shadow(0 0 10px #ef796f66);
}
.mode-options button {
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.15s;
}
.hud {
  background: linear-gradient(180deg, #fffef9, #fffcf4);
}
.mute {
  transition:
    background 0.15s,
    color 0.15s;
}
@media (prefers-reduced-motion: reduce) {
  .panel {
    animation: none;
  }
  .balance-fill {
    transition: none;
  }
}
.h-cap {
  width: max-content;
}
@media (max-width: 650px) {
  .view3d .h-bub {
    display: none;
  }
}
/* Keep status readable when the extra view control makes a single HUD row too tight. */
@media (max-width: 650px) {
  .hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }
  .hud .layers {
    grid-column: 1;
    grid-row: 1;
  }
  .hud-end {
    grid-column: 2;
    grid-row: 1;
  }
  .hud .level-tag {
    grid-column: 1;
    grid-row: 2;
    max-width: none;
    min-width: 0;
  }
  .hud .balance {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-end;
  }
  .balance-track {
    width: 100px;
  }
}
@media (max-width: 650px) and (orientation: portrait) {
  body:not(.is-touch) #game {
    height: clamp(310px, 58svh, 520px);
    aspect-ratio: auto;
  }
  body:not(.is-touch) .game-shell {
    min-height: 0;
  }
}
.race-board {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 4;
  display: grid;
  gap: 4px;
  width: min(250px, 46%);
  padding: 7px 9px;
  background: #fffaf0eb;
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 #17242b33;
  pointer-events: none;
  font-size: 11px;
}
.rb-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #866447;
  white-space: nowrap;
}
.rb-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
}
.rb-row.out {
  opacity: 0.5;
}
.rb-name {
  font-weight: 850;
  white-space: nowrap;
}
.rb-you {
  font-size: 8px;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff9e9;
  margin-left: 4px;
  vertical-align: 1px;
}
.rb-track {
  height: 8px;
  min-width: 24px;
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  background: #e6e4d9;
  overflow: hidden;
}
.rb-fill {
  height: 100%;
  transition: width 0.25s;
}
.rb-meta {
  display: flex;
  gap: 4px;
  align-items: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rb-meter .gone {
  filter: grayscale(1);
  opacity: 0.25;
}
.rb-pct {
  min-width: 30px;
  text-align: right;
}
@media (max-width: 650px) {
  .race-board {
    left: 6px;
    top: 6px;
    padding: 5px 6px;
    gap: 3px;
    font-size: 9px;
  }
  .rb-head {
    letter-spacing: 0.4px;
    font-size: 8px;
  }
  .rb-team {
    display: none;
  }
  .rb-pct {
    min-width: 24px;
  }
}
.game-center-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--ink);
  font-weight: 850;
  text-decoration-thickness: 2px;
}
