:root {
  --ink: #1d1f2e;
  --navy: #1b2238;
  --navy2: #263156;
  --paper: #fffaf0;
  --red: #d6303d;
  --red2: #a81f2b;
  --green: #22a05b;
  --amber: #f0a020;
  --gold: #ffd34d;
  --blue: #2f7fd6;
  --must: #e0474c;
  --bonus: #2fae66;
  --ping: #f0a020;
  --shadow: 0 10px 30px rgba(10, 14, 30, 0.35);
  --r: 18px;
  font-family: Fredoka, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
canvas#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
button {
  font: inherit;
  cursor: pointer;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  border: 1px solid #ccc;
  border-bottom-width: 3px;
  font-weight: 700;
  font-size: 0.9em;
  text-align: center;
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
  overflow-y: auto;
  touch-action: pan-y;
}
.screen.show {
  display: flex;
}
#sc-loading {
  flex-direction: column;
  background: radial-gradient(ellipse at center, #2b3866, #141a2c);
  color: #fff;
  gap: 20px;
}
.loading-line {
  opacity: 0.75;
  font-size: 18px;
}
.logo {
  font-weight: 700;
  font-size: clamp(42px, 9vw, 76px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo span {
  color: var(--red);
}
#sc-loading .logo {
  color: #fff;
}
.panel {
  background: var(--paper);
  border-radius: 26px;
  box-shadow: var(--shadow), inset 0 0 0 4px #fff;
  padding: 26px 28px;
  width: min(560px, 100%);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  position: relative;
  margin: auto;
}
.panel::before {
  /* candy-cane trim */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 10px;
  border-radius: 26px 26px 0 0;
  background: repeating-linear-gradient(-45deg, var(--red) 0 12px, #fff 12px 24px);
}
.panel.small {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel h2 {
  margin: 6px 0 8px;
  font-size: 30px;
  line-height: 1.1;
}
.panel h3 {
  margin: 10px 0 4px;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-top: 6px;
}
.muted {
  color: #5b5e70;
}
.small {
  font-size: 12px;
}
.pitch {
  font-size: 17px;
  line-height: 1.4;
  margin: 12px 0 14px;
  color: #3a3d50;
}
.title-panel {
  width: min(520px, 100%);
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
}
.btn {
  border: 0;
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 3px 0 #d8d2c3, 0 0 0 2px #e9e3d4 inset;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink);
  transition: transform 0.08s;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d8d2c3, 0 0 0 2px #e9e3d4 inset;
}
.btn b {
  font-size: 17px;
  font-weight: 600;
}
.btn small {
  color: #6b6e80;
  font-size: 13px;
}
.btn.primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 var(--red2);
}
.btn.primary small {
  color: #ffd8dc;
}
.btn.big {
  padding: 16px 18px;
}
.btn.big b {
  font-size: 21px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn:focus-visible,
.link:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.link {
  background: none;
  border: 0;
  color: var(--blue);
  text-decoration: underline;
  padding: 6px;
  font-size: 15px;
}
.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 600;
}
.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: #5b5e70;
}
.mute {
  position: fixed;
  top: 14px;
  right: 14px;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  box-shadow: var(--shadow);
}

/* Title screen sits on the left so the office shows behind */
#sc-title {
  justify-content: flex-start;
  padding-left: max(16px, 5vw);
}
#sc-avatar {
  justify-content: flex-start;
  padding-left: max(16px, 5vw);
}
@media (min-width: 761px) {
  #sc-title .panel,
  #sc-avatar .panel {
    margin: auto 0;
  }
}
@media (max-width: 760px) {
  #sc-title,
  #sc-avatar {
    justify-content: center;
    padding-left: 16px;
  }
  #sc-avatar {
    align-items: flex-end;
  }
  .avatar-panel {
    max-height: 62vh;
  }
}

