:root {
  --ui-border: rgba(255, 255, 255, 0.16);
  --ui-strong: rgba(255, 255, 255, 0.82);
  --slot-size: 62px;
  --slot-gap: 10px;
  --drawer-height: 0px;
  --log-height: 0px;
  --tray-width: 384px;
  --log-width: 980px;
  --panel-bg: rgba(9, 13, 20, 0.92);
  --panel-accent: #8ee7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #081225;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  user-select: none;
}

body {
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#world-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(7, 12, 20, 0.26), rgba(4, 8, 13, 0.78)),
    rgba(5, 9, 15, 0.42);
  backdrop-filter: blur(14px);
}

body.world-select #world-menu {
  display: flex;
}

body.world-select #log-shell,
body.world-select #gem-counter,
body.world-select #shop-panel,
body.world-select #inventory-shell {
  display: none;
}

#world-menu-shell {
  width: min(720px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%),
    rgba(10, 15, 24, 0.94);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.36);
}

.world-menu-heading {
  margin-bottom: 16px;
}

.world-menu-title {
  color: #f5fbff;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.world-menu-subtitle {
  margin-top: 6px;
  color: rgba(225, 236, 244, 0.7);
  font-size: 14px;
}

#world-search {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef7ff;
  font: inherit;
  font-size: 15px;
  outline: none;
}

#world-search::placeholder {
  color: rgba(238, 247, 255, 0.42);
}

#world-search:focus {
  border-color: rgba(142, 231, 255, 0.44);
  box-shadow: 0 0 0 1px rgba(142, 231, 255, 0.12);
}

#world-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  max-height: min(420px, calc(100vh - 220px));
  overflow-y: auto;
}

.world-card,
.world-empty {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 56%),
    rgba(18, 24, 36, 0.88);
}

.world-card {
  width: 100%;
  padding: 16px 18px;
  color: #eef7ff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.world-card:hover,
.world-card:focus-visible {
  border-color: rgba(142, 231, 255, 0.36);
  background:
    linear-gradient(180deg, rgba(210, 246, 255, 0.08), transparent 56%),
    rgba(20, 29, 43, 0.94);
  transform: translateY(-1px);
  outline: none;
}

.world-card-name {
  color: #f5fbff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.world-card-meta {
  margin-top: 6px;
  color: rgba(225, 236, 244, 0.72);
  font-size: 13px;
  line-height: 1.45;
}

.world-empty {
  padding: 18px;
  color: rgba(225, 236, 244, 0.7);
  font-size: 14px;
  line-height: 1.5;
}

#shop-panel {
  position: fixed;
  top: 74px;
  z-index: 30;
  display: none;
  width: min(320px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%),
    var(--panel-bg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
}

#shop-panel {
  right: 18px;
}

#shop-panel.open {
  display: block;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  color: #f3fbff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.panel-subtitle {
  margin-top: 3px;
  color: rgba(228, 240, 248, 0.72);
  font-size: 13px;
}

.panel-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  font: inherit;
  cursor: pointer;
}

#log-shell {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--log-width), calc(100vw - 28px));
  z-index: 24;
  pointer-events: auto;
}

#log-drawer {
  display: flex;
  flex-direction: column;
  height: var(--log-height);
  overflow: hidden;
  border-radius: 0;
  font-family: "Courier New", ui-monospace, monospace;
  image-rendering: pixelated;
}

#log-shell.open #log-drawer {
  border: 3px solid #2b3a55;
  border-top: none;
  background: #0d1320;
  box-shadow: 0 0 0 2px #060a12, 8px 8px 0 rgba(0, 0, 0, 0.55);
}

#log-list {
  flex: 1 1 auto;
  min-height: 0;
  /* below the top corner buttons when they overlap the log (ui-dom.js) */
  margin-top: var(--log-clearance, 0px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 14px;
  scrollbar-gutter: stable;
}

#chat-entry {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 13, 20, 0.38);
  color: #edf7ff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

/* the chat box shows whenever the log is pulled down */
#log-shell.open #chat-entry,
#log-shell.chatting #chat-entry {
  display: flex;
}

#chat-entry {
  margin: 0;
  flex: none;
}

#chat-entry-prompt {
  color: #8ee7ff;
}

#chat-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: inherit;
  font: inherit;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

#chat-input::placeholder {
  color: rgba(237, 247, 255, 0.42);
}

#chat-input:focus {
  outline: 2px solid rgba(142, 231, 255, 0.6);
  outline-offset: 0;
}

#chat-send {
  flex: none;
  width: 38px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(142, 231, 255, 0.85);
  color: #07121b;
  font-size: 14px;
  cursor: pointer;
}

