/* Blockmas: chunky grey buttons, dirt menu backgrounds, pixel text with a hard shadow. */
@font-face {
  font-family: "Blockmas Pixel";
  src: url("/christmas/fonts/blockmas-pixel.woff2") format("woff2");
  font-display: block;
}

:root {
  --text: #ffffff;
  --shadow: #3f3f3f;
  --muted: #a0a0a0;
  --yellow: #ffff55;
  --green: #55ff55;
  --red: #ff5555;
  --aqua: #55ffff;
  --tile-dirt: none;
  --tile-stone: none;
  --tile-snow: none;
  --ui-scale: 2;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b2433;
  color: var(--text);
  font-family: "Blockmas Pixel", "Lucida Console", Monaco, monospace;
  font-size: 20px;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
  image-rendering: pixelated;
}

#game {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#game canvas {
  width: 100%;
  height: 100%;
  outline: none;
  -webkit-touch-callout: none;
  display: block;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 2px 2px 0 var(--shadow);
}

#ui > * {
  pointer-events: auto;
}

#ui .passive,
#ui .hud {
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- dirt screens */

.dirt-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2b2420;
  background-image: var(--tile-dirt);
  background-size: 64px 64px;
  image-rendering: pixelated;
  z-index: 50;
  text-shadow: 2px 2px 0 var(--shadow);
}

.dirt-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.dirt-screen > * {
  position: relative;
}

.boot-box {
  width: min(560px, calc(100vw - 32px));
  text-align: center;
  line-height: 1.5;
}

.boot-title {
  font-size: 40px;
  
  
  margin-bottom: 18px;
  color: #ffffff;
}

.bar {
  margin: 14px auto 0;
  width: 220px;
  height: 6px;
  background: #808080;
  border: 0;
}

.bar > div {
  height: 100%;
  width: 0;
  background: #80ff80;
  transition: width 0.2s;
}

/* ---------------------------------------------------------------- buttons */

.mc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 200px;
  min-height: 40px;
  padding: 6px 14px;
  margin: 4px;
  color: #e6e6e6;
  text-align: center;
  text-decoration: none;
  font: inherit;
  font-size: 20px;
  line-height: 24px;
  text-shadow: 2px 2px 0 #262626;
  background-color: #747474;
  background-image: linear-gradient(rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.12)), var(--tile-stone);
  background-size: auto, 48px 48px;
  border: 2px solid #000000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.42), inset -2px -4px 0 rgba(0, 0, 0, 0.38);
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  image-rendering: pixelated;
  transition: filter 0.08s ease;
}

.mc-button:hover,
.mc-button:focus-visible {
  color: #ffffa0;
  background-color: #7d88cc;
  background-image: linear-gradient(rgba(115, 136, 255, 0.46), rgba(80, 102, 224, 0.5)), var(--tile-stone);
  box-shadow: inset 2px 2px 0 rgba(205, 215, 255, 0.55), inset -2px -4px 0 rgba(35, 45, 110, 0.48);
  outline: none;
}

.mc-button:active:not([disabled]):not(.disabled) {
  transform: translateY(1px);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.25);
}

.mc-button[disabled],
.mc-button.disabled {
  color: #a0a0a0;
  background: #2c2c2c;
  box-shadow: none;
  cursor: default;
}

.mc-button.wide {
  width: 400px;
  max-width: calc(100vw - 32px);
}

.mc-button.half {
  width: 196px;
  min-width: 0;
}

.mc-button.danger:hover {
  color: var(--red);
}

.button-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
}

.mc-input {
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 40px;
  padding: 0 10px;
  font: inherit;
  font-size: 20px;
  color: #e0e0e0;
  background: #000000;
  border: 2px solid #a0a0a0;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.mc-input:focus {
  border-color: #ffffff;
}

input[type="range"].mc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 196px;
  height: 40px;
  margin: 4px;
  background: #000000;
  border: 2px solid #000000;
  box-shadow: inset 0 0 0 2px #2c2c2c;
  cursor: pointer;
}

input[type="range"].mc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 36px;
  background: #8b8b8b;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #c6c6c6, inset -2px -2px 0 #555;
}

input[type="range"].mc-slider::-moz-range-thumb {
  width: 12px;
  height: 32px;
  background: #8b8b8b;
  border: 2px solid #000;
  border-radius: 0;
}

.slider-wrap {
  position: relative;
  display: inline-block;
}

.slider-wrap span {
  position: absolute;
  inset: 0;
  line-height: 48px;
  text-align: center;
  pointer-events: none;
  color: #e0e0e0;
}

/* ---------------------------------------------------------------- title screen */

.title-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px 56px;
  background: radial-gradient(ellipse at center, rgba(10, 18, 34, 0.12) 25%, rgba(6, 12, 24, 0.62) 100%);
  z-index: 20;
}

.logo-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 36px;
  max-width: calc(100vw - 32px);
}

.logo-wrap canvas {
  display: block;
  width: clamp(300px, 56vw, 660px);
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.splash {
  position: absolute;
  right: -12px;
  bottom: -6px;
  color: var(--yellow);
  font-size: clamp(16px, 2vw, 22px);
  text-shadow: 2px 2px 0 #3f3f00;
  transform: rotate(-16deg);
  transform-origin: center;
  animation: splash 0.55s ease-in-out infinite alternate;
  white-space: nowrap;
  pointer-events: none;
}

@keyframes splash {
  from {
    transform: rotate(-16deg) scale(0.94);
  }
  to {
    transform: rotate(-16deg) scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash {
    animation: none;
  }
}

.title-buttons {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(400px, calc(100vw - 32px));
}

.title-buttons .mc-button {
  margin: 0;
}

.title-buttons .mc-button.wide {
  width: 100%;
  max-width: 100%;
}

.title-buttons .button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.title-buttons .mc-button.half {
  width: 100%;
  min-width: 0;
}

.title-note {
  margin: 8px 0 0;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.52);
  border: 2px solid rgba(255, 255, 255, 0.14);
  color: #e4e8f0;
  font-size: 16px;
  line-height: 1.35;
  text-align: center;
}

.corner {
  position: fixed;
  bottom: 8px;
  font-size: 16px;
  color: #f0f4ff;
  text-shadow: 2px 2px 0 #1e1e26;
}

.corner.left {
  left: 12px;
}

.corner.right {
  right: 12px;
  text-align: right;
}

.corner a {
  color: #ffff80;
  text-decoration: none;
}

.corner a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------- menus */

.menu {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  background: rgba(16, 16, 16, 0.6);
  z-index: 30;
  overflow-y: auto;
  padding: 24px 16px;
}

.menu.dirt {
  background-color: #2b2420;
  background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), var(--tile-dirt);
  background-size: auto, 64px 64px;
}

.menu h2 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 400;
  text-align: center;
}

.menu p {
  max-width: 520px;
  text-align: center;
  line-height: 1.45;
  margin: 6px 0 14px;
}

.menu .section-label {
  color: var(--muted);
  font-size: 20px;
  margin: 12px 0 2px;
}

.menu .spacer {
  height: 16px;
}

/* Redesigned translucent grey Pause Menu (no dirt texture) */
.pause-shell {
  background: rgba(20, 22, 28, 0.56);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  align-items: center;
  justify-content: safe center;
  padding: 20px 16px;
}

.pause-card {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: rgba(26, 28, 34, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.pause-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(12, 14, 18, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.pause-header h2 {
  margin: 0;
  font-size: 24px;
  color: #ffffff;
  text-align: left;
  letter-spacing: 0.5px;
}

.pause-header-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #d4dae6;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.status-dot {
  width: 9px;
  height: 9px;
  background: #ff5555;
  box-shadow: 0 0 0 1px #000;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.on {
  background: #55ff55;
}

.pause-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  min-height: 0;
  flex: 1;
}

.pause-left {
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px;
  gap: 12px;
  overflow-y: auto;
  border-right: 2px solid rgba(255, 255, 255, 0.12);
}

.pause-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
}

