html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: system-ui, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

#game-wrap {
  position: relative;
  width: min(100vw, calc(100vh * 288 / 512));
  height: min(100vh, calc(100vw * 512 / 288));
  aspect-ratio: 288 / 512;
  container-type: size;
}

#game {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  outline: none;
}

#birdLayer {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% * 34 / 288);
  height: calc(100% * 24 / 512);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  pointer-events: none;
  z-index: 1;
  transform-origin: center center;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: #fff;
  z-index: 2;
}

#playerHud {
  position: absolute;
  top: 1.2%;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  font-size: 2.8cqh;
  letter-spacing: 0.08em;
  color: #ffe14a;
  text-shadow:
    2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000,
    2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

#worldRecordHud {
  position: absolute;
  top: 5%;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  font-size: 3.1cqh;
  letter-spacing: 0.06em;
  text-shadow:
    2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000,
    2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

#worldRecordHud span {
  color: #ffe14a;
}

#scoreHud {
  position: absolute;
  top: 8.6%;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 900;
  font-size: 36px;
  font-size: 8.5cqh;
  line-height: 1;
  text-shadow:
    3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000,
    3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000;
}

#likeGoalHud {
  position: absolute;
  top: 17.2%;
  left: 16%;
  right: 16%;
  text-align: center;
  pointer-events: none;
  z-index: 3;
}

#likeGoalHud[hidden] { display: none; }

body.mode-title #likeGoalHud {
  display: none !important;
}

body.game-over #likeGoalHud {
  display: none !important;
}

.likeGoalBar {
  height: 3px;
  max-width: 38%;
  margin: 0 auto 0.35cqh;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #000;
  border-radius: 2px;
  overflow: hidden;
}

.likeGoalBar > i {
  display: block;
  height: 100%;
  width: 0;
  background: #ffe14a;
}

.likeGoalName {
  font-size: 10px;
  font-size: 1.85cqh;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffe14a;
  text-shadow: 0 0 4px #000, 1px 1px 0 #000, -1px -1px 0 #000;
  margin-bottom: 0.15cqh;
}

.likeGoalText {
  font-size: 11px;
  font-size: 2.15cqh;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 0 4px #000, 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

#giftCallouts {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  height: 0;
  z-index: 6;
  pointer-events: none;
}

.giftCallout {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  text-align: center;
  white-space: nowrap;
  max-width: 86%;
  animation: giftCallout 1.65s cubic-bezier(0.18, 1.35, 0.28, 1) both;
}

.giftCallout .who {
  display: block;
  font-size: 13px;
  font-size: 2.7cqh;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    0 0 6px #000,
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000;
}

.giftCallout .what {
  display: block;
  font-size: 34px;
  font-size: 8.2cqh;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.03em;
  paint-order: stroke fill;
  -webkit-text-stroke: 1.4px #000;
  text-shadow:
    0 0 10px #000,
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000;
}

.giftCallout.up .what { color: #b8ff64; }
.giftCallout.down .what { color: #ff8a3a; }
.giftCallout.special .what {
  color: #ffe14a;
  text-shadow:
    0 0 14px #ffe14a,
    0 0 10px #000,
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000;
}

@keyframes giftCallout {
  0% { opacity: 0; transform: translate(-50%, 22%) scale(0.42); }
  12% { opacity: 1; transform: translate(-50%, -6%) scale(1.18); }
  20% { transform: translate(-50%, -10%) scale(0.96); }
  28% { transform: translate(-50%, -12%) scale(1); }
  68% { opacity: 1; transform: translate(-50%, -22%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -48%) scale(0.88); }
}

#centerHud {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 18%;
  text-align: center;
  font-weight: 900;
  text-shadow: 0 0 6px #000, 2px 2px 0 #000, -1px -1px 0 #000;
}

#centerHud.readyScreen {
  top: 26%;
  bottom: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

#centerHud.readyScreen .credit {
  margin-bottom: 0;
  margin-top: 1.2cqh;
}