#log-tab {
  position: relative;
  width: 104px;
  height: 26px;
  margin: -1px auto 0;
  padding: 0;
  border: 3px solid #2b3a55;
  border-top: none;
  border-radius: 0;
  background: linear-gradient(#3b4e6f 0 50%, #2c3b55 50% 100%);
  display: block;
  box-shadow:
    inset 2px 2px 0 rgba(180, 200, 232, 0.35),
    inset -2px -2px 0 rgba(10, 14, 22, 0.55),
    0 0 0 2px #060a12,
    4px 4px 0 rgba(0, 0, 0, 0.5);
  cursor: ns-resize;
  appearance: none;
  touch-action: none;
  image-rendering: pixelated;
}

#log-tab::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 4px;
  height: 4px;
  transform: translateX(-50%);
  background: #e6eefb;
  box-shadow:
    -10px 0 0 #e6eefb,
    10px 0 0 #e6eefb,
    -14px 4px 0 #e6eefb,
    -6px 4px 0 #e6eefb,
    -10px 4px 0 #e6eefb,
    14px 4px 0 #e6eefb,
    6px 4px 0 #e6eefb,
    10px 4px 0 #e6eefb,
    0 4px 0 #e6eefb;
}

#log-tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 3px;
  height: 3px;
  background: #1a2335;
  box-shadow: 0 -2px 0 #4a608a;
}

.log-entry {
  --log-accent: #8ee7ff;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 10px;
  border-left: 4px solid var(--log-accent);
  border-radius: 0;
  background: #141a26;
  color: #eef7ff;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.log-entry-time {
  color: var(--log-accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.log-entry-line {
  min-width: 0;
  color: rgba(238, 247, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#gem-counter {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%),
    rgba(10, 15, 25, 0.84);
  color: #e8fbff;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  appearance: none;
}

#gem-counter i {
  color: #68efe3;
}

#gem-counter-icon {
  width: 22px;
  height: 22px;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4));
}

#gem-counter[aria-expanded="true"] {
  border-color: rgba(104, 239, 227, 0.44);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(104, 239, 227, 0.14);
}

.shop-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 52%),
    rgba(17, 24, 35, 0.82);
}

.shop-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.shop-card-title {
  color: #f3fbff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.shop-card-copy {
  margin-top: 5px;
  color: rgba(220, 233, 240, 0.72);
  font-size: 13px;
  line-height: 1.45;
}

.shop-price {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(104, 239, 227, 0.18);
  border-radius: 999px;
  background: rgba(104, 239, 227, 0.08);
  color: #dbfffb;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.shop-price i {
  color: #68efe3;
}

.shop-status {
  color: rgba(238, 246, 251, 0.78);
  font-size: 13px;
  line-height: 1.45;
}

.shop-action {
  padding: 12px 14px;
  border: 1px solid rgba(142, 231, 255, 0.2);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(196, 247, 255, 0.96), rgba(122, 224, 255, 0.9));
  color: #07121b;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(60, 177, 219, 0.18);
}

.shop-action:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

#inventory-shell {
  position: fixed;
  left: 50%;
  bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(-50%);
  width: min(var(--tray-width), calc(100vw - 12px));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  pointer-events: auto;
}

#hotbar,
#inventory-drawer {
  border: 3px solid #2b3a55;
  background: #121824;
  box-shadow: 0 0 0 2px #060a12, 8px 8px 0 rgba(0, 0, 0, 0.55);
  font-family: "Courier New", ui-monospace, monospace;
  image-rendering: pixelated;
}

#hotbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--slot-gap);
  padding: 14px;
  border-bottom: none;
  border-radius: 0;
}

#drawer-tab {
  position: relative;
  width: 104px;
  height: 26px;
  margin: 0 auto -1px;
  border: 3px solid #2b3a55;
  border-bottom: none;
  border-radius: 0;
  background: linear-gradient(#3b4e6f 0 50%, #2c3b55 50% 100%);
  box-shadow:
    inset 2px 2px 0 rgba(180, 200, 232, 0.35),
    inset -2px -2px 0 rgba(10, 14, 22, 0.55),
    0 0 0 2px #060a12,
    4px -4px 0 rgba(0, 0, 0, 0.5);
  cursor: ns-resize;
  touch-action: none;
  image-rendering: pixelated;
}

#drawer-tab::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 4px;
  height: 4px;
  transform: translateX(-50%);
  background: #e6eefb;
  box-shadow:
    -10px 0 0 #e6eefb,
    10px 0 0 #e6eefb,
    -14px -4px 0 #e6eefb,
    -6px -4px 0 #e6eefb,
    -10px -4px 0 #e6eefb,
    14px -4px 0 #e6eefb,
    6px -4px 0 #e6eefb,
    10px -4px 0 #e6eefb,
    0 -4px 0 #e6eefb;
}

#drawer-tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 3px;
  height: 3px;
  background: #1a2335;
  box-shadow: 0 2px 0 #4a608a;
}

#inventory-drawer {
  height: var(--drawer-height);
  overflow: hidden;
  border-top: none;
  border-radius: 0;
}

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--slot-gap);
  padding: 14px;
}