.pause-tab-btn.mc-button {
  min-width: 0;
  min-height: 34px;
  padding: 4px 12px;
  margin: 0;
  font-size: 16px;
  line-height: 20px;
  flex: 1 1 auto;
}

.pause-tab-btn.mc-button.active {
  color: #ffff80;
  background-color: #6b76b8;
  background-image: linear-gradient(rgba(115, 136, 255, 0.44), rgba(75, 96, 210, 0.5)), var(--tile-stone);
  box-shadow: inset 2px 2px 0 rgba(215, 224, 255, 0.55), inset -2px -3px 0 rgba(30, 40, 100, 0.5);
}

.pause-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pause-body .mc-button {
  margin: 0;
}

.pause-body .mc-button.wide {
  width: 100%;
  max-width: 100%;
}

.pause-body .mc-button.primary {
  background-color: #5b825b;
  background-image: linear-gradient(rgba(90, 175, 95, 0.34), rgba(45, 105, 50, 0.42)), var(--tile-stone);
  color: #ffffff;
}

.pause-body .mc-button.primary:hover {
  color: #ffffa0;
  background-color: #679c67;
}

.pause-grid,
.pause-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.pause-bottom-row {
  padding-top: 6px;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.pause-grid .mc-button.half,
.pause-bottom-row .mc-button.half {
  width: 100%;
  min-width: 0;
  font-size: 17px;
}

.pause-callout {
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.38);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.pause-callout-title {
  color: var(--yellow);
  font-size: 18px;
  line-height: 1.3;
}

.pause-callout-sub {
  color: #cfd6e3;
  font-size: 15px;
  margin-top: 3px;
}

.pause-subnote {
  margin: 2px 0 4px;
  color: #c8d0de;
  font-size: 15px;
  text-align: left !important;
  max-width: none !important;
  line-height: 1.35;
}

.pause-stats {
  padding: 14px 16px;
  background: rgba(12, 14, 18, 0.44);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.stat-group {
  background: rgba(0, 0, 0, 0.32);
  border: 2px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
}

.stat-group-title {
  color: var(--yellow);
  font-size: 15px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  line-height: 1.42;
}

.stat-k {
  color: #9aa3b5;
  flex-shrink: 0;
}

.stat-v {
  color: #f0f4fc;
  text-align: right;
  overflow-wrap: anywhere;
}

.stat-v.good {
  color: var(--green);
}

.stat-v.warn {
  color: var(--yellow);
}

.stat-v.bad {
  color: var(--red);
}

.options-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.menu > .options-panel {
  max-width: 460px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.settings-group-title {
  color: var(--yellow);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.options-card {
  width: min(560px, calc(100vw - 32px));
}

.options-card-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px;
  min-height: 0;
  overflow-y: auto;
}

.options-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.options-card-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

.options-card-footer .mc-button {
  margin: 0;
}

.options-card-footer .mc-button.wide {
  width: 100%;
  max-width: 100%;
}

.options-panel .button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.options-panel .mc-button.wide {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
}

.options-panel .mc-button.half,
.options-panel .slider-wrap,
.options-panel input[type="range"].mc-slider {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.options-panel .mc-button.half,
.options-panel .mc-button.wide {
  font-size: 17px;
}

.options-panel .slider-wrap span {
  line-height: 40px;
  font-size: 17px;
}

.mc-button.active-toggle {
  color: #a8ffa8;
}

@media (max-width: 780px) {
  .pause-columns {
    grid-template-columns: 1fr;
  }

  .pause-left {
    border-right: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  }

  .pause-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.credits {
  max-width: 620px;
  line-height: 1.5;
  text-align: left;
}

.credits h3 {
  color: var(--yellow);
  font-size: 20px;
  font-weight: 400;
  margin: 16px 0 4px;
}

.credits a {
  color: var(--aqua);
}

.controls-table {
  border-collapse: collapse;
  margin-bottom: 16px;
}

.controls-table td {
  padding: 3px 12px;
}

.controls-table td:first-child {
  color: var(--yellow);
  text-align: right;
}

/* ---------------------------------------------------------------- HUD */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  mix-blend-mode: difference;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: #ffffff;
}

.crosshair::before {
  left: 9px;
  top: 0;
  width: 2px;
  height: 20px;
}

.crosshair::after {
  top: 9px;
  left: 0;
  height: 2px;
  width: 20px;
}

.hotbar {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  padding: 2px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 2px #8b8b8b;
}

.hotbar-more {
  width: 44px;
  height: 44px;
  margin: 2px;
  padding: 0;
  border: none;
  background: rgba(139, 139, 139, 0.45);
  box-shadow: inset 2px 2px 0 rgba(55, 55, 55, 0.9), inset -2px -2px 0 rgba(255, 255, 255, 0.35);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #3f3f3f;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hotbar-more:active {
  background: rgba(255, 255, 255, 0.28);
}

.slot {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 2px;
  background: rgba(139, 139, 139, 0.35);
  box-shadow: inset 2px 2px 0 rgba(55, 55, 55, 0.9), inset -2px -2px 0 rgba(255, 255, 255, 0.35);
}

.slot img {
  position: absolute;
  inset: 4px;
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.slot .key {
  position: absolute;
  right: 3px;
  bottom: 0;
  font-size: 10px;
  color: #d0d0d0;
}

.slot.selected {
  outline: 4px solid #ffffff;
  outline-offset: 0;
  z-index: 1;
  box-shadow: inset 0 0 0 2px #000;
}

.animal-hint {
  position: absolute;
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.58);
  border: 2px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 18px;
  white-space: nowrap;
  pointer-events: none;
}

.held-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 70px;
  text-align: center;
  font-size: 20px;
  transition: opacity 0.6s;
}

.held-name.special {
  color: var(--yellow);
}

.held-note {
  display: block;
  font-size: 20px;
  color: var(--muted);
}

.messages {
  position: absolute;
  left: 8px;
  bottom: 80px;
  width: min(560px, calc(100vw - 16px));
  font-size: 20px;
}

.message {
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.45);
  transition: opacity 1s;
}

.message.error {
  color: var(--red);
}

.message.good {
  color: var(--green);
}

.message.info {
  color: var(--yellow);
}

.plot-info {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 20px;
}

.plot-info small {
  display: block;
  font-size: 20px;
  color: var(--muted);
}

.plot-info .hint {
  color: var(--yellow);
}

.status {
  position: absolute;
  top: 8px;
  right: 10px;
  text-align: right;
  font-size: 20px;
  line-height: 1.4;
}

.status .offline {
  color: var(--red);
}

.debug {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 18px;
  line-height: 1.32;
}

.debug div {
  display: table;
  background: rgba(24, 28, 36, 0.58);
  padding: 1px 6px;
  margin-bottom: 1px;
}

.fps-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 9px;
  background: rgba(18, 22, 30, 0.64);
  border: 2px solid rgba(255, 255, 255, 0.16);
  font-size: 16px;
  color: #d6ffcf;
  line-height: 1.2;
}

.click-to-play {
  position: fixed;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  font: inherit;
  font-size: 20px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  z-index: 28;
  pointer-events: auto;
  cursor: pointer;
}

.click-to-play:hover,
.click-to-play:focus-visible {
  color: #ffffa0;
  outline: none;
  border-color: rgba(255, 255, 160, 0.7);
}

.fs-hint {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 28;
  margin: 0;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.28);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fs-hint:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 160, 0.7);
}

/* ---------------------------------------------------------------- inventory */

/* ---------------------------------------------------------------- creative inventory (Minecraft style) */

.mc-creative-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 472px;
  max-width: calc(100vw - 16px);
  color: #404040;
  text-shadow: none;
}

.mc-tabs {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 0 2px;
  position: relative;
  z-index: 1;
}

.mc-tabs-top {
  margin-bottom: -4px;
}

.mc-tabs-bottom {
  align-items: flex-start;
  margin-top: -4px;
}