/* Avatar */
.avatar-panel {
  width: min(440px, 100%);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 10px;
}
.field input {
  font: inherit;
  font-size: 18px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #e2dccd;
  user-select: text;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
}
.pick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.pick > span {
  width: 64px;
  font-weight: 600;
  font-size: 14px;
}
.swatches,
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.swatches button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #ddd;
}
.swatches button.on,
.chips button.on {
  box-shadow: 0 0 0 3px var(--blue);
}
.chips button {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  box-shadow: 0 0 0 2px #e2dccd;
  font-size: 14px;
}

/* Briefing */
.brief-panel {
  width: min(600px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brief-list {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  display: grid;
  gap: 6px;
}
.brief-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  border-left: 6px solid var(--c);
}
.brief-list li b {
  display: block;
}
.brief-list li small {
  color: #6b6e80;
}
.brief-list .tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--c);
  min-width: 58px;
  padding-top: 3px;
}
.controls-mini {
  font-size: 13px;
  color: #5b5e70;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 4px 0 6px;
}

/* End */
.end-panel {
  width: min(600px, 100%);
  text-align: center;
}
.end-emoji {
  font-size: 64px;
  line-height: 1;
  margin-top: 8px;
  animation: bounce 1s infinite alternate ease-in-out;
}
@keyframes bounce {
  to {
    transform: translateY(-8px) rotate(6deg);
  }
}
.end-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 16px;
  align-items: center;
  margin: 14px 0;
  text-align: left;
}
@media (max-width: 520px) {
  .end-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
}
.wristband {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 14px;
  position: relative;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}
.wristband::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transform: translateY(-50%);
}
.end-score {
  font-size: 54px;
  font-weight: 700;
  line-height: 1.1;
}
.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.breakdown td {
  padding: 5px 4px;
  border-bottom: 1px dashed #e2dccd;
}
.breakdown td:last-child {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.breakdown tr.total td {
  font-size: 17px;
  border-bottom: 0;
}
.trees {
  font-size: 22px;
  letter-spacing: 2px;
  margin: 4px 0 14px;
  line-height: 1.3;
}
.trees small {
  display: block;
  font-size: 13px;
  letter-spacing: 0;
  color: #5b5e70;
}

/* Leaderboard */
.board-panel {
  width: min(620px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tabs {
  display: flex;
  gap: 6px;
}
.tabs button {
  flex: 1;
  border: 0;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 0 0 2px #e2dccd inset;
  font-weight: 600;
}
.tabs button.on {
  background: var(--navy);
  color: #fff;
  box-shadow: none;
}
.board-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.board-body td,
.board-body th {
  padding: 7px 6px;
  text-align: left;
  border-bottom: 1px solid #efe9dc;
}
.board-body th {
  font-size: 12px;
  text-transform: uppercase;
  color: #6b6e80;
  font-weight: 600;
}
.board-body td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.board-body tr.me td {
  background: #fff3c4;
}
.board-body .rank {
  width: 28px;
  font-weight: 700;
}
.ava {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  vertical-align: middle;
  margin-right: 6px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #ddd;
}
.band-mini {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.board-empty {
  padding: 24px;
  text-align: center;
  color: #6b6e80;
}
@media (max-width: 520px) {
  .board-body .hide-sm {
    display: none;
  }
}

/* Help */
.help-panel {
  width: min(680px, 100%);
}
.help-steps {
  padding-left: 20px;
  line-height: 1.5;
}
.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}
.keys th,
.keys td {
  padding: 5px;
  border-bottom: 1px solid #efe9dc;
  text-align: left;
}
.help-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  font-size: 14px;
  line-height: 1.45;
}
@media (max-width: 560px) {
  .help-cols {
    grid-template-columns: 1fr;
  }
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  color: #fff;
}
#hud[hidden] {
  display: none;
}
#hud > * {
  position: absolute;
}
#vignette {
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px 30px rgba(255, 30, 0, 0);
  transition: box-shadow 0.4s;
}
body.on-fire #vignette {
  animation: firepulse 0.8s infinite alternate;
}
@keyframes firepulse {
  from {
    box-shadow: inset 0 0 120px 30px rgba(255, 40, 0, 0.35);
  }
  to {
    box-shadow: inset 0 0 160px 60px rgba(255, 90, 0, 0.6);
  }
}
#clockBox {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  border-radius: 16px;
  padding: 6px 18px 8px;
  text-align: center;
  box-shadow: var(--shadow), inset 0 0 0 3px #3a4775;
}
#clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 34px;
  font-weight: 700;
  color: #7cffb2;
  text-shadow: 0 0 12px rgba(124, 255, 178, 0.5);
  letter-spacing: 0.04em;
  line-height: 1.1;
}
#partyIn {
  font-size: 13px;
  opacity: 0.85;
}
.party-at {
  font-size: 11px;
  opacity: 0.6;
}
#clockBox.late #clock {
  color: var(--gold);
  animation: tick 1s infinite;
}
#clockBox.over #clock {
  color: #ff6a6a;
}
@keyframes tick {
  50% {
    transform: scale(1.06);
  }
}
#todoBox {
  top: 12px;
  left: 12px;
  width: 290px;
  background: rgba(255, 250, 240, 0.95);
  color: var(--ink);
  border-radius: 16px;
  padding: 10px 10px 6px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