.slot {
  position: relative;
  min-height: 0;
  aspect-ratio: 1 / 1;
  border: 2px solid #3a4b6b;
  border-radius: 0;
  background: #1b2230;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.04), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #edf1f4;
  cursor: pointer;
  overflow: hidden;
  image-rendering: pixelated;
}

.slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: none;
  pointer-events: none;
}

.slot.hotbar.selected {
  border-color: #ffe066;
  box-shadow: 0 0 0 2px #c79a20, inset 2px 2px 0 rgba(255, 255, 255, 0.06), inset -2px -2px 0 rgba(0, 0, 0, 0.4);
}

.slot.empty {
  color: rgba(255, 255, 255, 0.28);
}

.slot.locked {
  cursor: default;
  color: rgba(255, 255, 255, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 45%),
    rgba(15, 18, 24, 0.88);
}

.slot.unavailable {
  opacity: 0.45;
}

.slot-content {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}

.slot-content.centered,
.slot-content.icon-only,
.slot-content.preview {
  align-items: center;
  justify-content: center;
  gap: 0;
}

.slot-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06)),
    var(--item-color, rgba(255, 255, 255, 0.16));
  color: #0f1723;
  font-size: 16px;
}

.slot-icon.plain {
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: #f06b62;
  font-size: 26px;
}

.lock-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.42);
  font-size: 14px;
}

.item-preview {
  display: block;
  width: 100%;
  height: 100%;
}

.count {
  position: absolute;
  right: 7px;
  bottom: 6px;
  z-index: 1;
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-strong);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

@media (max-width: 780px) {
  :root {
    --slot-gap: 8px;
    --tray-width: 100vw;
    --log-width: 100vw;
  }

  #world-menu {
    padding: 14px;
  }

  #world-menu-shell {
    width: calc(100vw - 20px);
    padding: 18px;
    border-radius: 22px;
  }

  .world-menu-title {
    font-size: 24px;
  }

  .world-menu-subtitle {
    font-size: 13px;
  }

  #world-search {
    font-size: 14px;
    padding: 12px 13px;
  }

  #world-list {
    max-height: min(380px, calc(100vh - 200px));
  }

  #shop-panel {
    top: 64px;
    right: 12px;
    width: min(320px, calc(100vw - 24px));
  }

  #hotbar,
  #inventory-grid {
    padding: 12px;
  }

  #drawer-tab {
    width: 96px;
  }

  #gem-counter {
    right: 12px;
    top: 12px;
    font-size: 15px;
  }

  #log-shell {
    width: calc(100vw - 14px);
  }

  #log-tab {
    width: 96px;
  }

  #log-list {
    padding: 10px 10px 12px;
  }

  #chat-entry {
    min-height: 42px;
    padding: 8px 10px 12px;
    font-size: 13px;
  }

  .log-entry {
    padding: 6px 9px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Night pixel UI. Applies while html has .pixel-style (set by
   engine/pixel-style.js; V switches back to the classic look above).

   Matches the website and the blocks: dark ink panels with notched pixel
   corners and the blocks' bevel (light top, dark bottom), Bricolage
   Grotesque for titles, IBM Plex Mono for labels and chat, gem cyan accents.
   Frames are box-shadows, so they never change the size of anything.
   ========================================================================== */

html.pixel-style {
  --px-ink: #f6f3ee;
  --px-dim: rgba(246, 243, 238, 0.68);
  --px-faint: rgba(246, 243, 238, 0.42);
  --px-gem: #68efe3;
  --px-gem-deep: #2bb3a8;
  --px-panel: rgba(10, 12, 18, 0.86);
  --px-line: #2a3242;
  --px-out: #04060a;
  --px-slot: #151a24;
  --px-font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --px-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  /* outline + inner line, offset sideways only, which leaves notched corners */
  --px-frame:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line),
    0 -2px 0 0 var(--px-line), 0 2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out),
    0 -4px 0 0 var(--px-out), 0 4px 0 0 var(--px-out),
    6px 8px 0 0 rgba(0, 0, 0, 0.35);
  --px-bevel: inset 0 2px 0 0 rgba(255, 255, 255, 0.06), inset 0 -3px 0 0 rgba(0, 0, 0, 0.38);
}

html.pixel-style,
html.pixel-style body {
  font-family: var(--px-font);
  background: #04060d;
}

/* ---------------------------------------------------------------- panels */

html.pixel-style #hotbar,
html.pixel-style #inventory-drawer,
html.pixel-style #log-shell.open #log-drawer,
html.pixel-style #shop-panel,
html.pixel-style #world-menu-shell {
  border: 0;
  border-radius: 0;
  background: var(--px-panel);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  font-family: var(--px-font);
}

/* the hotbar and the drawer below it read as one panel */
html.pixel-style #hotbar {
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line), 0 -2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out), 0 -4px 0 0 var(--px-out),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.06);
}

html.pixel-style #inventory-drawer {
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line), 0 2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out), 0 4px 0 0 var(--px-out);
}