.mc-tab {
  position: relative;
  width: 56px;
  height: 52px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #8b8b8b;
  border: 2px solid #000000;
  box-shadow: inset 3px 3px 0 #b8b8b8, inset -3px -3px 0 #555555;
  cursor: pointer;
  color: #404040;
  font: inherit;
  z-index: 1;
}

.mc-tab.top {
  border-bottom-color: #000000;
  padding-bottom: 2px;
}

.mc-tab.bottom {
  border-top-color: #000000;
  padding-top: 2px;
}

.mc-tab.right {
  margin-left: auto;
}

.mc-tab:hover:not(.active) {
  background: #a4a4a4;
}

.mc-tab.active {
  background: #c6c6c6;
  z-index: 4;
}

.mc-tab.top.active {
  height: 56px;
  border-bottom: 0;
  box-shadow: inset 4px 4px 0 #ffffff, inset -4px 0 0 #555555;
}

.mc-tab.bottom.active {
  height: 56px;
  border-top: 0;
  box-shadow: inset 4px 0 0 #ffffff, inset -4px -4px 0 #555555;
}

.mc-tab img {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
  pointer-events: none;
}

.mc-search-glyph {
  font-size: 30px;
  line-height: 1;
  color: #3f3f3f;
  pointer-events: none;
}

.mc-creative-panel {
  position: relative;
  z-index: 2;
  background: #c6c6c6;
  border: 2px solid #000000;
  box-shadow: inset 4px 4px 0 #ffffff, inset -4px -4px 0 #555555;
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-inv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}

.mc-inv-title {
  font-size: 20px;
  color: #404040;
  text-shadow: none;
  line-height: 1.1;
}

.mc-inv-search {
  width: 210px;
  height: 28px;
  padding: 0 7px;
  font: inherit;
  font-size: 18px;
  color: #ffffff;
  background: #000000;
  border: 2px solid #a0a0a0;
  box-shadow: inset 2px 2px 0 #262626;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.mc-inv-search:focus {
  border-color: #ffffff;
}

.mc-inv-body {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.mc-grid {
  display: grid;
  grid-template-columns: repeat(9, 44px);
  grid-template-rows: repeat(5, 44px);
  gap: 0;
}

.mc-slot {
  position: relative;
  width: 44px;
  height: 44px;
  background: #8b8b8b;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mc-slot.empty {
  cursor: default;
}

.mc-slot:not(.empty):hover {
  background: #b0b0c8;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #ffffff, inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.mc-slot img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  pointer-events: none;
}

.mc-slot-key {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 13px;
  color: #e8e8e8;
  text-shadow: 1px 1px 0 #222;
  pointer-events: none;
}

.mc-scroll-track {
  position: relative;
  width: 32px;
  background: #8b8b8b;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #ffffff;
  cursor: pointer;
  flex-shrink: 0;
}

.mc-scroll-thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  height: 36px;
  background: #c6c6c6;
  border: 2px solid #000000;
  box-shadow: inset 2px 2px 0 #ffffff, inset -2px -2px 0 #555555;
  cursor: grab;
}

.mc-scroll-thumb::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    to bottom,
    #6b6b6b 0px,
    #6b6b6b 2px,
    transparent 2px,
    transparent 4px
  );
}

.mc-scroll-thumb.disabled {
  background: #9a9a9a;
  opacity: 0.55;
  cursor: default;
}

.mc-hotbar-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding-top: 6px;
  border-top: 2px solid #9e9e9e;
}

.mc-hotbar-row .mc-slot.selected {
  outline: 3px solid #ffffff;
  outline-offset: -1px;
  z-index: 2;
}

.mc-hotbar-row .mc-slot.empty-hotbar {
  background: #7c7c7c;
}

.mc-hotbar-row.carrying .mc-hotbar-slot:hover {
  background: #b8c2a8;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #ffffff, inset 0 0 0 2px #ffff70;
}

.mc-hotbar-row .mc-trash {
  margin-left: 10px;
  width: 32px;
  background: #a46868;
  box-shadow: inset 2px 2px 0 #4a2424, inset -2px -2px 0 #e6b8b8;
}

.mc-hotbar-row .mc-trash:hover {
  background: #c45858;
}

.mc-trash-icon {
  color: #ffffff;
  font-size: 22px;
  text-shadow: 2px 2px 0 #3f1515;
  pointer-events: none;
}

.mc-inv-foot {
  font-size: 14px;
  color: #555555;
  line-height: 1.2;
}

#ui .inv-cursor,
.inv-cursor {
  position: fixed;
  z-index: 80;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  pointer-events: none !important;
}

.inv-cursor img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.45));
}

.inventory {
  width: min(760px, calc(100vw - 16px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: #c6c6c6;
  border: 2px solid #000;
  box-shadow: inset 4px 4px 0 #ffffff, inset -4px -4px 0 #555555;
  padding: 12px 14px 14px;
  color: #3f3f3f;
  text-shadow: none;
}

.inventory .inv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.inventory .inv-title {
  font-size: 20px;
  flex: 1;
}

.inventory input {
  width: 220px;
  height: 30px;
  font: inherit;
  font-size: 20px;
  padding: 0 6px;
  background: #000;
  color: #fff;
  border: 2px solid #a0a0a0;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 8px;
}

.tab {
  padding: 4px 8px;
  font: inherit;
  font-size: 20px;
  color: #3f3f3f;
  background: #a8a8a8;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #dcdcdc, inset -2px -2px 0 #6a6a6a;
  cursor: pointer;
}

.tab.active {
  background: #c6c6c6;
  color: #000;
  box-shadow: inset 2px 2px 0 #ffffff, inset -2px -2px 0 #8b8b8b;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 44px);
  gap: 2px;
  overflow-y: auto;
  padding: 2px;
  min-height: 140px;
  max-height: 46vh;
}

.grid .slot,
.inv-hotbar .slot {
  background: #8b8b8b;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #ffffff;
  cursor: pointer;
  margin: 0;
}

.grid .slot:hover,
.inv-hotbar .slot:hover {
  background: #c5c5f0;
}

.inv-hotbar {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  padding: 2px;
}

.inv-hotbar .slot.selected {
  outline: 3px solid #ffffff;
}

.inv-help {
  margin-top: 8px;
  font-size: 20px;
  color: #555;
}

#ui .tooltip,
.tooltip {
  position: fixed;
  z-index: 60;
  padding: 4px 8px;
  background: rgba(16, 0, 16, 0.94);
  border: 2px solid #28007f;
  outline: 2px solid #100010;
  color: #ffffff;
  font-size: 20px;
  pointer-events: none !important;
  text-shadow: 2px 2px 0 var(--shadow);
  max-width: 280px;
}

.tooltip .cat {
  display: block;
  color: #5555ff;
  font-size: 20px;
}

.tooltip .note {
  display: block;
  color: var(--yellow);
  font-size: 20px;
}

@media (max-width: 640px) {
  .slot {
    width: 34px;
    height: 34px;
  }
  .slot img {
    inset: 3px;
    width: 28px;
    height: 28px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, 34px);
  }
  .mc-button.half {
    width: calc(50vw - 24px);
  }
  .title-buttons .mc-button.half {
    width: 100%;
  }
  .splash {
    right: 4px;
    bottom: -14px;
    font-size: 16px;
  }
  .mc-creative-wrap {
    width: calc(100vw - 12px);
  }
  .mc-creative-panel {
    padding: 8px 10px;
  }
  .mc-grid {
    grid-template-columns: repeat(9, 34px);
    grid-template-rows: repeat(5, 34px);
  }
  .mc-slot {
    width: 34px;
    height: 34px;
  }
  .mc-slot img {
    width: 28px;
    height: 28px;
  }
  .mc-tab {
    width: 44px;
    height: 42px;
  }
  .mc-tab.top.active,
  .mc-tab.bottom.active {
    height: 46px;
  }
  .mc-tab img {
    width: 26px;
    height: 26px;
  }
  .mc-scroll-track,
  .mc-hotbar-row .mc-trash {
    width: 24px;
  }
  .corner.left {
    display: none;
  }
}

/* ---------------------------------------------------------------- chat */

.messages {
  z-index: 12;
}

.messages.open .message {
  opacity: 1 !important;
}

.message.chat .who {
  color: #ffffff;
}

.message.chat.guest .who {
  color: #a0a0a0;
}

.message.chat.admin .who {
  color: var(--yellow);
}

.chat-input {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 40;
  height: 36px;
  padding: 0 8px;
  font: inherit;
  font-size: 20px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.6);
  border: 0;
  outline: none;
  text-shadow: 2px 2px 0 var(--shadow);
  user-select: text;
  -webkit-user-select: text;
}