#todoHead {
  font-weight: 700;
  font-size: 14px;
  margin: 0 4px 6px;
}
.todo-foot {
  font-size: 11px;
  color: #8a8c9a;
  margin: 4px 4px 0;
}
#todo {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
#todo li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 5px 8px;
  border-radius: 10px;
  border-left: 5px solid var(--c);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
}
#todo li.t-must {
  --c: var(--must);
}
#todo li.t-bonus {
  --c: var(--bonus);
}
#todo li.esc {
  --c: var(--must);
  background: #fff0e0;
}
#todo li.sel {
  box-shadow: 0 0 0 2px var(--c);
  background: #fffbe8;
}
#todo li.done {
  opacity: 0.45;
}
#todo li.done b {
  text-decoration: line-through;
}
#todo li.pop {
  animation: pop 0.5s;
}
@keyframes pop {
  30% {
    transform: scale(1.08);
    background: #d6ffe4;
  }
}
#todo .tick {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  border: 2px solid var(--c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}
#todo li.done .tick {
  background: var(--c);
}
#todo b {
  font-weight: 600;
  display: block;
}
#todo small {
  color: #6b6e80;
  font-size: 11px;
}
#scoreBox {
  top: 12px;
  right: 12px;
  text-align: right;
  background: var(--navy);
  padding: 6px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 110px;
}
#score {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
#combo {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  height: 0;
  overflow: hidden;
}
#combo.on {
  height: auto;
  animation: pop 0.4s;
}
#pings {
  top: 82px;
  right: 12px;
  width: 270px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.ping {
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 8px 10px 6px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--ping);
  font-size: 13px;
  animation: slidein 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  cursor: pointer;
}
.ping.sel {
  box-shadow: 0 0 0 2px var(--ping), var(--shadow);
}
.ping.urgent {
  animation: wobble 0.4s infinite;
}
@keyframes slidein {
  from {
    transform: translateX(120%);
  }
}
@keyframes wobble {
  25% {
    transform: rotate(-1.5deg);
  }
  75% {
    transform: rotate(1.5deg);
  }
}
.ping-from {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6b6e80;
}
.ping-from b {
  color: #7a3fa0;
}
.ping-text {
  margin: 2px 0 6px;
  line-height: 1.25;
}
.ping-bar {
  height: 4px;
  border-radius: 2px;
  background: #f0e8d8;
  overflow: hidden;
}
.ping-bar i {
  display: block;
  height: 100%;
  background: var(--ping);
  transform-origin: left;
}
.ping.urgent .ping-bar i {
  background: var(--must);
}
#status {
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
#stamina {
  width: 200px;
  height: 12px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.8);
}
#stamina i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7cffb2, #3bd16f);
  transform-origin: left;
}
#stamina.coffee i {
  background: linear-gradient(90deg, #c98a3c, #ffd34d);
}
#effects {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 320px;
}
.fx {
  background: rgba(27, 34, 56, 0.85);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
}
.fx.carry {
  background: var(--blue);
}
.fx.dim {
  opacity: 0.85;
}
#banner {
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: min(560px, 90vw);
}
.ban {
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.ban.bad {
  background: var(--must);
  animation: tick 0.8s infinite;
}
.ban.warn {
  background: var(--amber);
  color: var(--ink);
}
.ban.good {
  background: rgba(34, 160, 91, 0.92);
}
#prompt {
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  background: rgba(255, 250, 240, 0.96);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#prompt.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#toasts {
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: min(560px, 92vw);
}
.toast {
  background: rgba(27, 34, 56, 0.94);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 15px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toastin 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  transition: opacity 0.4s, transform 0.4s;
}
.toast.good {
  background: rgba(30, 140, 80, 0.96);
}
.toast.bad {
  background: rgba(200, 40, 55, 0.96);
}
.toast.warn {
  background: rgba(240, 160, 32, 0.97);
  color: var(--ink);
}
.toast.out {
  opacity: 0;
  transform: translateY(10px);
}
@keyframes toastin {
  from {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }
}
#bubbles,
#floaters {
  inset: 0;
}
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 240px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastin 0.25s;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
  transform: translateX(-50%);
}
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 22px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 8px rgba(0, 0, 0, 0.3);
  animation: floatup 1.4s forwards;
  white-space: nowrap;
}
.floater.good {
  color: var(--gold);
  font-size: 28px;
}
@keyframes floatup {
  0% {
    transform: translate(-50%, -30%) scale(0.6);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -60%) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -260%) scale(1);
    opacity: 0;
  }
}
#popups {
  inset: 0;
  pointer-events: none;
}
.popup {
  position: absolute;
  width: 220px;
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 10px 12px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 6px solid var(--blue);
  animation: toastin 0.3s backwards;
  font-size: 14px;
}
.popup i {
  position: absolute;
  top: 6px;
  right: 10px;
  font-style: normal;
  color: #999;
}
#pauseBtn {
  top: 12px;
  left: 50%;
  margin-left: 110px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(27, 34, 56, 0.85);
  color: #fff;
  pointer-events: auto;
  font-size: 13px;
}