html.pixel-style #log-shell.open #log-drawer {
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line), 0 2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out), 0 4px 0 0 var(--px-out),
    6px 8px 0 0 rgba(0, 0, 0, 0.35);
}

html.pixel-style #shop-panel,
html.pixel-style #world-menu-shell {
  box-shadow: var(--px-frame), var(--px-bevel);
}

/* ------------------------------------------------------------ drag tabs */

html.pixel-style #drawer-tab,
html.pixel-style #log-tab {
  border: 0;
  background: #10141c;
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07);
}

html.pixel-style #drawer-tab {
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line), 0 -2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out), 0 -4px 0 0 var(--px-out),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07);
}

html.pixel-style #log-tab {
  box-shadow:
    -2px 0 0 0 var(--px-line), 2px 0 0 0 var(--px-line), 0 2px 0 0 var(--px-line),
    -4px 0 0 0 var(--px-out), 4px 0 0 0 var(--px-out), 0 4px 0 0 var(--px-out),
    inset 0 -3px 0 0 rgba(0, 0, 0, 0.35);
}

/* the grip: two rows of pixel dots in gem cyan */
html.pixel-style #drawer-tab::before,
html.pixel-style #log-tab::before {
  background: var(--px-gem);
}

html.pixel-style #drawer-tab::before {
  box-shadow:
    -10px 0 0 var(--px-gem), 10px 0 0 var(--px-gem),
    -14px -4px 0 rgba(104, 239, 227, 0.45), -6px -4px 0 rgba(104, 239, 227, 0.45),
    -10px -4px 0 rgba(104, 239, 227, 0.45), 14px -4px 0 rgba(104, 239, 227, 0.45),
    6px -4px 0 rgba(104, 239, 227, 0.45), 10px -4px 0 rgba(104, 239, 227, 0.45),
    0 -4px 0 rgba(104, 239, 227, 0.45);
}

html.pixel-style #log-tab::before {
  box-shadow:
    -10px 0 0 var(--px-gem), 10px 0 0 var(--px-gem),
    -14px 4px 0 rgba(104, 239, 227, 0.45), -6px 4px 0 rgba(104, 239, 227, 0.45),
    -10px 4px 0 rgba(104, 239, 227, 0.45), 14px 4px 0 rgba(104, 239, 227, 0.45),
    6px 4px 0 rgba(104, 239, 227, 0.45), 10px 4px 0 rgba(104, 239, 227, 0.45),
    0 4px 0 rgba(104, 239, 227, 0.45);
}

html.pixel-style #drawer-tab::after,
html.pixel-style #log-tab::after {
  background: var(--px-out);
  box-shadow: none;
}

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

/* slots look like little empty block fronts */
html.pixel-style .slot {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow:
    0 0 0 2px var(--px-out),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07),
    inset 0 -3px 0 0 rgba(0, 0, 0, 0.42);
  color: var(--px-ink);
  transition: box-shadow 0.15s, transform 0.15s;
}

html.pixel-style .slot:hover {
  background: #1a2130;
}

html.pixel-style .slot.hotbar.selected {
  background: #18222c;
  box-shadow:
    0 0 0 2px var(--px-gem),
    0 0 0 4px var(--px-out),
    0 0 18px 2px rgba(104, 239, 227, 0.35),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.08),
    inset 0 -3px 0 0 rgba(0, 0, 0, 0.42);
  transform: translateY(-2px);
}

html.pixel-style .slot.locked {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0 4px, transparent 4px 8px),
    #0c0f15;
}

html.pixel-style .lock-icon {
  border-radius: 0;
  background: transparent;
  color: var(--px-faint);
}

html.pixel-style .item-preview,
html.pixel-style .slot-content canvas {
  image-rendering: pixelated;
}

/* counts and key numbers in a pixel font, outlined like game text */
html.pixel-style .count {
  right: 5px;
  bottom: 3px;
  font-family: "Silkscreen", var(--px-mono);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  color: var(--px-ink);
  text-shadow:
    2px 0 0 var(--px-out), -2px 0 0 var(--px-out), 0 2px 0 var(--px-out), 0 -2px 0 var(--px-out),
    2px 2px 0 var(--px-out);
}

.slot-key {
  display: none;
}

html.pixel-style .slot-key {
  display: block;
  position: absolute;
  top: 4px;
  left: 6px;
  z-index: 1;
  font-family: "Silkscreen", var(--px-mono);
  font-size: 9px;
  line-height: 1;
  color: var(--px-faint);
  pointer-events: none;
}

html.pixel-style .slot.hotbar.selected .slot-key {
  color: var(--px-gem);
}

/* pixel gem and lock in place of the icon-font glyphs */
html.pixel-style .shop-price i,
html.pixel-style .lock-icon i {
  display: inline-block;
  background: var(--px-gem-icon) center / contain no-repeat;
  image-rendering: pixelated;
}