#centerHud .title {
  font-size: 26px;
  font-size: 5.6cqh;
  line-height: 1.12;
  margin-bottom: 1.2cqh;
}

#centerHud .credit {
  font-size: 12px;
  font-size: 2.4cqh;
  font-weight: 700;
  color: #ffe14a;
  letter-spacing: 0.04em;
  margin-bottom: 2cqh;
}

#centerHud .ready {
  font-size: 24px;
  font-size: 5.2cqh;
  color: #ffe14a;
}

#centerHud .over {
  font-size: 24px;
  font-size: 5.2cqh;
  color: #ffe14a;
  margin-bottom: 2cqh;
}

#deadHud {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4cqh;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 0 6px #000, 1px 1px 0 #000;
}

#deadHud[hidden] { display: none; }

#deadHud.timedOut {
  top: 44%;
  bottom: auto;
}

#deadHud.timedOut .countdown,
#deadHud.timedOut .galaxyHint {
  display: none;
}

#deadHud .countdown {
  font-size: 28px;
  font-size: 5.6cqh;
  font-weight: 900;
  color: #fff;
  animation: revivePulse 0.9s ease-in-out infinite;
}

#deadHud .countdown span {
  color: #ffe14a;
}

#deadHud .galaxyHint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqh;
}

.deadPromptRow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 4cqh 6cqh;
  max-width: 94%;
}

.deadPromptGift {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6cqh;
}

.deadPromptGift img,
.deadPromptGift .giftPh {
  width: 20cqh;
  height: 20cqh;
  max-width: 112px;
  max-height: 112px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 0 14px #4cc8ff) drop-shadow(0 0 28px #ff4ad2);
  animation: galaxyPulse 1.1s ease-in-out infinite;
}

.deadPromptRow.one .deadPromptGift img,
.deadPromptRow.one .deadPromptGift .giftPh {
  width: 24cqh;
  height: 24cqh;
  max-width: 128px;
  max-height: 128px;
}

.deadPromptGift span {
  font-weight: 900;
  font-size: 14px;
  font-size: 3cqh;
  letter-spacing: 0.08em;
  color: #fff;
  text-align: center;
  text-shadow: 0 0 10px #4cc8ff, 0 0 18px #ff4ad2, 1px 1px 0 #000;
  animation: hypeFlash 0.7s ease-in-out infinite;
}

.deadPromptGift.reset img,
.deadPromptGift.reset .giftPh {
  filter: drop-shadow(0 0 14px #e07018) drop-shadow(0 0 24px #ff4ad2);
}

#deadHud .hype {
  margin: 0;
  font-weight: 900;
  font-size: 18px;
  font-size: 3.6cqh;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 0 10px #4cc8ff, 0 0 18px #ff4ad2, 1px 1px 0 #000;
  animation: hypeFlash 0.7s ease-in-out infinite;
}

@keyframes galaxyPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px #4cc8ff) drop-shadow(0 0 18px #ff4ad2); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 22px #7ae0ff) drop-shadow(0 0 36px #ff7ae8); }
}

@keyframes revivePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes hypeFlash {
  0%, 100% { opacity: 1; color: #fff; }
  50% { opacity: 0.85; color: #ffe14a; }
}

#deadHud #restartBtn {
  pointer-events: auto;
  background: #73c02a;
  color: #fff;
  border: 3px solid #000;
  border-radius: 10px;
  padding: 8px 22px;
  font: inherit;
  font-size: 16px;
  font-size: 3.2cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 4px 0 #000;
}

#deadHud #deadMenuBtn {
  display: none;
  pointer-events: auto;
  background: #2a1c22;
  color: #f4e6c3;
  border: 3px solid #000;
  border-radius: 10px;
  padding: 7px 22px;
  font: inherit;
  font-size: 14px;
  font-size: 2.8cqh;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 4px 0 #000;
}

#deadHud.timedOut #deadMenuBtn:not([hidden]) {
  display: inline-block;
}