/* Touch controls */
#touch {
  inset: 0;
  display: none;
}
body.touch #touch {
  display: block;
}
#joyZone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60%;
  height: 60%;
  pointer-events: auto;
}
#joyBase {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: none;
  pointer-events: none;
}
#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
}
#touch button {
  position: absolute;
  pointer-events: auto;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  touch-action: none;
}
#touch button small {
  font-size: 10px;
  font-weight: 500;
}
#btnAction {
  right: 18px;
  bottom: 28px;
  width: 86px;
  height: 86px;
  background: var(--red);
  font-size: 26px;
}
#btnSprint {
  right: 116px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  background: var(--blue);
  font-size: 20px;
}
#btnDrop {
  right: 30px;
  bottom: 128px;
  width: 52px;
  height: 52px;
  background: #555c70;
  font-size: 16px;
}
body.touch #prompt {
  bottom: 130px;
}
body.touch #status {
  bottom: auto;
  top: 12px;
  left: auto;
  right: 12px;
  align-items: flex-end;
  display: none;
}
body.in-mg #touch,
body.in-mg #prompt {
  display: none !important;
}

/* Small screens: compact HUD */
@media (max-width: 760px) {
  #todo b {
    font-size: 11px;
  }
  #todo li.done {
    display: none;
  }
  #todo .tick {
    width: 14px;
    height: 14px;
  }
  #todoHead {
    font-size: 12px;
  }
  #todoBox {
    width: 168px;
    padding: 6px 6px 4px;
    max-height: 46vh;
    overflow-y: auto;
  }
  #todo li {
    padding: 4px 6px;
    font-size: 11px;
  }
  #todo small {
    display: none;
  }
  #todo li.sel small {
    display: block;
  }
  .todo-foot {
    display: none;
  }
  #clockBox {
    padding: 4px 10px 5px;
    left: auto;
    right: 12px;
    transform: none;
    top: 64px;
  }
  #clock {
    font-size: 24px;
  }
  .party-at {
    display: none;
  }
  #scoreBox {
    padding: 4px 10px;
    min-width: 90px;
  }
  #score {
    font-size: 20px;
  }
  #pings {
    top: 140px;
    width: 178px;
  }
  .ping {
    font-size: 11px;
    padding: 6px 8px 5px;
  }
  #pauseBtn {
    left: auto;
    right: 112px;
    margin: 0;
    width: 36px;
    height: 36px;
  }
  #banner {
    top: auto;
    bottom: 200px;
  }
  .ban {
    font-size: 12px;
  }
  #toasts {
    bottom: 150px;
  }
  .toast {
    font-size: 13px;
  }
  #status {
    bottom: auto;
    top: auto;
  }
  body.touch #status {
    display: flex;
    top: auto;
    bottom: 180px;
    left: 12px;
    right: auto;
    align-items: flex-start;
  }
  #stamina {
    width: 120px;
  }
}