html.pixel-style .shop-price i {
  width: 17px;
  height: 14px;
}

html.pixel-style .lock-icon i {
  width: 20px;
  height: 20px;
  background-image: var(--px-lock-icon);
  opacity: 0.7;
}

html.pixel-style .shop-price i::before,
html.pixel-style .lock-icon i::before {
  content: none;
}

/* ------------------------------------------------------- log and chat */

html.pixel-style #log-drawer,
html.pixel-style .log-entry,
html.pixel-style #chat-entry {
  font-family: var(--px-mono);
}

html.pixel-style .log-entry {
  border-left-width: 3px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 -2px 0 0 rgba(0, 0, 0, 0.3);
  color: var(--px-ink);
  font-size: 12.5px;
  font-weight: 500;
}

html.pixel-style .log-entry-time {
  font-weight: 500;
  letter-spacing: 0.04em;
}

html.pixel-style .log-entry-line {
  color: var(--px-dim);
}

html.pixel-style #chat-entry {
  border-top: 2px solid var(--px-line);
  background: rgba(4, 6, 10, 0.55);
  color: var(--px-ink);
  font-size: 13.5px;
  font-weight: 500;
}

html.pixel-style #chat-entry-prompt {
  color: var(--px-gem);
}

html.pixel-style #chat-input {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 2px 0 rgba(0, 0, 0, 0.35);
  color: var(--px-ink);
  font-family: var(--px-mono);
  caret-color: var(--px-gem);
}

html.pixel-style #chat-input::placeholder {
  color: var(--px-faint);
}

html.pixel-style #chat-input:focus {
  outline: 0;
  box-shadow: 0 0 0 2px var(--px-gem), inset 0 2px 0 rgba(0, 0, 0, 0.35);
}

html.pixel-style #chat-send {
  border-radius: 0;
  background: var(--px-gem);
  color: var(--px-out);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 3px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

html.pixel-style #chat-send:active {
  transform: translateY(2px);
}

/* --------------------------------------------------------- gem counter */

/* the website's gem pill */
html.pixel-style #gem-counter {
  padding: 8px 15px 8px 12px;
  border: 1px solid rgba(142, 231, 255, 0.25);
  background: rgba(16, 22, 34, 0.86);
  font-family: var(--px-font);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--px-ink);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

html.pixel-style #gem-counter[aria-expanded="true"] {
  border-color: var(--px-gem);
  box-shadow: 0 0 18px rgba(104, 239, 227, 0.35);
}

/* ----------------------------------------------------------------- shop */

html.pixel-style .panel-title,
html.pixel-style .world-menu-title {
  font-family: var(--px-font);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--px-ink);
}

html.pixel-style .panel-subtitle,
html.pixel-style .world-menu-subtitle {
  font-family: var(--px-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--px-faint);
}

html.pixel-style .panel-close {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 0 rgba(0, 0, 0, 0.4);
  color: var(--px-dim);
}

html.pixel-style .shop-card {
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 0 2px var(--px-out), var(--px-bevel);
}

html.pixel-style .shop-card-title {
  font-family: var(--px-font);
  font-weight: 700;
  letter-spacing: -0.01em;
}

html.pixel-style .shop-card-copy,
html.pixel-style .shop-status {
  color: var(--px-dim);
}

html.pixel-style .shop-price {
  border: 0;
  border-radius: 0;
  background: rgba(104, 239, 227, 0.1);
  box-shadow: 0 0 0 2px rgba(104, 239, 227, 0.35);
  font-family: var(--px-mono);
  font-weight: 500;
  color: var(--px-gem);
}

/* a chunky gem-coloured button with the blocks' bevel */
html.pixel-style .shop-action {
  border: 0;
  border-radius: 0;
  background: var(--px-gem);
  color: var(--px-out);
  font-family: var(--px-font);
  font-weight: 800;
  letter-spacing: 0;
  box-shadow:
    0 0 0 2px var(--px-out),
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    inset 0 -4px 0 rgba(0, 0, 0, 0.22),
    0 0 20px rgba(104, 239, 227, 0.3);
}

html.pixel-style .shop-action:hover:not(:disabled) {
  background: #8af5ec;
}

html.pixel-style .shop-action:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 3px 0 rgba(0, 0, 0, 0.18);
}

/* ----------------------------------------------------------- world menu */

html.pixel-style #world-menu {
  background: rgba(4, 6, 13, 0.45);
}

html.pixel-style #world-search {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 3px 0 rgba(0, 0, 0, 0.35);
  color: var(--px-ink);
  font-family: var(--px-mono);
}

html.pixel-style #world-search:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--px-gem), 0 0 0 4px var(--px-out), inset 0 3px 0 rgba(0, 0, 0, 0.35);
}

html.pixel-style .world-card {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow: 0 0 0 2px var(--px-out), var(--px-bevel);
}