body.overlay #deadMenuBtn {
  display: none !important;
}

#centerHud .stats {
  display: inline-block;
  background: rgba(238, 228, 184, 0.94);
  color: #3a2a20;
  border: 3px solid #000;
  border-radius: 10px;
  padding: 1.2cqh 2.2cqh;
  min-width: 64%;
  text-shadow: none;
  font-size: 13px;
  font-size: 2.55cqh;
  font-weight: 800;
}

#centerHud .stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.6cqh;
  margin: 0.45cqh 0;
}

#centerHud .stats div span:first-child {
  text-align: left;
}

#centerHud .stats div span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#centerHud .revive {
  margin-top: 2cqh;
  font-size: 13px;
  font-size: 2.6cqh;
  color: #ffe14a;
}

#centerHud .countdown {
  font-size: 28px;
  font-size: 6cqh;
  color: #fff;
  margin: 1.4cqh 0;
}

#centerHud .countdown span {
  color: #ffe14a;
}

#nameGate {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 18%;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  text-align: center;
}

#nameGate[hidden],
body.overlay #nameGate {
  display: none;
}

#authForm {
  width: 100%;
  max-width: 240px;
  padding: 10px 12px 12px;
  background: rgba(20, 14, 10, 0.92);
  border: 3px solid #543847;
  border-radius: 10px;
  box-shadow: 0 6px 0 #2a1c22, 0 0 0 2px #000;
}

.authBrand {
  font-weight: 900;
  font-size: 22px;
  font-size: 4.6cqh;
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 4px #000, 2px 2px 0 #000;
}

.authCredit {
  margin: 6px 0 10px;
  font-size: 10px;
  font-size: 1.9cqh;
  font-weight: 700;
  color: #ffe14a;
  text-shadow: 0 0 4px #000;
}

.authTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}

.authTabs button {
  background: #2a1c22;
  color: #c8b48a;
  border: 2px solid #543847;
  border-radius: 6px;
  padding: 5px 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.authTabs button.on {
  background: #73c02a;
  color: #fff;
  border-color: #000;
}

#nameGate label {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  font-weight: 800;
  font-size: 10px;
  font-size: 1.9cqh;
  letter-spacing: 0.08em;
  color: #f4e6c3;
  text-align: left;
  text-shadow: 0 0 4px #000;
}

#nameGate input {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin-top: 3px;
  padding: 7px 8px;
  border: 2px solid #543847;
  border-radius: 6px;
  background: #140e0c;
  color: #ffe14a;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.06em;
}

#nameGate input:focus {
  outline: none;
  border-color: #ffe14a;
}

#confirmRow[hidden] {
  display: none;
}

#authHint {
  margin: 2px 0 6px;
  font-size: 10px;
  font-size: 1.8cqh;
  font-weight: 700;
  color: #8a7a62;
  text-shadow: none;
}

#nameError {
  margin: 0 0 6px;
  color: #ff6b4a;
  font-size: 11px;
  font-size: 2cqh;
  font-weight: 800;
  text-shadow: 0 0 4px #000;
}

#nameError[hidden] { display: none; }

#nameGate button[type="submit"] {
  width: 100%;
  background: #73c02a;
  color: #fff;
  border: 3px solid #000;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#logoutBtn {
  margin-top: 12px;
  background: #8a6a3a;
  color: #fff;
  border: 3px solid #000;
  border-radius: 8px;
  padding: 6px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#pausedHud {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  text-shadow: 0 0 8px #000, 2px 2px 0 #000;
}

#pausedHud .pausedTitle {
  font-weight: 900;
  font-size: 28px;
  font-size: 6cqh;
}

#pausedHud .pausedHint {
  margin: 1.2cqh 0 3cqh;
  font-size: 13px;
  font-size: 2.4cqh;
  font-weight: 700;
  color: #ffe14a;
}