/* ---------- Mini-game overlay ---------- */
#mg {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 16, 32, 0.55);
  backdrop-filter: blur(2px);
}
#mg.show {
  display: flex;
}
.mg-card {
  width: min(560px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 18px 20px 16px;
  box-shadow: var(--shadow), inset 0 0 0 4px #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow-y: auto;
}
.mg-card.shake {
  animation: shake 0.3s;
}
.mg-card.zap {
  background: #fff0f0;
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}
.mg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.mg-title {
  font-weight: 700;
  font-size: 20px;
}
.mg-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  color: #fff;
  background: var(--bonus);
}
.mg-tag.must {
  background: var(--must);
}
.mg-tag.ping {
  background: var(--ping);
  color: var(--ink);
}
.mg-timer {
  height: 8px;
  background: #ece4d2;
  border-radius: 4px;
  overflow: hidden;
}
.mg-timer i {
  display: block;
  height: 100%;
  background: var(--green);
  transform-origin: left;
}
.mg-timer i.low {
  background: var(--must);
}
.mg-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}
.mg-hint {
  font-size: 13px;
  color: #6b6e80;
  text-align: center;
}
.mg-word {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-6deg);
  font-size: clamp(54px, 14vw, 120px);
  font-weight: 700;
  color: var(--gold);
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink);
  pointer-events: none;
  animation: shout 0.75s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
  z-index: 2;
}
.mg-word.gone {
  display: none;
}
@keyframes shout {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(-20deg);
    opacity: 0;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.15) rotate(-6deg);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -50%) scale(1) rotate(-6deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.4) rotate(-6deg);
    opacity: 0;
  }
}
.mg-result {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  border-radius: 24px;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}
.mg-result.show {
  display: flex;
  animation: toastin 0.25s;
}
.mg-result.win {
  background: rgba(34, 160, 91, 0.95);
}
.mg-result.lose {
  background: rgba(200, 40, 55, 0.95);
}
.mg-action {
  align-self: center;
  border: 0;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  padding: 14px 34px;
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--red2);
  touch-action: none;
}
.mg-action:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--red2);
}
.mg-action:disabled {
  opacity: 0.5;
}
.mg-holiday {
  border: 0;
  background: #e6f6ff;
  border-radius: 12px;
  padding: 8px;
  font-weight: 600;
  color: #135c8a;
}