html.pixel-style .world-card:hover,
html.pixel-style .world-card:focus-visible {
  box-shadow: 0 0 0 2px var(--px-gem), 0 0 0 4px var(--px-out), var(--px-bevel);
}

html.pixel-style .world-card-name {
  font-family: var(--px-font);
  font-weight: 700;
}

html.pixel-style .world-card-meta {
  font-family: var(--px-mono);
  font-size: 12px;
  color: var(--px-faint);
}

/* ==========================================================================
   Character creator (engine/character.js) and the top-left button that
   opens it. Same night pixel look: ink panels with notched frames, gem cyan.
   ========================================================================== */

#character-button {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 30;
  width: 50px;
  height: 50px;
  padding: 4px;
  border: 0;
  border-radius: 0;
  background: rgba(16, 22, 34, 0.86);
  box-shadow:
    -2px 0 0 0 #2a3242, 2px 0 0 0 #2a3242, 0 -2px 0 0 #2a3242, 0 2px 0 0 #2a3242,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 0 rgba(0, 0, 0, 0.38);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#character-button:hover,
#character-button:focus-visible {
  outline: none;
  background: #1a2130;
  box-shadow:
    -2px 0 0 0 #68efe3, 2px 0 0 0 #68efe3, 0 -2px 0 0 #68efe3, 0 2px 0 0 #68efe3,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    0 0 18px rgba(104, 239, 227, 0.3);
}

#character-button img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

body.world-select #character-button,
body.character-select #character-button,
body.character-select #log-shell,
body.character-select #gem-counter,
body.character-select #shop-panel,
body.character-select #inventory-shell {
  display: none;
}

#character-menu {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 13, 0.42);
}

body.character-select #character-menu {
  display: flex;
}

#character-shell {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 22px;
  width: min(900px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 22px;
  background: rgba(10, 12, 18, 0.9);
  color: #f6f3ee;
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, sans-serif;
  box-shadow:
    -2px 0 0 0 #2a3242, 2px 0 0 0 #2a3242, 0 -2px 0 0 #2a3242, 0 2px 0 0 #2a3242,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    6px 8px 0 0 rgba(0, 0, 0, 0.35),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.06), inset 0 -3px 0 0 rgba(0, 0, 0, 0.38);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
}

.cc-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

#character-preview {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 300px;
  background:
    linear-gradient(180deg, #0b1424 0%, #142440 62%, #1b2f4f 100%);
  box-shadow: 0 0 0 2px #04060a, inset 0 2px 0 rgba(255, 255, 255, 0.05);
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: none;
}

.cc-preview-hint {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(246, 243, 238, 0.42);
  text-align: center;
}

.cc-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.cc-heading .world-menu-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.cc-heading .world-menu-subtitle {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(246, 243, 238, 0.42);
}

.cc-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 6px 4px 4px;
}

.cc-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 0 2px #04060a, inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.cc-label {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(246, 243, 238, 0.68);
}

.cc-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.cc-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cc-step {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #151a24;
  box-shadow: 0 0 0 2px #04060a, inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 0 rgba(0, 0, 0, 0.4);
  color: #68efe3;
  font-family: "Silkscreen", "IBM Plex Mono", monospace;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.cc-step:hover,
.cc-step:focus-visible {
  outline: none;
  background: #1d2533;
}

.cc-step:active {
  transform: translateY(1px);
}

.cc-value {
  min-width: 112px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}

.cc-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 180px;
  min-width: 160px;
}

/* A colour bar: the gradient is the track, the thumb a chunky pixel tab */
.cc-bar {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--track, #333);
  box-shadow: 0 0 0 2px #04060a, inset 0 2px 0 rgba(255, 255, 255, 0.18), inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  cursor: pointer;
  touch-action: none;
}

.cc-bar.cc-shade {
  height: 10px;
}

.cc-bar:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #68efe3, 0 0 0 4px #04060a;
}

.cc-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: #f6f3ee;
  box-shadow: 0 0 0 2px #04060a, inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.cc-bar.cc-shade::-webkit-slider-thumb {
  height: 18px;
}

.cc-bar::-moz-range-thumb {
  width: 10px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: #f6f3ee;
  box-shadow: 0 0 0 2px #04060a, inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.cc-bar.cc-shade::-moz-range-thumb {
  height: 18px;
}

.cc-bar::-moz-range-track {
  background: transparent;
}

.cc-row.muted .cc-bars {
  opacity: 0.35;
}

.cc-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 4px;
}