#pausedHud .volumeRow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-size: 2.6cqh;
  font-weight: 800;
  background: rgba(20, 14, 10, 0.85);
  border: 3px solid #000;
  border-radius: 10px;
  padding: 10px 14px;
}

#pausedHud .volumeRow input[type="range"] {
  width: 140px;
  accent-color: #73c02a;
  cursor: pointer;
}

#pausedHud #volumeValue {
  min-width: 3.2em;
  color: #ffe14a;
  text-align: right;
}

#pausedHud[hidden] { display: none; }

#fullResetHud {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 80, 40, 0.35), rgba(0, 0, 0, 0.55) 70%);
}

#fullResetHud[hidden] { display: none; }

.fullResetTitle {
  font-weight: 900;
  font-size: 42px;
  font-size: 9.2cqh;
  letter-spacing: 0.08em;
  color: #fff;
  text-align: center;
  text-shadow:
    0 0 18px #ff4ad2,
    0 0 28px #e07018,
    3px 3px 0 #000,
    -3px -3px 0 #000,
    3px -3px 0 #000,
    -3px 3px 0 #000;
  animation: fullResetSlam 0.55s cubic-bezier(0.12, 1.4, 0.3, 1) both;
}

@keyframes fullResetSlam {
  0% { transform: scale(0.15) rotate(-12deg); opacity: 0; }
  55% { transform: scale(1.18) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

#modeMenu {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 10%;
  bottom: 6%;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  text-align: center;
  overflow: auto;
}

#modeMenu[hidden] { display: none; }

.modeMenuBrand {
  font-weight: 900;
  font-size: 26px;
  font-size: 5.4cqh;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px #000, 2px 2px 0 #000, -1px -1px 0 #000;
}

.modeMenuCredit {
  margin: 1cqh 0 2.4cqh;
  font-size: 12px;
  font-size: 2.2cqh;
  font-weight: 700;
  color: #ffe14a;
  text-shadow: 0 0 4px #000, 1px 1px 0 #000;
}

.modeMenuBtn {
  width: 100%;
  max-width: 230px;
  margin: 0 0 1.2cqh;
  background: #73c02a;
  color: #fff;
  border: 3px solid #000;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 900;
  font-size: 14px;
  font-size: 2.8cqh;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 0 4px 0 #2a1c22;
}

.modeMenuBtn.streamer {
  background: #8750f5;
}

.modeMenuBtn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.modeMenuBtn.soon,
.modeMenuBtn:disabled {
  background: #3a3236;
  color: #8a8488;
  border-color: #4a4448;
  box-shadow: none;
  cursor: default;
  text-shadow: none;
}

.modeMenuBtn.soon span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-size: 1.8cqh;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a9498;
}

.modeMenuHint {
  width: 100%;
  max-width: 230px;
  margin: 0 0 1.2cqh;
  color: #f0dcc8;
  font-size: 11px;
  font-size: 2cqh;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 1px 1px 0 #000;
}

.modeMenuBtn.pass {
  display: block;
  box-sizing: border-box;
  background: #25F4EE;
  color: #081018;
  text-decoration: none;
  text-shadow: none;
}

.modeMenuBtn.pass[hidden] {
  display: none;
}

.modeMenuBtn.board {
  background: #e6b422;
  color: #1a1208;
  text-shadow: none;
}

#scoreboard {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 7%;
  bottom: 5%;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: rgba(16, 10, 12, 0.88);
  border: 3px solid #000;
  border-radius: 12px;
  padding: 8px 8px 6px;
  box-shadow: 0 6px 0 #2a1c22;
  z-index: 4;
}

#scoreboard[hidden] { display: none; }

.scoreboardHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.scoreboardTitle {
  font-weight: 900;
  font-size: 16px;
  font-size: 3.1cqh;
  letter-spacing: 0.08em;
  color: #ffe14a;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

#scoreboardClose {
  width: 32px;
  height: 32px;
  border: 3px solid #000;
  border-radius: 8px;
  background: #2a1c22;
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}

.scoreboardTabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.scoreboardTabs button {
  flex: 1;
  border: 3px solid #000;
  border-radius: 8px;
  padding: 6px 4px;
  background: #3a3236;
  color: #c8c0c4;
  font: inherit;
  font-weight: 800;
  font-size: 10px;
  font-size: 1.85cqh;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.scoreboardTabs button.on {
  background: #73c02a;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.scoreboardTabs button[data-board-mode="streamer"].on {
  background: #8750f5;
}

#scoreboardList {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scoreboardRow {
  display: grid;
  grid-template-columns: 2.4em 1fr 3.4em;
  gap: 4px;
  align-items: center;
  padding: 0.45cqh 0.35cqh;
  font-weight: 800;
  font-size: 11px;
  font-size: 2.05cqh;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.scoreboardRow span:last-child {
  text-align: right;
  color: #ffe14a;
}

.scoreboardRow.gold { color: #ffe14a; }
.scoreboardRow.silver { color: #e8e8e8; }
.scoreboardRow.bronze { color: #e0a070; }
.scoreboardRow.me {
  background: rgba(255, 225, 74, 0.16);
  border-radius: 4px;
}

#scoreboardEmpty {
  margin: 12px 4px 0;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  font-size: 2.2cqh;
  color: #c8c0c4;
  text-shadow: 1px 1px 0 #000;
}

#scoreboardEmpty[hidden] { display: none; }

#menuBtn {
  margin-top: 12px;
  background: #2a1c22;
  color: #f4e6c3;
  border: 3px solid #543847;
  border-radius: 8px;
  padding: 6px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

body:not(.play-streamer) #dock,
body:not(.play-streamer) #giftOverlayLayer,
body:not(.play-streamer) #likeGoalHud,
body:not(.play-streamer) #giftEditor,
body.play-solo #deadHud .countdown,
body.play-solo #deadHud .galaxyHint {
  display: none !important;
}

body.mode-title #worldRecordHud,
body.mode-title #playerHud,
body.mode-title #scoreHud {
  display: none;
}

#dock {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  width: 300px;
  background: rgba(20, 14, 10, 0.92);
  color: #f4e6c3;
  border: 3px solid #543847;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 0 #2a1c22;
}

#dock.hidden,
body.overlay #dock,
body:not(.overlay):not(.logged-in) #dock {
  display: none;
}

#dock h1 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: #f8e14a;
}

.dockToggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

#dock .dockToggle {
  margin: 0;
  flex: 1;
  background: #2a1c22;
  color: #c8b48a;
  border: 2px solid #543847;
  border-radius: 8px;
  padding: 8px 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  line-height: 1.2;
}

#dock .dockToggle.on {
  background: #73c02a;
  color: #fff;
  border-color: #000;
}

.dockToggleHint {
  margin: 0 0 10px;
}

#pilotMode,
#autoStartMode {
  margin: 0;
}

#dock label {
  display: block;
  font-size: 11px;
  margin-bottom: 6px;
}

#dock input {
  width: 100%;
  box-sizing: border-box;
  background: #2a1c22;
  color: #f4e6c3;
  border: 2px solid #543847;
  padding: 6px 8px;
  font: inherit;
}

#dock .row {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}

#dock button {
  flex: 1;
  background: #73c02a;
  color: #fff;
  border: 2px solid #543847;
  padding: 6px 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#dock button.ghost {
  background: #8a6a3a;
}

#dock button:disabled {
  opacity: 0.45;
  cursor: default;
}

#status {
  font-size: 11px;
  min-height: 2.4em;
  color: #c8b48a;
}

#status.connected { color: #9ae04a; }
#status.error { color: #e07018; }

#adminUnlock {
  margin-top: 8px;
}

#adminUnlock button {
  width: 100%;
  background: #8a6a3a;
}

#adminError {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 700;
  color: #e07018;
}

#adminError[hidden],
#adminUnlock[hidden],
.debug[hidden] {
  display: none;
}

.debug {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
}