/* timing */
.tm-items {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 30px;
}
.tm-items span.in {
  opacity: 0.2;
  transform: scale(0.7);
  transition: all 0.2s;
}
.tm-track {
  position: relative;
  height: 54px;
  background: #2a2f45;
  border-radius: 12px;
  overflow: hidden;
}
.tm-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, #3bd16f, #22a05b);
  transition: left 0.2s, width 0.2s;
}
.tm-marker {
  position: absolute;
  top: 6px;
  width: 30px;
  margin-left: -15px;
  text-align: center;
  font-size: 28px;
  color: #fff;
}
.tm-case {
  min-height: 52px;
  border: 4px dashed #8a8c9a;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 28px;
  position: relative;
}
.tm-case small {
  position: absolute;
  top: 2px;
  left: 8px;
  font-size: 11px;
  color: #8a8c9a;
  text-transform: uppercase;
}

/* hold */
.hd-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
}
.hd-emoji {
  font-size: 64px;
}
.hd-jar {
  position: relative;
  width: 90px;
  height: 180px;
  border: 5px solid #8a8c9a;
  border-top: 0;
  border-radius: 0 0 20px 20px;
  overflow: hidden;
  background: #fff;
}
.hd-water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #6ad1ff, #2f7fd6);
}
.hd-band {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 3px dashed var(--green);
  border-bottom: 3px dashed var(--green);
  background: rgba(34, 160, 91, 0.18);
}
.hd-bar {
  height: 26px;
  background: #ece4d2;
  border-radius: 13px;
  overflow: hidden;
}
.hd-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3bd16f, #22a05b);
}
.hd-status {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
}
.hd-status.warn {
  color: var(--amber);
}
.hd-status.danger {
  color: var(--must);
  animation: tick 0.2s infinite;
}

/* mash */
.ms-emoji {
  font-size: 90px;
  text-align: center;
  transition: transform 0.06s;
}