.cc-button {
  padding: 11px 18px;
  border: 0;
  border-radius: 0;
  background: #151a24;
  box-shadow: 0 0 0 2px #04060a, inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 rgba(0, 0, 0, 0.42);
  color: #f6f3ee;
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.cc-button:hover,
.cc-button:focus-visible {
  outline: none;
  background: #1d2533;
}

.cc-button[hidden] {
  display: none;
}

.cc-button.cc-play {
  min-width: 110px;
  background: #68efe3;
  color: #04060a;
  font-weight: 800;
  box-shadow:
    0 0 0 2px #04060a,
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    inset 0 -4px 0 rgba(0, 0, 0, 0.22),
    0 0 20px rgba(104, 239, 227, 0.3);
}

.cc-button.cc-play:hover,
.cc-button.cc-play:focus-visible {
  background: #8af5ec;
}

.cc-button:active {
  transform: translateY(2px);
}

@media (max-width: 720px) {
  #character-menu {
    padding: 10px;
  }

  #character-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 14px;
  }

  #character-preview {
    min-height: 0;
    height: 30vh;
  }

  .cc-preview-hint {
    display: none;
  }

  .cc-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .cc-value {
    min-width: 92px;
  }

  #character-button {
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
  }
}

/* -------------------------------------------- shop tools and equipping */

.shop-card + .shop-card {
  margin-top: 12px;
}

.slot.tool {
  cursor: pointer;
}

/* the equipped tool: a gem ring and a little E */
.slot.equipped,
html.pixel-style .slot.equipped {
  box-shadow:
    0 0 0 2px #68efe3,
    0 0 0 4px #04060a,
    0 0 14px 2px rgba(104, 239, 227, 0.3),
    inset 0 2px 0 0 rgba(255, 255, 255, 0.08),
    inset 0 -3px 0 0 rgba(0, 0, 0, 0.42);
}

.equip-badge {
  position: absolute;
  top: 3px;
  right: 5px;
  z-index: 1;
  font-family: "Silkscreen", "IBM Plex Mono", monospace;
  font-size: 10px;
  line-height: 1;
  color: #68efe3;
  text-shadow: 1px 1px 0 #04060a, -1px 0 0 #04060a, 0 -1px 0 #04060a;
  pointer-events: none;
}

/* the creator's preview: a shorter box so the figure fills it */
.cc-preview-wrap {
  align-self: start;
}

#character-preview {
  flex: none;
  min-height: 0;
  aspect-ratio: 3 / 4;
}

/* ----------------------------------- the wrench's popup, more shop cards */

/* four cards don't fit on a short screen */
#shop-panel {
  max-height: calc(100vh - 92px);
  overflow-y: auto;
}

#tile-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 40;
  display: none;
  width: min(360px, calc(100vw - 36px));
  padding: 16px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: var(--panel-bg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.36);
}

#tile-panel.open {
  display: block;
}

/* the Play together panel can be taller than a phone held sideways */
#tile-panel {
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

body.world-select #tile-panel,
body.character-select #tile-panel {
  display: none;
}

#tile-panel-body {
  display: grid;
  gap: 10px;
}

.tile-field {
  display: grid;
  gap: 6px;
}

.tile-field-label {
  color: #f3fbff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tile-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: #f3fbff;
  font: inherit;
  font-size: 14px;
}

.tile-input:focus {
  outline: 2px solid rgba(104, 239, 227, 0.6);
  outline-offset: 1px;
}

.tile-hint,
.tile-status {
  margin: 0;
  color: rgba(220, 233, 240, 0.72);
  font-size: 12.5px;
  line-height: 1.45;
}

.tile-hint b {
  color: #f3fbff;
  font-weight: 700;
}

.tile-error {
  margin: 0;
  min-height: 1em;
  color: #ff9a8a;
  font-size: 12.5px;
}

.tile-error:empty {
  display: none;
}

.tile-action.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #f3fbff;
}

html.pixel-style #tile-panel {
  border: 0;
  border-radius: 0;
  background: var(--px-panel);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: var(--px-frame), var(--px-bevel);
  font-family: var(--px-font);
}

html.pixel-style .tile-field-label {
  font-family: var(--px-mono);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--px-faint);
}

html.pixel-style .tile-input {
  border: 0;
  border-radius: 0;
  background: var(--px-slot);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 2px 0 rgba(0, 0, 0, 0.35);
  color: var(--px-ink);
  font-family: var(--px-mono);
}

html.pixel-style .tile-input:focus {
  outline: 0;
  box-shadow: 0 0 0 2px var(--px-gem), inset 0 2px 0 rgba(0, 0, 0, 0.35);
}

html.pixel-style .tile-hint,
html.pixel-style .tile-status {
  color: var(--px-dim);
}

html.pixel-style .tile-hint b {
  color: var(--px-ink);
  font-family: var(--px-mono);
  font-weight: 500;
}

html.pixel-style .tile-action.secondary {
  background: var(--px-slot);
  color: var(--px-ink);
  box-shadow: 0 0 0 2px var(--px-out), inset 0 3px 0 rgba(255, 255, 255, 0.08), inset 0 -4px 0 rgba(0, 0, 0, 0.3);
}

html.pixel-style .tile-action.secondary:hover:not(:disabled) {
  background: #222a38;
}

/* ==========================================================================
   Play together (engine/net.js): the button beside the character button,
   its panel (which reuses #tile-panel), and online worlds in the world menu.
   ========================================================================== */