.debugTroll {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(84, 56, 71, 0.6);
}

.debugTroll p {
  margin: 0;
  font-size: 10px;
  line-height: 1.3;
  color: #f0dcc8;
}

.debugTroll label {
  margin: 0;
  font-size: 10px;
}

.debugTroll select {
  width: 100%;
  margin-top: 2px;
  background: #1a1014;
  color: #f0dcc8;
  border: 2px solid #543847;
  border-radius: 4px;
  padding: 4px;
  font-size: 11px;
}

#trollRefreshBtn {
  background: #8a6a3a;
}

.debug button {
  background: #4ec0ca;
  font-size: 10px;
  padding: 4px;
}

#wipeRecordBtn {
  grid-column: 1 / -1;
  background: #c44b2b;
}

#adminLockBtn {
  grid-column: 1 / -1;
  background: #8a6a3a;
}

#giftEditorBtn {
  width: 100%;
  margin: 8px 0 0;
  background: #8750f5;
  color: #fff;
  border: 2px solid #543847;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.hint {
  margin: 8px 0 0;
  font-size: 10px;
  color: #8a7a62;
}

#giftOverlayLayer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  --gift-scale: 1.85;
}

#giftOverlayLayer[hidden] { display: none; }

body:not(.overlay):not(.logged-in) #giftOverlayLayer {
  display: none !important;
}

.giftPanel {
  position: absolute;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: calc(8px * var(--gift-scale));
  width: max-content;
  min-width: calc(32px * var(--gift-scale));
  max-width: 46%;
  padding: 0;
  background: none;
  border: none;
  pointer-events: none;
  overflow: visible;
}

.giftPanel.show { display: flex; }

body:not(.overlay).giftDragging .giftPanel.show {
  pointer-events: auto;
  cursor: grab;
}

body:not(.overlay).giftDragging .giftPanel.show:active {
  cursor: grabbing;
}

.giftPanelItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  overflow: visible;
  gap: 1px;
  color: #fff;
  font-weight: 900;
  font-size: calc(13px * var(--gift-scale));
  line-height: 1.1;
  letter-spacing: 0.02em;
  paint-order: stroke fill;
  -webkit-text-stroke: 1.4px #000;
  text-shadow:
    0 0 6px #000,
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 2px 0 #000,
    0 -2px 0 #000,
    2px 0 0 #000,
    -2px 0 0 #000;
}

.giftPanelText {
  color: #fff;
  display: block;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  width: 100%;
  margin: 0 auto;
  line-height: 1.05;
}

.giftPanelItem img,
.giftPanelItem .giftPh {
  width: calc(32px * var(--gift-scale));
  height: calc(32px * var(--gift-scale));
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px #000);
}

.giftPh {
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 6px;
  font-size: 16px;
}

#giftEditor[hidden] { display: none; }

#giftEditor {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color-scheme: dark;
  cursor: pointer;
}

#giftEditor input,
#giftEditor select {
  color: #fff;
  -webkit-text-fill-color: #fff;
  caret-color: #ffe14a;
  user-select: text;
  -webkit-user-select: text;
}

.giftEditorCard {
  width: min(1120px, 100%);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #141218;
  color: #f4e6c3;
  border: 2px solid #3d3344;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  cursor: default;
}

.giftEditorCard header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #2a2230;
}

.giftEditorCard h2 {
  margin: 0;
  color: #ffe14a;
  font-size: 18px;
}

.giftEditorCard header p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #8a7a62;
}

.giftEditorHeadActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#giftEditorClose {
  background: #2a1c22;
  color: #f4e6c3;
  border: 2px solid #543847;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-weight: 900;
  cursor: pointer;
}

#giftEditorClose:hover {
  background: #8a6a3a;
  color: #fff;
  border-color: #000;
}

.giftEditorTopBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  flex-shrink: 0;
  padding: 10px 18px;
  border-bottom: 1px solid #2a2230;
  background: #100e14;
}