/* sort */
.st-rule {
  text-align: center;
  font-weight: 600;
}
.st-count {
  text-align: center;
  font-size: 13px;
  color: #6b6e80;
}
.st-card {
  align-self: center;
  min-width: 260px;
  max-width: 100%;
  min-height: 90px;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 0 #e2dccd, 0 0 0 2px #e9e3d4 inset;
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.st-card.in {
  animation: cardin 0.2s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes cardin {
  from {
    transform: translateY(-20px) scale(0.85);
    opacity: 0;
  }
}
.st-card.application {
  border-top: 8px solid #7a3fa0;
}
.st-card.ticket {
  border: 3px dashed #c89a66;
  box-shadow: none;
  background: #fffaf0;
}
.st-card .bauble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: inset -8px -8px 0 rgba(0, 0, 0, 0.18), inset 6px 6px 0 rgba(255, 255, 255, 0.35);
}
.st-card .band {
  padding: 10px 28px;
  border-radius: 8px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.st-bins {
  display: grid;
  gap: 8px;
}
.st-bins.n2 {
  grid-template-columns: 1fr 1fr;
}
.st-bins.n4 {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas: '. up .' 'left down right';
}
.st-bin {
  border: 0;
  border-radius: 14px;
  padding: 10px;
  background: var(--c);
  color: #fff;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.st-bin b {
  font-size: 18px;
}
.st-bin.flash {
  animation: pop 0.25s;
}
.st-bins.n4 .ArrowUp {
  grid-area: up;
}
.st-bins.n4 .ArrowLeft {
  grid-area: left;
}
.st-bins.n4 .ArrowRight {
  grid-area: right;
}
.st-bins.n4 .ArrowDown {
  grid-area: down;
}

/* choice */
.ch-caller {
  font-size: 40px;
  text-align: center;
  animation: wobble 0.3s infinite;
}
.ch-q {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}
.ch-sub {
  text-align: center;
  font-size: 13px;
  color: #6b6e80;
}
.ch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch-opt {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  box-shadow: 0 0 0 2px #e2dccd inset;
  text-align: left;
  font-size: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.ch-opt b {
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 13px;
}
.ch-opt.sel {
  box-shadow: 0 0 0 3px var(--blue) inset;
}
.ch-opt.wrong {
  background: #ffe0e0;
  text-decoration: line-through;
}

/* typing */
.ty-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 30px;
  text-align: center;
}
.ty-code s {
  color: var(--must);
}
.ty-code b {
  color: var(--green);
}
.ty-hint {
  text-align: center;
  font-weight: 600;
}
.ty-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  border: 3px solid var(--blue);
  text-transform: uppercase;
  user-select: text;
  -webkit-user-select: text;
}
.ty-input:focus {
  outline: none;
}
.ty-counter {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}
.ty-counter.danger {
  color: var(--must);
  animation: tick 0.4s infinite;
}

/* whack */
.wk-score {
  text-align: center;
  font-weight: 700;
  font-size: 18px;
}
.wk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.wk-cell {
  aspect-ratio: 1.5;
  border: 0;
  border-radius: 14px;
  background: #2a2f45;
  position: relative;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.wk-cell.up {
  background: #3a4370;
}
.wk-cell.cur {
  box-shadow: 0 0 0 3px var(--gold) inset;
}
.wk-cell small {
  position: absolute;
  left: 6px;
  top: 4px;
  font-size: 11px;
  color: #8a90b0;
}
.wk-who {
  animation: none;
}
.wk-cell.up .wk-who {
  animation: popup 0.15s;
}
@keyframes popup {
  from {
    transform: translateY(30px);
  }
}

/* deploy */
.dp-warn {
  text-align: center;
  font-weight: 600;
  color: var(--must);
}
.dp-log {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: #14182a;
  color: #7cffb2;
  border-radius: 10px;
  padding: 10px;
  min-height: 120px;
}

/* server */
.sv-phase {
  text-align: center;
  font-weight: 700;
  font-size: 18px;
}
.sv-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 120px;
  justify-content: center;
}
.sv-power {
  font-size: 64px;
  text-align: center;
}
.sv-cable {
  align-self: center;
  color: #fff;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 999px;
}
.sv-ports {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.sv-port {
  border: 0;
  border-radius: 12px;
  padding: 14px 6px;
  background: #2a2f45;
  color: #fff;
  font-weight: 600;
  border-bottom: 8px solid var(--c);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.sv-lights {
  display: flex;
  gap: 12px;
  justify-content: center;
  background: #14182a;
  padding: 22px;
  border-radius: 14px;
}
.sv-lights i {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}
.sv-lights i.g {
  background: #3bd16f;
  box-shadow: 0 0 14px #3bd16f;
}
.sv-lights i.r {
  background: #e0474c;
  box-shadow: 0 0 14px #e0474c;
}

/* collect */
.cl-need {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font-weight: 600;
}
.cl-need span {
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  box-shadow: 0 0 0 2px #e2dccd inset;
}
.cl-need span.ok {
  background: #d6ffe4;
  text-decoration: line-through;
}
.cl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: #7d8794;
  padding: 10px;
  border-radius: 12px;
}
.cl-cell {
  aspect-ratio: 1.2;
  border: 0;
  border-radius: 10px;
  background: #eef0f4;
  font-size: 32px;
}
.cl-cell.empty {
  background: #5d6674;
}
.cl-cell.cur {
  box-shadow: 0 0 0 3px var(--gold);
}
.cl-cell.sparkle {
  animation: pop 0.5s 2;
  background: #fff3c4;
}
.cl-msg {
  text-align: center;
  min-height: 1.3em;
  font-weight: 600;
}

/* stealth */
.sl-status {
  text-align: center;
  font-weight: 700;
  font-size: 20px;
}
.sl-status.warn {
  color: var(--amber);
}
.sl-status.look {
  color: var(--must);
}
.sl-track {
  position: relative;
  height: 80px;
  background: linear-gradient(180deg, #c3d6e6, #a9c2d8);
  border-radius: 14px;
}
.sl-you {
  position: absolute;
  left: 0;
  top: 18px;
  font-size: 40px;
  margin-left: 8px;
}
.sl-you.moving {
  animation: wobble 0.25s infinite;
}
.sl-them {
  position: absolute;
  right: 10px;
  top: 12px;
  font-size: 48px;
}