#net-button {
  position: fixed;
  top: 18px;
  left: 82px;
  z-index: 30;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(16, 22, 34, 0.86);
  box-shadow:
    -2px 0 0 0 #2a3242, 2px 0 0 0 #2a3242, 0 -2px 0 0 #2a3242, 0 2px 0 0 #2a3242,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 0 rgba(0, 0, 0, 0.38);
  color: rgba(246, 243, 238, 0.82);
  font-size: 19px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#net-button:hover,
#net-button:focus-visible,
#net-button.online {
  outline: none;
  background: #1a2130;
  color: #68efe3;
  box-shadow:
    -2px 0 0 0 #68efe3, 2px 0 0 0 #68efe3, 0 -2px 0 0 #68efe3, 0 2px 0 0 #68efe3,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    0 0 18px rgba(104, 239, 227, 0.3);
}

#net-button.busy i {
  animation: net-blink 0.9s steps(2, end) infinite;
}

@keyframes net-blink {
  50% { opacity: 0.35; }
}

/* how many players are in the world, you included */
#net-badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  min-width: 18px;
  padding: 2px 4px;
  background: #68efe3;
  color: #04060a;
  font-family: "Silkscreen", "IBM Plex Mono", monospace;
  font-size: 10px;
  line-height: 14px;
  box-shadow: 0 0 0 2px #04060a;
}

#net-badge[hidden] {
  display: none;
}

body.world-select #net-button,
body.character-select #net-button {
  display: none;
}

.net-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f3fbff;
  font-size: 14px;
  cursor: pointer;
}

.net-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #68efe3;
}

.net-players {
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
}

.net-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
}

.net-player-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #f3fbff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.net-player .tile-action {
  padding: 6px 10px;
  font-size: 12px;
}

.world-online {
  display: grid;
  gap: 12px;
}

.world-online-title {
  margin-top: 4px;
  color: #68efe3;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html.pixel-style .world-online-title,
html.pixel-style .net-player-name,
html.pixel-style .net-check {
  font-family: var(--px-mono);
}

html.pixel-style .net-player {
  box-shadow: 0 0 0 2px var(--px-out);
}

@media (max-width: 720px) {
  #net-button {
    top: 12px;
    left: 68px;
    width: 44px;
    height: 44px;
  }
}

/* a text field with its button beside it (World name, Find a world) */
.net-inline {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.net-inline .tile-field {
  flex: 1 1 auto;
  min-width: 0;
}

.net-inline .tile-action {
  flex: none;
  padding-left: 16px;
  padding-right: 16px;
  height: 42px;
}

/* worlds found by name in the Play together panel */
.net-found {
  display: grid;
  gap: 8px;
}

.net-found .tile-action {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Touch controls (engine/touch-controls.js): walk and jump buttons on
   phones and tablets. JS puts them beside the hotbar when there's room, or
   just above it (--touch-bottom) when there isn't.
   ========================================================================== */

#touch-controls {
  --touch-size: 66px;
  --touch-bottom: 140px;
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--touch-bottom);
  z-index: 22;
  padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

#touch-controls.beside {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

body.touch-ui #touch-controls {
  display: flex;
}

body.world-select #touch-controls,
body.character-select #touch-controls {
  display: none;
}

#touch-move {
  display: flex;
  gap: 10px;
  pointer-events: auto;
  touch-action: none;
}

.touch-button {
  width: var(--touch-size);
  height: var(--touch-size);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(16, 22, 34, 0.62);
  box-shadow:
    -2px 0 0 0 #2a3242, 2px 0 0 0 #2a3242, 0 -2px 0 0 #2a3242, 0 2px 0 0 #2a3242,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    inset 0 2px 0 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 0 rgba(0, 0, 0, 0.38);
  color: rgba(246, 243, 238, 0.86);
  font-size: 34px;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* the buttons inside #touch-move pass touches up to it */
#touch-move .touch-button {
  pointer-events: none;
}

#touch-jump {
  --touch-size: 76px;
}

.touch-button.pressed {
  background: rgba(26, 33, 48, 0.9);
  color: #68efe3;
  transform: translateY(2px);
  box-shadow:
    -2px 0 0 0 #68efe3, 2px 0 0 0 #68efe3, 0 -2px 0 0 #68efe3, 0 2px 0 0 #68efe3,
    -4px 0 0 0 #04060a, 4px 0 0 0 #04060a, 0 -4px 0 0 #04060a, 0 4px 0 0 #04060a,
    0 0 18px rgba(104, 239, 227, 0.3);
}

@media (max-width: 380px) {
  #touch-controls {
    --touch-size: 58px;
  }

  #touch-jump {
    --touch-size: 66px;
  }
}

/* iPhones zoom into any text field smaller than 16px when it's tapped */
@media (pointer: coarse) {
  #chat-input,
  .tile-input,
  #world-search {
    font-size: 16px;
  }
}