.giftEditorTopBar .hint {
  margin: 0;
  font-size: 11px;
}

.giftPaneHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.giftPaneHeadTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.giftPaneHeadTitle h3 { margin: 0; }

#loadDefaultGifts {
  background: #2a1c22;
  color: #f4e6c3;
  border: 2px solid #543847;
  border-radius: 6px;
  padding: 4px 8px;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

#loadDefaultGifts:hover {
  background: #3a2a30;
  color: #ffe14a;
}

.giftPaneHead .giftToggle {
  font-size: 11px;
  color: #f4e6c3;
  white-space: nowrap;
}

.giftEditorToolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.giftEditorToolbar input {
  flex: 1;
  min-width: 0;
  background: #140e0c;
  color: #ffe14a;
  border: 2px solid #543847;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

#giftSyncBtn {
  background: #73c02a;
  color: #fff;
  border: 2px solid #000;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

#giftCatalogPill, #giftSaveStatus {
  font-size: 12px;
  font-weight: 800;
  color: #9ae04a;
}

#giftSaveStatus.busy { color: #ffe14a; }
#giftSaveStatus.err { color: #e07018; }

.giftEditorBody {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(360px, 1.15fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 12px 16px 16px;
}

@media (max-width: 760px) {
  .giftEditorCard { height: min(920px, 96vh); }
  .giftEditorBody { grid-template-columns: 1fr; }
  .giftMapFields,
  .giftMapRow:not(.needsAmount) .giftMapFields {
    grid-template-columns: 1fr;
  }
}

.giftCatalogPane, .giftMapPane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0c0c10;
  border: 1px solid #2a2230;
  border-radius: 12px;
  padding: 12px;
}

.giftEditorBody h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c8b48a;
}

#giftCatalogGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  flex: 1;
  min-height: 140px;
  overflow: auto;
  padding: 2px;
}

.giftCatItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #15151c;
  border: 2px solid #2a2230;
  border-radius: 8px;
  padding: 8px 4px 6px;
  cursor: pointer;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.giftCatItem:hover, .giftCatItem.on {
  border-color: #8750f5;
}

.giftCatItem img, .giftCatItem .giftPh {
  width: 36px;
  height: 36px;
}

.giftCatName {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.15;
  max-width: 100%;
}

.giftCatCoins {
  color: #ffe14a;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.giftManualRow {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
}

.giftManualRow input {
  flex: 1;
  background: #140e0c;
  color: #fff;
  border: 2px solid #543847;
  border-radius: 6px;
  padding: 6px;
  font: inherit;
}

.giftEditorTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.giftEditorTabs button {
  background: #2a1c22;
  color: #c8b48a;
  border: 2px solid #543847;
  border-radius: 6px;
  padding: 6px;
  font-weight: 800;
  cursor: pointer;
}

.giftEditorTabs button.on {
  background: #73c02a;
  color: #fff;
  border-color: #000;
}

#giftMapList {
  flex: 1;
  min-height: 240px;
  overflow: auto;
  padding-right: 2px;
}

.giftMapRow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #15151c;
  border: 1px solid #2a2230;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.giftMapRow:last-child {
  margin-bottom: 0;
}

.giftMapHead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.giftMapHead .giftMapName {
  flex: 1 1 110px;
  min-width: 90px;
  background: #0b0908;
  color: #fff;
  -webkit-text-fill-color: #fff;
  caret-color: #ffe14a;
  border: 2px solid #8750f5;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
}

.giftMapMeta {
  font-size: 11px;
  font-weight: 800;
  color: #c4b48a;
  white-space: nowrap;
}

.giftMapFields {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(72px, 0.7fr);
  gap: 8px;
  align-items: end;
}

.giftMapRow img, .giftMapRow .giftPh {
  width: 36px;
  height: 36px;
}

.giftMapRow select, .giftMapRow input[type="text"], .giftMapRow input[type="number"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #140e0c;
  color: #fff;
  border: 2px solid #543847;
  border-radius: 6px;
  padding: 7px 8px;
  font: inherit;
  font-weight: 800;
}