.chat-input::placeholder {
  color: #808080;
}

/* ---------------------------------------------------------------- rules and reports */

.rules {
  max-width: 640px;
  line-height: 1.5;
}

.rule {
  margin: 0 0 10px;
}

.rule b {
  color: var(--yellow);
  font-weight: 400;
}

.rules-note {
  color: #c0c0c0;
}

.report-list {
  width: min(640px, 100%);
  margin-bottom: 12px;
}

.report {
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #000;
}

.report b {
  color: var(--yellow);
  font-weight: 400;
}

.report-reasons {
  color: #c0c0c0;
}

.reports-badge {
  color: var(--red);
}

/* ---------------------------------------------------------------- small screens */

/* When a menu is taller than the window, the auto margins keep it centred
   when it fits and let it scroll from the top when it doesn't. */
.menu > :first-child,
.title-screen > :first-child {
  margin-top: auto;
}

.menu > :last-child,
.title-screen > .title-buttons {
  margin-bottom: auto;
}

.button-row {
  max-width: 100%;
}

.mc-button.small {
  min-width: 0;
  min-height: 32px;
  padding: 2px 10px;
  margin: 2px;
}

.mc-button.small.disabled {
  pointer-events: none;
}

@media (max-height: 640px) {
  .logo-wrap {
    margin-bottom: 12px;
  }
  .mc-button {
    min-height: 34px;
    margin: 3px;
  }
  .menu h2 {
    margin-bottom: 10px;
  }
}

@media (max-width: 440px) {
  .mc-button.half {
    width: calc(50vw - 20px);
    min-width: 0;
  }
  .mc-button.wide {
    width: calc(100vw - 32px);
  }
  .slider-wrap,
  input[type="range"].mc-slider {
    width: calc(50vw - 20px);
  }
}

/* ---------------------------------------------------------------- hearts and the tour */

.plot-info .hearts {
  color: #ff8aa8;
}

.tour-caption {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 30;
  min-width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid #000;
  text-shadow: 2px 2px 0 var(--shadow);
}

.tour-rank {
  color: #ff8aa8;
}

.tour-title {
  color: var(--yellow);
}

.tour-help {
  color: #a0a0a0;
  margin-top: 4px;
}

/* ---------------------------------------------------------------- snowball splat */

.splat {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  animation: splat-fade 1.8s ease-in forwards;
}

.splat .blob {
  position: absolute;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 45%, rgba(235, 243, 255, 0.7) 60%, rgba(255, 255, 255, 0) 72%);
  image-rendering: pixelated;
}

@keyframes splat-fade {
  0%,
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- admin panel */

.admin-panel {
  width: min(820px, calc(100vw - 16px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 24, 0.92);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 2px #555;
  padding: 12px 14px;
}

.admin-panel .tab {
  font-size: 20px;
}

.admin-list {
  overflow-y: auto;
  max-height: calc(100vh - 260px);
  min-height: 120px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 6px 8px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.admin-name {
  min-width: 0;
  flex: 1 1 220px;
  overflow-wrap: anywhere;
}

.admin-name .tag {
  color: #a0a0a0;
}

.admin-name .tag.red {
  color: var(--red);
}

.admin-id {
  color: #808080;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-search {
  width: 100%;
  height: 36px;
  margin-bottom: 8px;
  padding: 0 8px;
  font: inherit;
  font-size: 20px;
  color: #fff;
  background: #000;
  border: 2px solid #a0a0a0;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.admin-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.admin-panel {
  overflow-y: auto;
}

.admin-panel .inv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-panel .inv-title {
  flex: 1;
}

/* ---------------------------------------------------------------- mini games */

.game-hud {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  min-width: 220px;
  padding: 4px 14px 6px;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 229, 102, 0.5);
  pointer-events: none;
  text-shadow: 2px 2px 0 var(--shadow);
}

.game-hud-title {
  color: var(--yellow);
  font-size: 20px;
}

.game-hud-value {
  font-size: 40px;
  line-height: 1.1;
}

.game-hud-sub {
  color: var(--muted);
  font-size: 20px;
}

.game-banner {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  pointer-events: none;
  text-shadow: 3px 3px 0 var(--shadow);
}

.game-banner-big {
  color: var(--yellow);
  font-size: 60px;
  line-height: 1.1;
}

.game-banner-small {
  margin-top: 6px;
  font-size: 20px;
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .game-hud {
    top: 96px;
  }

  .game-banner-big {
    font-size: 40px;
  }
}

/* ---------------------------------------------------------------- intro cutscene */

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  text-shadow: 2px 2px 0 var(--shadow);
}

.intro-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 13vh;
  background: #000;
}

.intro-bar.top {
  top: 0;
}

.intro-bar.bottom {
  bottom: 0;
}

.intro-fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 1;
}

.intro-caption {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 16px);
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  padding: 10px 16px 12px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.8s;
  z-index: 1;
}

.intro-caption.shown {
  opacity: 1;
}

.intro-caption canvas {
  display: block;
  max-width: 100%;
  margin: 0 auto 10px;
  image-rendering: pixelated;
}

.intro-title {
  color: var(--yellow);
  font-size: 40px;
  line-height: 1.15;
}

.intro-text {
  margin-top: 6px;
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.intro-skip {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  pointer-events: auto;
  width: auto;
  padding: 0 14px;
}

.intro-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: var(--muted);
  font-size: 20px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .intro-title {
    font-size: 28px;
  }

  .intro-hint {
    display: none;
  }
}

/* ---------------------------------------------------------------- character creator */

.creator-screen {
  justify-content: flex-start;
}

.creator {
  display: flex;
  gap: 16px;
  width: min(1040px, 100%);
  align-items: flex-start;
}

.creator-left {
  flex: 1;
  min-width: 0;
}

.creator-right {
  width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.creator-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.creator-tab {
  font: inherit;
  font-size: 20px;
  color: #e6e6e6;
  background: #3a3a3a;
  border: 2px solid #1a1a1a;
  padding: 4px 10px;
  cursor: pointer;
  text-shadow: 2px 2px 0 var(--shadow);
}

.creator-tab:hover {
  background: #4a4a5a;
}

.creator-tab.active {
  color: var(--yellow);
  background: #5a5a6a;
  border-color: #fff;
}

.creator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #1a1a1a;
}

.creator-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font: inherit;
  color: #e6e6e6;
  background: #6b6b6b;
  border: 2px solid #2a2a2a;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.25), inset -2px -2px 0 rgba(0, 0, 0, 0.3);
  padding: 6px 4px 4px;
  cursor: pointer;
}

.creator-tile:hover {
  background: #7a7a9a;
}

.creator-tile.selected {
  border-color: #fff;
  background: #5c7a5c;
}

.creator-tile.locked canvas {
  filter: grayscale(1) brightness(0.55);
}

.creator-tile canvas {
  image-rendering: pixelated;
  width: 48px;
  height: 92px;
}

.creator-tile-name {
  font-size: 20px;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: 2px 2px 0 var(--shadow);
}

.creator-lock {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  font-size: 20px;
  color: var(--yellow);
  background: rgba(0, 0, 0, 0.7);
  text-shadow: none;
}

.creator-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  margin: 8px 0;
  align-items: center;
}

