@font-face {
  font-family: system-ui;
  src: local(system-ui);
}
:root {
  color-scheme: light;
  --ink: #203d38;
  --muted: #56675e;
  --paper: #f8f6ed;
  --line: #d9ded1;
  --green: #244e3e;
  --gold: #f1c76b;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  min-height: 100dvh;
}
body {
  margin: 0;
  background: #c4e2eb;
  overflow: hidden;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 11px 15px;
  min-height: 44px;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: #e9eddf;
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
button.primary:hover {
  background: #183c2e;
}
button.text-button {
  border: 0;
  background: transparent;
  padding: 7px 0;
  min-height: 36px;
  font-size: 0.84rem;
}
button.danger {
  color: #933f31;
}
a {
  color: inherit;
  text-underline-offset: 3px;
}
a:hover {
  text-decoration: underline;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #b76d19;
  outline-offset: 3px;
}
input,
select {
  width: 100%;
  border: 1px solid #a9b6a9;
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fffef9;
  min-height: 44px;
}
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  margin: 16px 0 7px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h2 {
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}
h3 {
  font-size: 0.85rem;
  margin: 18px 0 8px;
}
p {
  line-height: 1.5;
}
h3 span {
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}
[hidden] {
  display: none !important;
}
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
#lobby {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(24px, 5vh, 60px) clamp(20px, 6vw, 100px);
  background: linear-gradient(90deg, #162f3538, transparent 75%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-shadow: 0 2px 14px #1c37384f;
  max-width: 450px;
  margin: 0 0 24px;
}
.brand img {
  border-radius: 11px;
  box-shadow: 0 2px 6px #1c373820;
}
.brand h1 {
  font-size: 2rem;
  letter-spacing: -0.065em;
  line-height: 1;
}
.tag {
  margin-left: auto;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  font-weight: 750;
  background: #203d38bf;
  border: 1px solid #dfe8d456;
  padding: 7px 9px;
  border-radius: 6px;
  text-shadow: none;
}
.lobby-card {
  width: 430px;
  max-width: 100%;
  padding: 24px;
  background: var(--paper);
  border: 1px solid #ffffff99;
  border-radius: 18px;
  box-shadow: 0 20px 70px #152b3333;
}
.switch {
  display: flex;
  padding: 4px;
  border-radius: 11px;
  background: #e6e9dd;
  gap: 4px;
  margin-bottom: 20px;
}
.switch button {
  flex: 1;
  border: 0;
  background: transparent;
  min-height: 40px;
  padding: 8px;
}
.switch button[aria-pressed="true"] {
  background: #fffef9;
  box-shadow: 0 1px 4px #17291c17;
}
.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.two-fields label {
  margin-top: 16px;
}
.optional {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
}
.start-actions {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 8px;
  margin-top: 22px;
}
.primary span {
  margin-left: 8px;
}
.full {
  width: 100%;
  margin-top: 18px;
}
.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 9px 0;
}
.privacy-note {
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 13px;
}
.status {
  font-size: 0.83rem;
  color: #88412f;
  margin-top: 8px;
}
.status:empty {
  display: none;
}
.code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
input.code {
  font-size: 1.5rem;
  padding: 17px;
}
footer {
  background: #203d38d9;
  border-radius: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  max-width: 450px;
  margin-top: 14px;
  padding: 4px 12px;
  color: white;
  text-shadow: 0 1px 6px #163435;
}
footer button.text-button,
footer a {
  color: white;
  font-size: 0.72rem;
}
footer a {
  text-decoration: none;
}
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: 18px;
}
#hud button,
#hud #hotbar {
  pointer-events: auto;
}
.game-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.world-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8f6edf5;
  border: 1px solid #ffffffc9;
  border-radius: 12px;
  padding: 8px 14px 8px 8px;
  box-shadow: 0 4px 20px #17363b1c;
  min-width: 0;
  max-width: 55%;
}
.world-badge img {
  border-radius: 7px;
}
.world-badge div {
  min-width: 0;
}
.world-badge strong {
  display: block;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.world-badge span {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 2px;
}
.game-buttons {
  display: flex;
  gap: 8px;
}
#room-button {
  font-size: 0.85rem;
}
.game-buttons button,
.flight button {
  box-shadow: 0 3px 16px #16343526;
  background: #f8f6edf5;
}
.flight {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.flight button {
  padding: 8px 14px;
  min-width: 60px;
}
#visitor {
  font-size: 0.8rem;
  padding: 8px 12px;
  background: var(--paper);
  border-radius: 8px;
}
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font:
    26px/1 ui-monospace,
    monospace;
  text-shadow:
    1px 1px 2px #203d38,
    -1px -1px 2px #203d38;
}
.bottom-bar {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  max-width: calc(100% - 24px);
}
#material-name {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 650;
  color: white;
  text-shadow: 0 1px 4px #162e2c;
  margin-bottom: 8px;
  background: #1c383cbf;
  border-radius: 6px;
  padding: 5px 10px;
}
.hotbar-wrap {
  display: flex;
  gap: 6px;
  justify-content: center;
  background: #16312ed9;
  padding: 6px;
  border: 1px solid #d6e2ce78;
  border-radius: 13px;
  box-shadow: 0 7px 20px #152b3333;
}
#hotbar {
  display: flex;
  gap: 4px;
  min-width: 0;
}
.block-button {
  position: relative;
  min-width: 40px;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 6px;
  border-radius: 6px;
  background: #f8f6edc9;
  border: 2px solid transparent;
}
.block-button[aria-pressed="true"] {
  border-color: white;
  background: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
  transform: translateY(-3px);
}
.swatch {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--block);
  box-shadow:
    inset 0 5px 0 #ffffff27,
    inset -5px 0 0 #0002;
  border: 1px solid #203d3830;
}
.block-button small {
  position: absolute;
  left: 3px;
  top: 0;
  font-size: 9px;
  color: #152d28;
  background: #fffdf1cf;
  border-radius: 2px;
  padding: 0 2px;
}
#palette-button {
  width: 44px;
  min-width: 40px;
  min-height: 44px;
  padding: 0;
  font-size: 1.6rem;
  border-radius: 6px;
}
#desktop-hint {
  color: white;
  font-size: 0.66rem;
  text-shadow: 0 1px 5px #173630;
  margin-top: 10px;
}
.touch-controls {
  display: none;
}
#player-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
#player-labels span {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #203d38d9;
  color: white;
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 5px;
  white-space: nowrap;
}
#toast {
  position: fixed;
  z-index: 8;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90%, 520px);
  background: #203d38f5;
  color: white;
  border: 1px solid #fff8;
  border-radius: 10px;
  padding: 12px 18px;
  box-shadow: 0 5px 25px #1c302a33;
  font-size: 0.87rem;
  pointer-events: none;
}
dialog {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid white;
  border-radius: 18px;
  width: 540px;
  max-width: calc(100% - 24px);
  max-height: calc(100dvh - 32px);
  padding: 24px;
  box-shadow: 0 20px 90px #102e3a40;
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: #19333377;
  backdrop-filter: blur(5px);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.invite {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e8ecdf;
  border-radius: 12px;
  padding: 14px;
}
.invite > div {
  margin-right: auto;
}
.eyebrow {
  display: block;
  letter-spacing: 0.1em;
  font-size: 0.6rem;
  margin-bottom: 3px;
}
.invite strong {
  font-size: 1.35rem;
}
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.82rem;
}
.check input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}
#players {
  list-style: none;
  padding: 0;
  margin: 0;
}
#players li,
.request {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}
#players li .player-name,
.request .player-name {
  flex: 1;
  overflow-wrap: anywhere;
}
#players button,
.request button {
  padding: 8px 10px;
  font-size: 0.73rem;
  min-height: 40px;
}
.player-role {
  font-size: 0.7rem;
  color: var(--muted);
}
.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.menu-actions button {
  font-size: 0.8rem;
}
.menu-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.menu-footer a {
  font-size: 0.8rem;
  margin-left: auto;
}
details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 650;
  padding: 8px 0;
}
.help-copy p {
  font-size: 0.82rem;
  line-height: 1.65;
  margin-top: 12px;
}
#all-blocks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
#all-blocks button {
  height: auto;
  width: 100%;
  padding: 10px 7px;
  font-size: 0.72rem;
}
#all-blocks .swatch {
  width: 42px;
  height: 42px;
  margin: 0 auto 8px;
}
.controls-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px 20px;
  font-size: 0.83rem;
  line-height: 1.5;
  margin: 22px 0;
}
.controls-list dt {
  font-weight: 700;
}
.controls-list dd {
  margin: 0;
}
#help > p {
  font-size: 0.9rem;
}
#resume-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.no-script {
  position: fixed;
  inset: 20%;
  background: var(--paper);
  padding: 40px;
  border-radius: 20px;
  z-index: 20;
}
body[data-state="loading"] #host,
body[data-state="loading"] #solo {
  opacity: 0.5;
}
@media (pointer: coarse) {
  .touch-controls {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  #joystick {
    position: absolute;
    bottom: 135px;
    left: 28px;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    background: #f8f6ed33;
    border: 2px solid #ffffff88;
    display: grid;
    place-items: center;
    pointer-events: auto;
    touch-action: none;
  }
  #joystick span {
    display: block;
    width: 46px;
    height: 46px;
    border: 2px solid #ffffffba;
    border-radius: 50%;
    background: #f8f6edaa;
  }
  .touch-actions {
    position: absolute;
    bottom: 135px;
    right: 22px;
    display: grid;
    grid-template-columns: 62px 62px;
    gap: 9px;
  }
  .touch-actions button {
    pointer-events: auto;
    touch-action: none;
    border-radius: 50%;
    min-height: 58px;
    padding: 5px;
    color: #18392e;
    background: #f8f6eddf;
    font-size: 0.78rem;
  }
  .touch-actions #jump,
  .touch-actions #down {
    font-size: 1.5rem;
    min-height: 50px;
    width: 50px;
    justify-self: center;
  }
  .touch-actions #jump {
    grid-column: 2;
  }
  #desktop-hint {
    display: none;
  }
}
@media (max-width: 600px) {
  #lobby {
    padding: 22px 16px 30px;
    background: #19392f26;
  }
  .brand {
    margin: 0 auto 18px;
    max-width: 430px;
  }
  .brand h1 {
    font-size: 1.75rem;
  }
  .lobby-card {
    margin: auto;
    padding: 20px;
    border-radius: 16px;
  }
  footer {
    margin: 12px auto 0;
    gap: 4px 14px;
  }
  .game-top {
    gap: 5px;
  }
  .world-badge {
    max-width: 52%;
    padding-right: 9px;
    gap: 7px;
  }
  .world-badge strong {
    font-size: 0.76rem;
  }
  .world-badge span {
    font-size: 0.6rem;
  }
  .world-badge img {
    width: 27px;
    height: 27px;
  }
  .game-buttons {
    gap: 5px;
  }
  .game-buttons button {
    padding: 10px;
    font-size: 0.8rem;
  }
  #hud {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .game-buttons #menu-button span {
    display: none;
  }
  .block-button {
    min-width: 24px;
    width: 30px;
    height: 37px;
    padding: 4px;
  }
  .hotbar-wrap {
    gap: 4px;
    padding: 5px;
    border-radius: 9px;
  }
  #hotbar {
    gap: 3px;
  }
  .block-button small {
    display: none;
  }
  #palette-button {
    min-width: 32px;
    width: 32px;
    min-height: 37px;
  }
  .bottom-bar {
    max-width: calc(100% - 12px);
    width: max-content;
  }
  .flight {
    margin-top: 8px;
  }
  .flight button {
    min-height: 40px;
    padding: 7px 12px;
  }
  dialog {
    padding: 20px;
  }
  .invite {
    flex-wrap: wrap;
    padding: 12px;
  }
  .invite strong {
    font-size: 1.2rem;
  }
  .invite button {
    font-size: 0.77rem;
    padding: 9px 12px;
  }
  #all-blocks {
    grid-template-columns: repeat(3, 1fr);
  }
  #toast {
    top: 115px;
    font-size: 0.8rem;
  }
}
@media (max-width: 360px) {
  .lobby-card {
    padding: 16px;
  }
  .start-actions {
    grid-template-columns: 1fr;
  }
  .start-actions button {
    width: 100%;
  }
  .block-button {
    width: 25px;
    min-width: 23px;
  }
  #hotbar {
    gap: 2px;
  }
  #palette-button {
    min-width: 28px;
    width: 28px;
  }
  .touch-actions {
    right: 14px;
    grid-template-columns: 53px 53px;
    gap: 6px;
  }
  .touch-actions button {
    min-height: 53px;
  }
  #joystick {
    left: 18px;
    width: 95px;
    height: 95px;
  }
  .world-badge img {
    display: none;
  }
  .two-fields {
    gap: 8px;
  }
  .optional {
    display: none;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  #lobby {
    padding: 18px 24px;
  }
  .brand {
    margin-bottom: 12px;
  }
  .lobby-card {
    padding: 18px;
  }
  #joystick {
    bottom: 36px;
    width: 90px;
    height: 90px;
    left: 28px;
  }
  .touch-actions {
    bottom: 22px;
    right: 28px;
    grid-template-columns: 54px 54px;
    gap: 6px;
  }
  .touch-actions button {
    min-height: 48px;
  }
  .bottom-bar {
    bottom: 12px;
  }
  .block-button {
    width: 30px;
    min-width: 28px;
    height: 36px;
  }
  #palette-button {
    min-height: 36px;
    width: 32px;
    min-width: 32px;
  }
  #material-name {
    margin-bottom: 5px;
    font-size: 0.7rem;
  }
  #desktop-hint {
    display: none;
  }
  #hud {
    padding: 10px;
  }
  .flight {
    margin-top: 7px;
  }
  #toast {
    top: 75px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (pointer: coarse) {
  .bottom-bar {
    width: calc(100% - 24px);
    max-width: 540px;
  }
  #hotbar {
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    padding: 3px 1px 0;
  }
  #hotbar::-webkit-scrollbar {
    display: none;
  }
  #hotbar .block-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 6px;
  }
  #palette-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .flight button {
    min-height: 44px;
  }
}
@media (pointer: coarse) and (max-height: 520px) and (orientation: landscape) {
  .bottom-bar {
    width: calc(100% - 330px);
    max-width: 500px;
  }
}