.giftMapRow:not(.needsAmount) .giftAmountField {
  display: none;
}

.giftMapRow:not(.needsAmount) .giftMapFields {
  grid-template-columns: 1fr;
}

.giftTextField {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c4b48a;
}

.giftTextField input[type="text"],
.giftTextField input[type="number"],
.giftTextField select {
  width: 100%;
  min-width: 0;
  background: #0b0908;
  color: #fff;
  -webkit-text-fill-color: #fff;
  caret-color: #ffe14a;
  border: 2px solid #8750f5;
  font-size: 13px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
  padding: 7px 8px;
}

.giftTextField input:focus,
.giftTextField select:focus {
  outline: none;
  border-color: #b8ff64;
}

.deathTitleField {
  margin-top: 10px;
}

.deathSlots {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #2a2230;
  flex-shrink: 0;
}

.deathSlots h3 {
  margin-bottom: 4px;
}

.deathSlots .hint {
  margin: 0 0 8px;
}

.deathSlot {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  background: #15151c;
  border: 2px solid #2a2230;
  border-radius: 10px;
  padding: 8px;
}

.deathSlotBody {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.deathSlot.picking {
  border-color: #ffe14a;
  box-shadow: 0 0 0 1px #ffe14a;
}

.deathSlot strong {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffe14a;
}

.deathSlotPreview {
  display: grid;
  place-items: center;
  min-height: 64px;
  height: 64px;
  background: #0b0908;
  border-radius: 8px;
}

.deathSlotPreview img,
.deathSlotPreview .giftPh {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.deathSlotPreview .empty {
  font-size: 11px;
  color: #8a7a62;
}

.deathSlotBtns {
  display: flex;
  gap: 6px;
}

.deathSlotBtns button {
  flex: 1;
  background: #8750f5;
  color: #fff;
  border: 2px solid #000;
  border-radius: 6px;
  padding: 6px 8px;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
}

.deathSlotBtns .ghostSlot {
  background: #2a1c22;
  color: #c8b48a;
  border-color: #543847;
}

body.giftPicking #giftCatalogGrid,
body.giftReplacing #giftCatalogGrid {
  outline: 2px dashed #ffe14a;
  outline-offset: 4px;
  border-radius: 8px;
}

.giftCatItem.pick {
  box-shadow: 0 0 0 2px #ffe14a;
}

.giftMapRow.replacing {
  border-color: #ffe14a;
  box-shadow: 0 0 0 1px #ffe14a;
}

.giftMapRow.off {
  opacity: 0.48;
}

.giftMapRow .giftOnOff {
  background: #73c02a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 8px;
  font-weight: 900;
  cursor: pointer;
  min-width: 42px;
}

.giftMapRow .giftEditBtn {
  background: #8750f5;
  color: #fff;
  border: 2px solid #000;
  border-radius: 6px;
  padding: 5px 8px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.giftMapRow .giftEditBtn.on {
  background: #ffe14a;
  color: #000;
}

.giftMapRow .giftOnOff.off {
  background: #543847;
  color: #c8b48a;
}

.giftMapSettings {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
}

.likeGoalEditor {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px;
  border: 1px solid #2a2230;
  border-radius: 12px;
  background: #0c0c10;
  flex-shrink: 0;
}

.likeGoalEditor h3 { margin-bottom: 4px; }

.likeGoalEditor .hint { margin: 0 0 8px; }

.likeGoalFields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.likeGoalFields label,
.likeGoalEditorFoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.likeGoalFields input,
.likeGoalFields select {
  width: 100%;
  max-width: 220px;
  background: #101018;
  color: #fff;
  border: 2px solid #2a2230;
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 800;
}

.likeGoalEditorFoot { margin-top: 8px; }

.likeGoalEditorFoot .hint { margin: 0; }

.giftToggle, .giftScaleRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

.giftScaleRow input { flex: 1; }