.creator-swatch {
  width: 32px;
  height: 32px;
  border: 2px solid #1a1a1a;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.3), inset -2px -2px 0 rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.creator-swatch.selected {
  outline: 3px solid #fff;
  outline-offset: 1px;
}

.creator-muted {
  color: var(--muted);
}

.creator-info {
  font-size: 20px;
  color: #d8d8d8;
  line-height: 1.3;
}

.creator-info div + div {
  margin-top: 4px;
}

.creator-doll {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 8px 0;
  background: radial-gradient(circle at 50% 60%, rgba(120, 150, 200, 0.35), rgba(0, 0, 0, 0.4));
  border: 2px solid #1a1a1a;
  margin-bottom: 8px;
}

.creator-doll {
  position: relative;
}

.creator-doll canvas {
  display: block;
  width: 100%;
  height: 360px;
}

.creator-drag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 16px;
  color: rgba(230, 234, 245, 0.7);
  pointer-events: none;
}

.creator-right .button-row {
  width: 100%;
  justify-content: center;
}

@media (max-width: 760px) {
  .creator {
    flex-direction: column-reverse;
  }

  .creator-right {
    width: 100%;
  }

  .creator-doll canvas {
    height: 260px;
  }

  .creator-grid {
    max-height: none;
  }
}

/* creator inside the see-through pause card */
.creator-screen.pause-shell {
  justify-content: safe center;
}

.creator-card {
  width: min(1120px, calc(100vw - 32px));
}

.creator-card .creator {
  width: 100%;
  padding: 14px 16px 16px;
  overflow-y: auto;
  min-height: 0;
}

.creator-card .creator-grid {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.12);
}

.creator-card .creator-doll {
  background: radial-gradient(circle at 50% 70%, rgba(150, 175, 230, 0.28), rgba(0, 0, 0, 0.25));
  border-color: rgba(255, 255, 255, 0.12);
}

.character-preview {
  touch-action: none;
  outline: none;
}

/* ---------------------------------------------------------------- title: character and side buttons */

.title-character {
  position: fixed;
  right: max(24px, 7vw);
  bottom: 56px;
  width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 21;
}

.title-character-name {
  font-size: 22px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #1e1e26;
  margin-bottom: -18px;
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-character .character-preview {
  display: block;
  width: 260px;
  height: 360px;
}

.title-character .mc-button.title-character-button {
  width: 100%;
  min-width: 0;
  margin: -6px 0 0;
}

.title-side {
  position: fixed;
  left: max(16px, 3vw);
  bottom: 56px;
  z-index: 21;
}

.title-side .mc-button.title-account {
  min-width: 180px;
}

.title-buttons .button-row.thirds {
  grid-template-columns: 1fr 1fr 1fr;
}

.title-buttons .mc-button.title-character-small {
  display: none;
}

.mc-button.primary {
  background-color: #5b825b;
  background-image: linear-gradient(rgba(90, 175, 95, 0.34), rgba(45, 105, 50, 0.42)), var(--tile-stone);
  color: #ffffff;
}

@media (max-width: 1000px) {
  .title-character {
    display: none;
  }

  .title-buttons .mc-button.title-character-small {
    display: inline-flex;
  }

  .title-side {
    position: static;
    margin-top: 8px;
  }
}

.creator-right .button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
}

.creator-right .mc-button.half,
.creator-right .mc-button.wide {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.creator-right .button-row:last-child {
  grid-template-columns: 1fr;
}

.title-buttons .button-row.thirds .mc-button {
  padding: 6px 4px;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .title-buttons .button-row.thirds .mc-button {
    font-size: 16px;
  }
}

/* ---------------------------------------------------------------- plot ratings */

.rate-card {
  width: min(520px, calc(100vw - 32px));
}

.rate-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
}

.rate-average {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  color: #d4dae6;
}

.heart-meter {
  display: inline-flex;
  gap: 3px;
}

.heart-cell {
  position: relative;
  display: inline-block;
}

.heart-cell img,
.rate-heart img {
  image-rendering: pixelated;
  width: 100%;
  height: 100%;
  display: block;
}

.heart-fill {
  position: absolute;
  inset: 0 auto 0 0;
  overflow: hidden;
}

.heart-fill img {
  width: 22px;
  height: 22px;
}

.rate-hearts {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

.rate-heart {
  width: 64px;
  height: 58px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: transform 0.08s;
}

.rate-heart:hover {
  transform: translateY(-3px) scale(1.06);
  border-color: rgba(255, 140, 160, 0.7);
  background: rgba(120, 30, 50, 0.35);
}

.rate-hearts.blocked .rate-heart {
  cursor: default;
  opacity: 0.55;
}

.rate-hearts.blocked .rate-heart:hover {
  transform: none;
}

.rate-word {
  text-align: center;
  font-size: 22px;
  color: var(--yellow);
  min-height: 28px;
}

.rate-help {
  text-align: center;
  font-size: 16px;
  color: #a8b0c0;
}

@media (max-width: 420px) {
  .rate-heart {
    width: 52px;
    height: 48px;
  }
}

/* ---------------------------------------------------------------- graphics settings */

.graphics-panel .button-row.thirds {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  width: 100%;
}

.graphics-panel .mc-button.third {
  min-width: 0;
  width: 100%;
  margin: 0;
}

/* ---------------------------------------------------------------- advent calendar */

.title-buttons .mc-button.advent-button {
  background-color: #8a2a2a;
  background-image: linear-gradient(rgba(220, 60, 60, 0.38), rgba(140, 20, 30, 0.46)), var(--tile-stone);
  color: #fff6d0;
}

.advent-card {
  width: min(900px, calc(100vw - 32px));
}

.advent-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
  overflow-y: auto;
  min-height: 0;
}

.advent-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.advent-door {
  position: relative;
  aspect-ratio: 1 / 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  font: inherit;
  color: #f4efe0;
  cursor: pointer;
  border: 2px solid #1a0a0c;
  background: linear-gradient(#7a1e24, #5e141a);
  box-shadow: inset 2px 2px 0 rgba(255, 220, 200, 0.22), inset -2px -2px 0 rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.advent-door:nth-child(3n + 2) {
  background: linear-gradient(#1f5a2e, #164422);
}

.advent-door:nth-child(3n) {
  background: linear-gradient(#2a3e78, #1e2c58);
}

.advent-date {
  font-size: 16px;
  color: rgba(255, 240, 210, 0.85);
}

.advent-number {
  font-size: 32px;
  color: #ffe9a0;
  text-shadow: 2px 2px 0 #3a1a0a;
}

.advent-door.shut .advent-number {
  color: rgba(255, 233, 160, 0.55);
}

.advent-door.due {
  border-color: #ffd84a;
  box-shadow: 0 0 0 2px rgba(255, 216, 74, 0.5), inset 2px 2px 0 rgba(255, 240, 200, 0.4);
  animation: advent-glow 1.2s ease-in-out infinite alternate;
}

.advent-door.today .advent-date {
  color: #ffd84a;
}

.advent-door.open {
  background: linear-gradient(#f4efe0, #ddd2b8);
  color: #3a2618;
}

.advent-door.open .advent-date {
  color: #7a5a3a;
}

.advent-door.missed {
  filter: grayscale(0.8) brightness(0.6);
}

.advent-inside {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

.advent-inside canvas {
  height: 56px;
  width: auto;
  image-rendering: pixelated;
}

.advent-item {
  font-size: 14px;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: none;
}

.advent-note {
  font-size: 18px;
  color: #d8deea;
  text-align: center;
  min-height: 24px;
}

@keyframes advent-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  .advent-door.due {
    animation: none;
  }
}

@media (max-width: 600px) {
  .advent-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.graphics-panel .button-row.fourths {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
}

.graphics-panel .button-row.fourths .mc-button {
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 6px 4px;
  white-space: nowrap;
}

.graphics-panel .mc-button.liminal-toggle.active-toggle {
  color: #fffbe6;
  background-image: linear-gradient(90deg, rgba(220, 210, 150, 0.35), rgba(190, 200, 150, 0.35)), var(--tile-stone);
}

@media (max-width: 600px) {
  .graphics-panel .button-row.fourths {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ------------------------------------------------------------------ sledge racing (client/sledge.ts) */

.race-hud {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  text-shadow: 2px 2px 0 var(--shadow);
}

.race-stats {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 6px 14px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.race-place {
  color: var(--yellow);
  font-size: 64px;
  line-height: 1;
}

.race-place[data-place="1"] {
  color: #ffd84a;
}

.race-place[data-place="2"] {
  color: #d8e0ea;
}

.race-place[data-place="3"] {
  color: #e0a06a;
}

.race-lap {
  font-size: 26px;
}

.race-time {
  color: var(--muted);
  font-size: 18px;
}

.race-item {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.race-item-frame {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  border: 3px solid rgba(255, 229, 102, 0.75);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.6);
}

.race-item[data-item="rolling"] .race-item-frame {
  border-color: #ffffff;
}

.race-item.shielded .race-item-frame {
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 14px 4px rgba(255, 216, 96, 0.8);
}

.race-item-icon {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
}

.race-item-count {
  position: absolute;
  right: 3px;
  bottom: 0;
  color: var(--yellow);
  font-size: 18px;
}

.race-item-name {
  font-size: 18px;
  min-height: 22px;
}

.race-map {
  position: absolute;
  right: 16px;
  bottom: 70px;
  width: 200px;
  height: 200px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.race-keys {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.race-lobby {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 18px 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 229, 102, 0.5);
  pointer-events: none;
  text-shadow: 2px 2px 0 var(--shadow);
}

.race-lobby-title {
  color: var(--yellow);
  font-size: 28px;
}

.race-lobby-presenter,
.race-lobby-hint {
  color: var(--muted);
  font-size: 16px;
}

.race-lobby-sub {
  font-size: 20px;
}

.race-lobby-names {
  color: #cfe8ff;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.race-results {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 13;
  width: min(560px, calc(100vw - 32px));
  pointer-events: none;
}

/* the card fills the centred box (.pause-card on its own is 920px wide, which pushed it off to the right) */
.race-results .race-results-card {
  width: 100%;
  max-height: calc(100vh - 80px);
}

.race-results .race-rows {
  overflow-y: auto;
}

.race-row.racing {
  opacity: 0.6;
}

.race-rows {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
}

.race-row {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 12px;
  align-items: baseline;
  padding: 3px 8px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.race-row.mine {
  background: rgba(255, 229, 102, 0.22);
}

.race-row.p1 .race-row-place {
  color: #ffd84a;
}

.race-row.p2 .race-row-place {
  color: #d8e0ea;
}

.race-row.p3 .race-row-place {
  color: #e0a06a;
}

.race-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-row-best,
.race-results-hint {
  color: var(--muted);
  font-size: 15px;
}

.race-results-hint {
  padding: 0 14px 10px;
  text-align: center;
}

/* squid ink splats, fading away */
.race-ink {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  animation: race-ink 4s ease-in forwards;
}

.race-ink-blob {
  position: absolute;
  border-radius: 46% 54% 42% 58% / 52% 44% 56% 48%;
  background: radial-gradient(circle at 40% 35%, #3a3058, #120e20 70%);
  box-shadow: 0 0 0 10px rgba(18, 14, 32, 0.6);
}

@keyframes race-ink {
  0%,
  55% {
    opacity: 0.96;
  }
  100% {
    opacity: 0;
  }
}

/* a lightning flash */
.race-flash {
  position: fixed;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  background: #f4fbff;
  animation: race-flash 0.6s ease-out forwards;
}

@keyframes race-flash {
  from {
    opacity: 0.9;
  }
  to {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .race-place {
    font-size: 44px;
  }

  .race-map {
    width: 120px;
    height: 120px;
  }

  .race-keys {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .race-flash {
    animation-duration: 0.2s;
    background: rgba(244, 251, 255, 0.5);
  }
}

/* the slipstream sign */
.race-slip {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  color: #9fe0ff;
  font-size: 24px;
  letter-spacing: 2px;
}

/* the vehicle picker (client/garage.ts) */
.garage-card-wrap {
  width: min(900px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.garage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: min-content;
  align-items: start;
  align-content: start;
  gap: 8px;
  padding: 10px 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.garage-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 10px;
  margin: 0;
  min-width: 0;
  min-height: min-content;
  height: auto;
  text-align: left;
  color: inherit;
  font: inherit;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.garage-card:hover {
  border-color: rgba(255, 255, 255, 0.45);
}

.garage-card.selected {
  border-color: var(--yellow);
  background: rgba(255, 229, 102, 0.12);
}

.garage-name {
  color: var(--yellow);
  font-size: 20px;
  line-height: 1.2;
}

.garage-kind,
.garage-blurb,
.garage-help {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.garage-help {
  flex: 0 0 auto;
  padding: 0 14px 8px;
  text-align: center;
}

.garage-card-wrap > .pause-header,
.garage-card-wrap > .pause-grid {
  flex: 0 0 auto;
}

.garage-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.garage-stat {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.garage-bar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
  width: 100%;
}

.garage-bar span {
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.garage-bar span.on {
  background: #6fd06f;
}

.garage-stats-compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 6px;
}

.garage-stats-compact .garage-stat {
  display: block;
  grid-template-columns: none;
}

.garage-stats-compact .garage-bar span {
  height: 5px;
}

@media (max-width: 700px) {
  .garage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .garage-blurb {
    display: none;
  }

  .garage-stat {
    grid-template-columns: 72px minmax(0, 1fr);
    font-size: 12px;
  }
}

/* speed lines streaking in from the edges at full speed and in boosts (client/chasecam.ts) */
.race-speedlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- Minecraft-style touch controls */

/* #ui > * sets pointer-events:auto — override so empty HUD space passes look-drags through */
#ui > .touch-hud,
.touch-hud {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none !important;
  touch-action: none;
}

.touch-chrome {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.touch-chrome-btn {
  min-width: 52px;
  height: 40px;
  padding: 0 12px;
  border: 2px solid rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #3f3f3f;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.touch-chrome-btn:active,
.touch-pad.held {
  background: rgba(255, 255, 255, 0.22);
}

.touch-stick {
  position: absolute;
  left: calc(18px + env(safe-area-inset-left, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  border: 3px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  border: 2px solid rgba(0, 0, 0, 0.55);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  will-change: transform;
}

.touch-actions {
  position: absolute;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: auto auto;
  justify-items: end;
  align-items: end;
  gap: 10px 12px;
  pointer-events: auto;
}

.touch-actions-village .touch-pad.sprint {
  grid-column: 2;
  grid-row: 1;
}

.touch-actions-village .touch-pad.throw {
  grid-column: 1;
  grid-row: 2;
}

.touch-actions-village .touch-pad.jump {
  grid-column: 2;
  grid-row: 2;
}

.touch-actions-village .touch-pad.sneak {
  grid-column: 2;
  grid-row: 3;
}

.touch-actions-race .touch-pad.wheelie {
  grid-column: 1;
  grid-row: 1;
}

.touch-actions-race .touch-pad.item {
  grid-column: 1;
  grid-row: 2;
}

.touch-actions-race .touch-pad.jump {
  grid-column: 2;
  grid-row: 2;
}

.touch-actions-race .touch-pad.sneak {
  grid-column: 2;
  grid-row: 3;
}

.touch-pad {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: inherit;
  font-size: 26px;
  line-height: 1;
  text-shadow: 2px 2px 0 #3f3f3f;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.touch-pad.sprint {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.touch-pad.sneak {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.touch-pad.throw,
.touch-pad.item,
.touch-pad.wheelie {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  line-height: 1.1;
  padding: 4px;
}

.touch-pad.throw {
  background: rgba(40, 110, 160, 0.55);
  border-color: rgba(170, 220, 255, 0.45);
}

.touch-pad.throw.hint {
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.35),
    0 0 0 3px rgba(120, 200, 255, 0.75);
  animation: touch-throw-pulse 1.1s ease-in-out infinite;
}

@keyframes touch-throw-pulse {
  50% {
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.35),
      0 0 0 5px rgba(160, 230, 255, 0.95);
  }
}

.touch-pad.item {
  background: rgba(150, 90, 20, 0.55);
  border-color: rgba(255, 200, 100, 0.45);
}

.touch-pad.wheelie {
  background: rgba(90, 50, 140, 0.55);
  border-color: rgba(210, 180, 255, 0.45);
}

/* Hotbar stays docked at the bottom (Minecraft mobile), between stick and pads */
html.touch-play .hotbar {
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 26;
}

html.touch-play .held-name {
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

html.touch-play .animal-hint {
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  font-size: 14px;
  white-space: normal;
  text-align: center;
  max-width: min(280px, calc(100vw - 280px));
}

html.touch-play .messages {
  left: calc(8px + env(safe-area-inset-left, 0px));
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  width: min(360px, calc(100vw - 180px));
  font-size: 16px;
}

html.touch-play .plot-info,
html.touch-play .status {
  top: calc(52px + env(safe-area-inset-top, 0px));
}

html.touch-client,
html.touch-client body {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

html.touch-client .touch-chrome-btn:focus,
html.touch-client .touch-pad:focus,
html.touch-client .hotbar-more:focus,
html.touch-client .fs-hint:focus {
  outline: none;
}

html.touch-client .click-to-play {
  display: none !important;
}

html.touch-client .slot .key {
  display: none;
}

html.touch-client .mc-inv-body,
html.touch-client .mc-inv-panel,
html.touch-client .menu.dirt {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 480px) {
  .touch-stick {
    width: 112px;
    height: 112px;
    left: calc(10px + env(safe-area-inset-left, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .touch-stick-knob {
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
  }

  .touch-pad {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .touch-pad.sprint,
  .touch-pad.sneak {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .touch-pad.throw,
  .touch-pad.item,
  .touch-pad.wheelie {
    width: 50px;
    height: 50px;
    font-size: 10px;
  }

  html.touch-play .hotbar .slot,
  html.touch-play .hotbar-more {
    width: 36px;
    height: 36px;
    margin: 1px;
  }

  html.touch-play .hotbar .slot img {
    inset: 3px;
    width: 30px;
    height: 30px;
  }

  html.touch-play .hotbar-more {
    font-size: 14px;
  }
}

/* =================================================================
   Touch-client UI polish (phones/tablets only).
   Scoped under html.touch-client / html.touch-play — desktop untouched.
   ================================================================= */

/* ---- 1. Global chrome ---- */

html.touch-client .mc-button {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 18px;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

html.touch-client .mc-button.half {
  min-height: 44px;
}

html.touch-client .menu,
html.touch-client .dirt-screen,
html.touch-client .title-screen,
html.touch-client .pause-shell {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-right: calc(12px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(12px + env(safe-area-inset-left, 0px));
  -webkit-overflow-scrolling: touch;
}

html.touch-client .menu {
  justify-content: flex-start;
  align-items: stretch;
}

html.touch-client .menu.dirt,
html.touch-client .menu:not(.pause-shell) {
  align-items: center;
}

html.touch-client .menu h2 {
  font-size: 22px;
  margin-bottom: 14px;
}

html.touch-client .menu p,
html.touch-client .rules,
html.touch-client .credits,
html.touch-client .controls-table {
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
}

html.touch-client .controls-table td {
  padding: 8px 10px;
  font-size: 16px;
  vertical-align: top;
}

html.touch-client .controls-table td:first-child {
  white-space: nowrap;
}

html.touch-client .corner {
  bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  font-size: 13px;
  max-width: 42vw;
}

html.touch-client .corner.left {
  left: calc(8px + env(safe-area-inset-left, 0px));
}

html.touch-client .corner.right {
  right: calc(8px + env(safe-area-inset-right, 0px));
}

html.touch-client .mc-input,
html.touch-client input[type="text"],
html.touch-client input[type="search"] {
  min-height: 44px;
  font-size: 16px; /* avoids iOS zoom-on-focus */
}

html.touch-client .slider-wrap {
  min-height: 44px;
}

html.touch-client input[type="range"].mc-slider {
  min-height: 28px;
}

/* ---- 2. Title screen ---- */

html.touch-client .title-screen {
  justify-content: flex-start;
  gap: 8px;
}

html.touch-client .logo-wrap {
  margin-bottom: 16px;
  margin-top: 4px;
}

html.touch-client .logo-wrap canvas {
  width: clamp(220px, 72vw, 420px);
}

html.touch-client .splash {
  right: 0;
  bottom: -10px;
  font-size: 14px;
  max-width: 46vw;
  white-space: normal;
  text-align: center;
}

html.touch-client .title-buttons {
  width: min(400px, calc(100vw - 24px));
  gap: 10px;
  order: 2;
}

html.touch-client .title-character {
  position: static !important;
  right: auto;
  bottom: auto;
  order: 3;
  margin-top: 12px;
  width: min(220px, 70vw);
  align-self: center;
}

html.touch-client .title-character .character-preview,
html.touch-client .title-character canvas {
  width: min(160px, 50vw) !important;
  height: auto !important;
  max-height: 28vh;
}

html.touch-client .title-character-name {
  font-size: 16px;
  margin-bottom: 4px;
}

html.touch-client .title-side {
  position: static !important;
  left: auto;
  bottom: auto;
  order: 1;
  align-self: flex-end;
  margin: 0 0 4px;
  width: auto;
}

html.touch-client .title-side .mc-button.title-account {
  min-height: 40px;
  font-size: 15px;
  padding: 6px 12px;
}

html.touch-client .title-buttons .title-character-small {
  display: none; /* full Character block below already */
}

html.touch-client .title-note {
  font-size: 14px;
  line-height: 1.35;
}

/* ---- 3. Pause menu ---- */

html.touch-client .pause-shell {
  padding: calc(10px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
}

html.touch-client .pause-card {
  width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 640px;
  max-height: calc(
    100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
  );
  max-height: calc(100vh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

html.touch-client .pause-columns {
  grid-template-columns: 1fr;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.touch-client .pause-left {
  border-right: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  padding: 12px;
}

html.touch-client .pause-stats {
  max-height: none;
  border-left: none;
  padding: 12px;
}

html.touch-client .pause-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
}

html.touch-client .pause-header h2 {
  font-size: 20px;
}

html.touch-client .pause-tab-btn.mc-button {
  min-height: 40px;
  font-size: 15px;
  padding: 6px 10px;
}

html.touch-client .pause-grid,
html.touch-client .pause-bottom-row {
  gap: 10px;
}

html.touch-client .pause-grid .mc-button.half,
html.touch-client .pause-bottom-row .mc-button.half {
  font-size: 16px;
  min-height: 44px;
}

html.touch-client .pause-callout-title {
  font-size: 17px;
}

html.touch-client .pause-callout-sub {
  font-size: 14px;
}

html.touch-client .stat-row {
  font-size: 14px;
}

/* ---- 4. Creative inventory ---- */

html.touch-client .mc-creative-wrap {
  width: calc(100vw - 12px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 520px;
}

html.touch-client .mc-creative-panel {
  padding: 8px;
  max-height: calc(100dvh - 120px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100vh - 120px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.touch-client .mc-inv-search {
  width: 100%;
  max-width: none;
  height: 36px;
  font-size: 16px;
}

html.touch-client .mc-inv-head {
  flex-wrap: wrap;
  gap: 8px;
}

html.touch-client .mc-tabs {
  flex-wrap: wrap;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

html.touch-client .mc-tab {
  width: 42px;
  height: 40px;
  flex: 0 0 auto;
}

html.touch-client .mc-tab.top.active,
html.touch-client .mc-tab.bottom.active {
  height: 44px;
}

html.touch-client .mc-tab img {
  width: 26px;
  height: 26px;
}

html.touch-client .mc-grid {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto);
  width: 100%;
  gap: 2px;
}

html.touch-client .mc-slot {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
}

html.touch-client .mc-slot img {
  width: 70%;
  height: 70%;
  max-width: 32px;
  max-height: 32px;
}

html.touch-client .mc-hotbar-row .mc-slot,
html.touch-client .mc-hotbar-row .mc-trash {
  width: 40px;
  height: 40px;
}

html.touch-client .mc-inv-foot {
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 4px;
}

/* ---- 5. Chat ---- */

html.touch-client .chat-input {
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  height: 44px;
  font-size: 16px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 0;
}

html.touch-play.touch-client .chat-input {
  /* sit above hotbar + stick while chatting */
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

html.touch-client .messages.open,
html.touch-client .messages {
  font-size: 15px;
}

/* ---- 6. Creator / advent / rating / admin / options ---- */

html.touch-client .creator-screen,
html.touch-client .creator-card {
  width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 640px;
}

html.touch-client .creator {
  flex-direction: column;
  width: 100%;
  gap: 12px;
}

html.touch-client .creator-right {
  width: 100%;
  order: -1;
}

html.touch-client .creator-doll canvas {
  max-height: 28vh;
  width: auto;
}

html.touch-client .creator-grid {
  max-height: 42vh;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  -webkit-overflow-scrolling: touch;
}

html.touch-client .creator-tab {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 16px;
}

html.touch-client .creator-tile {
  min-height: 44px;
  padding: 8px 4px;
}

html.touch-client .creator-swatch {
  width: 36px;
  height: 36px;
}

html.touch-client .advent-card,
html.touch-client .rate-card {
  width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 520px;
}

html.touch-client .garage-screen {
  align-items: center;
  justify-content: safe center;
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
}

html.touch-client .garage-screen > .garage-card-wrap {
  margin-top: 0;
  margin-bottom: 0;
}

html.touch-client .garage-card-wrap {
  width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 520px;
  max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

html.touch-client .garage-card-wrap > .pause-header,
html.touch-client .garage-card-wrap > .garage-help,
html.touch-client .garage-card-wrap > .pause-grid {
  flex-shrink: 0;
}

html.touch-client .advent-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

html.touch-client .advent-door {
  min-height: 72px;
  font-size: 16px;
}

html.touch-client .admin-panel {
  width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 640px;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

html.touch-client .admin-row {
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 8px;
}

html.touch-client .admin-actions {
  flex-wrap: wrap;
  width: 100%;
  gap: 6px;
}

html.touch-client .admin-actions .mc-button,
html.touch-client .admin-actions button {
  min-height: 40px;
  font-size: 14px;
}

html.touch-client .admin-search {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
}

html.touch-client .options-panel {
  width: 100%;
  max-width: min(480px, calc(100vw - 24px));
}

html.touch-client .options-panel .button-row {
  gap: 8px;
}

html.touch-client .options-panel .mc-button.half {
  min-height: 44px;
}

html.touch-client .menu > .options-panel {
  max-width: min(480px, calc(100vw - 24px));
}

/* ---- 7. Garage / race / minigame / intro ---- */

html.touch-client .garage-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: min-content;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px 10px;
}

html.touch-client .garage-card,
html.touch-client .garage-card.compact {
  min-height: min-content;
  height: auto;
  padding: 10px;
  gap: 4px;
  /* Safari <button> as flex/grid: force normal flow */
  position: relative;
  overflow: visible;
}

html.touch-client .garage-name {
  font-size: 16px;
}

html.touch-client .garage-kind {
  font-size: 11px;
}

html.touch-client .garage-blurb {
  display: none;
}

html.touch-client .garage-help {
  font-size: 13px;
  padding: 4px 10px 8px;
}

@media (max-width: 380px) {
  html.touch-client .garage-grid {
    grid-template-columns: 1fr;
  }
}

html.touch-client .race-hud {
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
}

html.touch-client .race-stats {
  font-size: 16px;
  gap: 8px;
}

html.touch-client .race-item {
  top: calc(56px + env(safe-area-inset-top, 0px));
}

html.touch-client .race-item-frame {
  width: 64px;
  height: 64px;
}

html.touch-client .race-map {
  width: 120px;
  height: 120px;
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

html.touch-client .race-keys {
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  font-size: 13px;
}

html.touch-client .race-lobby {
  top: calc(56px + env(safe-area-inset-top, 0px));
  max-width: calc(100vw - 24px);
  font-size: 14px;
}

html.touch-client .race-lobby-title {
  font-size: 22px;
}

html.touch-client .race-results {
  width: calc(100vw - 24px);
  max-height: calc(100dvh - 48px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.touch-client .game-hud {
  top: calc(56px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
}

html.touch-client .game-banner-big {
  font-size: clamp(28px, 8vw, 48px);
}

html.touch-client .game-banner-small {
  font-size: 16px;
}

html.touch-client .intro-skip {
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  min-height: 44px;
  padding: 0 16px;
}

html.touch-client .intro-caption {
  width: min(760px, calc(100vw - 24px));
  bottom: calc(100% + 8px);
  padding: 8px 12px;
}

html.touch-client .intro-title {
  font-size: 26px;
}

html.touch-client .intro-text {
  font-size: 16px;
}

html.touch-client .intro-hint {
  display: none;
}

html.touch-client .intro-bar {
  height: max(10vh, env(safe-area-inset-top, 0px));
}

html.touch-client .intro-bar.bottom {
  height: max(10vh, env(safe-area-inset-bottom, 0px));
}

/* ---- 8. In-play HUD polish ---- */

html.touch-play .status {
  right: calc(8px + env(safe-area-inset-right, 0px));
  left: auto;
  text-align: right;
  max-width: min(200px, 42vw);
  font-size: 13px;
  line-height: 1.3;
}

html.touch-play .plot-info {
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: auto;
  transform: none;
  text-align: left;
  max-width: min(220px, 48vw);
  font-size: 13px;
}

html.touch-play .plot-info small {
  font-size: 12px;
}

html.touch-play .debug {
  top: calc(100px + env(safe-area-inset-top, 0px));
  font-size: 11px;
  max-width: 55vw;
}

html.touch-play .fps-pill {
  top: calc(100px + env(safe-area-inset-top, 0px));
}

/* Landscape: denser HUD so stick/pads and hotbar share the bottom edge */
@media (orientation: landscape) {
  html.touch-client .title-character {
    display: none;
  }

  html.touch-client .title-buttons .title-character-small {
    display: block;
  }

  html.touch-client .pause-card {
    max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  html.touch-play .touch-stick {
    width: 100px;
    height: 100px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
  }

  html.touch-play .touch-stick-knob {
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
  }

  html.touch-play .touch-pad {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  html.touch-play .touch-pad.sprint,
  html.touch-play .touch-pad.sneak {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  html.touch-play .touch-pad.throw,
  html.touch-play .touch-pad.item,
  html.touch-play .touch-pad.wheelie {
    width: 44px;
    height: 44px;
    font-size: 9px;
  }

  html.touch-play .touch-actions {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  html.touch-play .hotbar .slot,
  html.touch-play .hotbar-more {
    width: 34px;
    height: 34px;
  }

  html.touch-play .hotbar .slot img {
    inset: 3px;
    width: 28px;
    height: 28px;
  }

  html.touch-play .held-name {
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
  }

  html.touch-play .animal-hint {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    max-width: min(240px, calc(100vw - 240px));
  }

  html.touch-play .messages {
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
  }

  html.touch-play.touch-client .chat-input {
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  }

  html.touch-client .race-map {
    width: 96px;
    height: 96px;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }
}

/* Very narrow portrait phones */
@media (orientation: portrait) and (max-width: 420px) {
  html.touch-client .pause-grid,
  html.touch-client .pause-bottom-row {
    grid-template-columns: 1fr;
  }

  html.touch-client .title-buttons .button-row {
    grid-template-columns: 1fr;
  }
}
