:root {
  --ink: #14110e;
  --paper: #efe6d6;
  --copper: #c46a32;
  --mute: #8a7d6c;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, textarea { user-select: text; -webkit-user-select: text; }

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--paper);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(239, 230, 214, 0.12);
  flex-shrink: 0;
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 20px;
  color: var(--paper);
  text-decoration: none;
}

.who-wrap { display: flex; align-items: center; gap: 12px; font-size: 13px; }
#who { color: var(--copper); }
#save-note { color: #9dcc8a; min-width: 5ch; }
.top nav { display: flex; gap: 14px; font-size: 14px; }
.top nav a { color: var(--paper); text-decoration: none; }
.top nav a:hover, .top nav a.is-here { color: var(--copper); }

.updates {
  display: none;
}

.updates-grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 2px;
}

.updates-grid b {
  display: grid;
  place-items: center;
  min-height: 18px;
  font-size: 10px;
  font-weight: 500;
  color: var(--mute);
  background: rgba(239, 230, 214, 0.06);
}

.updates-grid b.is-done {
  background: var(--copper);
  color: #fffdf8;
}

.updates-count {
  margin-top: 6px;
  font-size: 12px;
  color: var(--paper);
  text-align: center;
}

.stage {
  flex: 1;
  position: relative;
  min-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  outline: none;
  background: #6ea8d4;
  touch-action: none;
}

.menu {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: #5b3a22;
  background-image:
    linear-gradient(rgba(0,0,0,0.35), rgba(0,0,0,0.55)),
    repeating-linear-gradient(90deg, #6b4423 0 16px, #5a381c 16px 32px),
    repeating-linear-gradient(0deg, #4a2c14 0 16px, #3d2410 16px 32px);
  image-rendering: pixelated;
  z-index: 20;
  padding: 20px;
  touch-action: auto;
  font-family: "Press Start 2P", ui-monospace, monospace;
}

.menu.is-hidden, .inv-panel.is-hidden, .hud.is-hidden, .is-hidden { display: none !important; }

#hud-coords {
  position: absolute;
  top: 8px;
  left: 10px;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 8px;
  line-height: 1.7;
  color: #cfcfcf;
  text-shadow: 2px 2px #000;
  pointer-events: none;
  z-index: 5;
}
#gm-pick { z-index: 30; background: rgba(0,0,0,0.55); }

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  font-family: "Press Start 2P", ui-monospace, monospace;
  color: #fff;
}
.boot-splash.is-hidden { display: none; }
.boot-dirt {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background:
    repeating-linear-gradient(90deg, #6b4423 0 32px, #5a381c 32px 64px),
    repeating-linear-gradient(0deg, #4a2c14 0 32px, #3d2410 32px 64px);
  image-rendering: pixelated;
}
.boot-mark, .boot-title, .boot-sub, .boot-bar { position: relative; }
.boot-mark { font-size: 10px; color: #c8c8c8; margin-bottom: 32px; letter-spacing: 3px; }
.boot-title {
  font-size: clamp(28px, 8vw, 52px);
  color: #5adc32;
  text-shadow: 5px 5px #14380c, -1px -1px #000;
  margin: 0 0 14px;
  letter-spacing: 3px;
}
.boot-sub { color: #ffff55; font-size: 10px; text-shadow: 2px 2px #3f3f00; margin: 0 0 42px; }
.boot-bar {
  width: min(280px, 72vw);
  height: 16px;
  border: 3px solid #fff;
  background: #111;
  box-shadow: 0 0 0 2px #000;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(#8adc4a, #3a8a20);
}
.menu:not(.is-hidden) ~ .touch { display: none !important; }

.mc-panel {
  width: min(460px, 100%);
  text-align: center;
  color: #fff;
}
.mc-panel.wide { width: min(560px, 100%); }
.mc-edition {
  color: #ffff55;
  font-size: 10px;
  text-shadow: 2px 2px #3f3f00;
  transform: rotate(-12deg);
  margin: 0 0 8px auto;
  width: max-content;
}
.mc-title {
  font-size: clamp(22px, 6vw, 42px);
  color: #5adc32;
  text-shadow: 4px 4px #1b3d10, -1px -1px #000;
  margin: 0 0 28px;
  letter-spacing: 2px;
}
.mc-heading {
  font-size: 14px;
  color: #fff;
  text-shadow: 2px 2px #000;
  margin: 0 0 18px;
}
.mc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 6px 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 10px;
  color: #fff;
  text-shadow: 2px 2px #3f3f3f;
  background: linear-gradient(#8b8b8b, #6f6f6f);
  border: 3px solid #000;
  box-shadow: inset 0 3px 0 #c6c6c6, inset 0 -3px 0 #3f3f3f;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.mc-btn kbd, .mini-btn kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  font: inherit;
  font-size: 8px;
  color: #111;
  background: #ececec;
  border: 2px solid #222;
  box-shadow: inset 0 -2px 0 #9a9a9a;
  text-shadow: none;
}
.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 8px;
  color: #fff;
  background: linear-gradient(#8b8b8b, #6f6f6f);
  border: 2px solid #000;
  pointer-events: auto;
  cursor: pointer;
}
.desk-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  pointer-events: auto;
}
.mc-panel input.is-ok { border-color: #6adc50; }
.mc-panel input.is-bad { border-color: #ff5555; }
.help-card { text-align: left; }
.help-grid {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 9px;
  line-height: 1.6;
  color: #eee;
  text-shadow: 2px 2px #000;
}
.help-grid kbd {
  display: inline-block;
  min-width: 18px;
  padding: 2px 4px;
  margin-right: 4px;
  font: inherit;
  font-size: 8px;
  color: #111;
  background: #ececec;
  border: 2px solid #111;
}
.mc-btn:hover { background: linear-gradient(#78c850, #4a8a30); }
.mc-btn.ghost { background: linear-gradient(#6b6b6b, #4a4a4a); }
.mc-btn.small { width: auto; padding: 10px 12px; margin: 0; }
.mc-panel label {
  display: block;
  text-align: left;
  font-size: 10px;
  line-height: 1.6;
  margin: 10px 0;
  color: #e0e0e0;
  text-shadow: 2px 2px #000;
}
.mc-panel input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font: inherit;
  font-size: 10px;
  color: #fff;
  background: #000;
  border: 2px solid #a0a0a0;
}
.mc-search { display: flex; gap: 8px; margin-bottom: 10px; }
.mc-search input { flex: 1; }
.mc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  max-height: 260px;
  overflow: auto;
  background: rgba(0,0,0,0.45);
  border: 2px solid #000;
  padding: 6px;
  text-align: left;
}
.mc-server, .world-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 10px;
  padding: 10px;
  color: #fff;
  text-shadow: 2px 2px #000;
  background: #5a5a5a;
  border: 2px solid #000;
  cursor: pointer;
  text-align: left;
}
.mc-server:hover, .world-btn:hover { background: #6e8a4a; }
.mc-server .count { color: #a0ffa0; white-space: nowrap; flex-shrink: 0; }
.mc-server .mode { color: #ffe08a; }
.view-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 10px;
}
.view-opt { width: 100%; margin: 0; }
.view-opt.is-on { background: linear-gradient(#78c850, #4a8a30); }
.mc-btn.is-locked,
.mc-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.mc-btn:disabled:hover { background: linear-gradient(#8b8b8b, #6f6f6f); }
.menu .tiny { color: #c8c8c8; text-shadow: 2px 2px #000; }

.splash-card, .inv-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, var(--paper), #e4d8c4);
  color: var(--ink);
  padding: 28px 24px 22px;
  border-radius: 8px;
}
.splash-card { text-align: center; }
.inv-card { width: min(640px, 100%); }
.splash-card.wide { width: min(480px, 100%); }
.splash-card label { display: block; text-align: left; font-size: 13px; margin: 10px 0; }
.splash-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  font: inherit;
  border: 1px solid rgba(20, 17, 14, 0.2);
  background: #fffdf8;
}

.logo {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  position: relative;
  image-rendering: pixelated;
}
.logo-grass, .logo-dirt {
  position: absolute;
  left: 18px;
  width: 60px;
  height: 30px;
}
.logo-grass { top: 18px; background: #5b9a3c; box-shadow: inset 0 -8px 0 #3d6b24; }
.logo-dirt { top: 48px; background: #8b5a32; }
.logo-pick {
  position: absolute;
  right: 10px;
  top: 22px;
  width: 10px;
  height: 54px;
  background: #c48a48;
  transform: rotate(-28deg);
  border-radius: 2px;
}
.logo-pick::before {
  content: "";
  position: absolute;
  top: -8px;
  left: -10px;
  width: 30px;
  height: 14px;
  background: #9aa0a6;
}

.menu-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font: inherit;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
}
.menu-btn.ghost { background: transparent; color: var(--ink); border: 1px solid rgba(20,17,14,0.2); }
.menu-btn.is-locked { opacity: 0.45; cursor: not-allowed; }

.world-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; max-height: 240px; overflow: auto; }
.world-btn {
  font: inherit;
  padding: 12px;
  text-align: left;
  background: #fffdf8;
  border: 1px solid rgba(20,17,14,0.12);
  cursor: pointer;
}

.inv-split { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.craft-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.craft-label { font-size: 12px; color: var(--mute); }
.craft-grid { display: grid; gap: 4px; }
.craft-grid.g2 { grid-template-columns: repeat(2, 44px); }
.craft-grid.g3 { grid-template-columns: repeat(3, 44px); }
.slot.result { border-color: var(--copper); }

.kicker, .tiny { font-size: 12px; color: var(--mute); }
.splash-card h1, .inv-card h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 420;
  margin: 6px 0 10px;
}
.error { color: #a33; min-height: 1.2em; margin-top: 8px; font-size: 13px; }

.hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 12px 20px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(20, 17, 14, 0.72) 55%);
  z-index: 6;
  overflow: visible;
}

.bars, .status {
  max-width: 420px;
  margin: 0 auto 8px;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
#hunger, #air-bar { justify-content: flex-end; margin-left: auto; }
#armor-bar { margin-bottom: 2px; min-height: 16px; }
.bar { display: flex; gap: 3px; font-size: 16px; letter-spacing: 1px; }
.xp-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.xp-wrap span {
  font-size: 11px;
  color: #8ae05a;
  min-width: 14px;
}
.xp-bar {
  width: 120px;
  height: 6px;
  background: #1a2010;
  border: 1px solid #3a4a20;
  position: relative;
}
#xp-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6ad040, #c8f070);
}
.recipe-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #3a3228;
}
.heart { color: #c44; text-shadow: 0 1px 0 #000; }
.heart.is-empty { color: #5a2a2a; }
.food { color: #c47a32; text-shadow: 0 1px 0 #000; }
.food.is-empty { color: #4a3424; }
.air { color: #7ec8e8; text-shadow: 0 1px 0 #000; }
.air.is-empty { color: #2a4450; opacity: 0.35; }
#air-bar { margin-top: 4px; }
.armor { color: #c8c8d0; text-shadow: 0 1px 0 #000; font-size: 14px; }
.armor.is-empty { color: #3a3a40; }

.hotbar {
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: auto;
  overflow: visible;
  padding: 6px 0;
}

.slot {
  width: 44px;
  height: 44px;
  border: 2px solid #3a332c;
  background: rgba(20, 17, 14, 0.78);
  position: relative;
}

.slot.is-selected,
.hotbar .slot.is-selected {
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px #14110e, 0 0 10px rgba(255, 255, 255, 0.45);
  z-index: 2;
}

.slot.is-drop {
  border-color: #f2e6c9;
  box-shadow: 0 0 0 2px #c48a48;
}

.drag-ghost {
  position: fixed;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  pointer-events: none;
  z-index: 80;
  border: 2px solid #f2e6c9;
  background: rgba(20, 17, 14, 0.9);
}

.slot .swatch {
  position: absolute;
  inset: 2px;
}

.slot .swatch.icon {
  display: grid;
  place-items: center;
  font-size: 18px;
  inset: 2px;
}

.slot .swatch.gfx,
.slot svg.swatch,
.slot img.iso-item {
  inset: 2px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.slot .count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 0 #000;
}

.slot .dur {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 2px;
  height: 3px;
  background: #7dcc6a;
}

.hint {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--mute);
}

body.is-touch .touch { display: block; }
#login:not(.is-hidden) ~ .touch, .menu:not(.is-hidden) ~ .touch { display: none !important; }

.touch {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}

.stick, .stick-aim {
  text-align: center;
  touch-action: none;
  pointer-events: auto;
}

#stick-move {
  position: absolute;
  bottom: 24px;
  left: 12px;
  width: 118px;
}

.stick-aim, .stick-label, .aim-cluster, .touch-top { display: none !important; }

.touch-actions {
  pointer-events: auto;
  position: absolute;
  right: 10px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 132px;
}

.touch button {
  background: rgba(20, 17, 14, 0.72);
  color: var(--paper);
  border: 1px solid rgba(239, 230, 214, 0.28);
  padding: 8px 6px;
  min-width: 0;
  font-size: 11px;
  border-radius: 8px;
  touch-action: manipulation;
}

#btn-mode-break.is-on { background: rgba(160, 40, 28, 0.92); }
#btn-mode-place.is-on { background: rgba(40, 110, 50, 0.92); }

.base {
  width: 104px;
  height: 104px;
  margin: 0 auto;
  border-radius: 50%;
  background: rgba(20, 17, 14, 0.35);
  border: 2px solid rgba(239, 230, 214, 0.25);
  position: relative;
  touch-action: none;
}

.knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 230, 214, 0.85);
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -24px 0 0 -24px;
  pointer-events: none;
}

.touch-top {
  display: none;
}

#btn-jump {
  grid-column: 1 / -1;
  min-height: 48px;
}

.aim-cluster {
  display: none;
}

.inv-panel {
  position: absolute;
  inset: 0;
  background: rgba(20, 17, 14, 0.72);
  display: grid;
  place-items: center;
  z-index: 8;
  padding: 16px;
  touch-action: auto;
}

.inv-card { width: min(520px, 100%); }
.inv-card header { display: flex; justify-content: space-between; align-items: center; }
.inv-card header button { background: transparent; color: var(--ink); text-decoration: underline; }
.inv-held { font-size: 13px; margin: 8px 0 12px; color: #4a4036; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 44px);
  gap: 4px;
  justify-content: center;
  margin-bottom: 16px;
}
.creative-palette {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 4px 0;
}
.inv-card h3 { font-size: 14px; margin-bottom: 8px; }
.inv-recipes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.craft-btn {
  text-align: left;
  padding: 8px 10px;
  background: #fffdf8;
  border: 1px solid rgba(20, 17, 14, 0.12);
  color: var(--ink);
}

.help-phone { display: none; }

@media (pointer: coarse), (max-width: 900px) {
  .touch { display: block; }
  body.is-touch .touch { display: block; }
  .hint, .desk-actions, .mc-btn kbd, .mini-btn kbd, .help-desk { display: none; }
  .help-phone { display: grid; }
  .top nav { display: none; }
  .slot { width: 36px; height: 36px; }
  .inv-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; }
  .craft-grid.g2 { grid-template-columns: repeat(2, minmax(36px, 1fr)); }
  .craft-grid.g3 { grid-template-columns: repeat(3, minmax(36px, 1fr)); }
  .mc-btn { padding: 12px 8px; font-size: 11px; margin: 6px 0; min-height: 48px; }
  .mc-panel input {
    min-height: 44px;
    font-size: 16px;
    padding: 10px;
  }
  .mc-list { max-height: 42vh; }
  .menu {
    align-items: start;
    overflow: auto;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .menu .mc-panel { margin: auto 0; }
  .inv-panel {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  .inv-card {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 12px;
  }
  .inv-split { flex-direction: column; gap: 10px; }
  .hud {
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    background: none;
    pointer-events: none;
  }
  .hud-top {
    padding: calc(6px + env(safe-area-inset-top)) 8px 10px;
    background: linear-gradient(180deg, rgba(20, 17, 14, 0.78), transparent);
  }
  .hud-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    background: none;
  }
  .status, .bars {
    max-width: none;
    margin: 0 auto 4px;
    scale: 0.92;
    transform-origin: center bottom;
  }
  .xp-bar { width: 90px; }
  .hotbar {
    gap: 3px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px env(safe-area-inset-bottom, 0px);
    -webkit-overflow-scrolling: touch;
    background: #000000dd;
    border-top: 3px solid #111;
  }
  .hotbar .slot { flex: 0 0 42px; width: 42px; height: 42px; }
  #stick-move {
    width: 128px;
    left: max(8px, env(safe-area-inset-left));
    bottom: max(56px, calc(48px + env(safe-area-inset-bottom)));
    z-index: 8;
  }
  .base { width: 112px; height: 112px; }
  .knob { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
  .touch-actions {
    width: 156px;
    right: max(8px, env(safe-area-inset-right));
    bottom: max(56px, calc(48px + env(safe-area-inset-bottom)));
    gap: 8px;
    z-index: 8;
  }
  .touch button {
    padding: 8px 6px;
    font-size: 12px;
    min-height: 40px;
    border-radius: 10px;
    font-weight: 600;
  }
  .touch-big {
    min-height: 52px;
    font-size: 13px;
  }
  body.is-playing .top { display: none !important; }
}

body.is-playing { touch-action: none; }

@media (max-width: 640px) and (orientation: portrait) {
  .status, .bars { scale: 0.82; }
  .hotbar .slot { flex: 0 0 32px; width: 32px; height: 32px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .hud-bottom {
    left: 0;
    right: 0;
    bottom: 0;
  }
  #stick-move { width: 96px; bottom: max(50px, calc(42px + env(safe-area-inset-bottom))); }
  .base { width: 84px; height: 84px; }
  .touch-actions { width: 140px; bottom: max(50px, calc(42px + env(safe-area-inset-bottom))); }
  .touch-big { min-height: 46px; }
  .touch button { min-height: 36px; padding: 6px; }
  body.is-playing .top { display: none !important; }
}

.furnace-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.furnace-row { display: flex; align-items: center; gap: 10px; }
.furnace-arrow {
  width: 48px;
  height: 10px;
  background: #3a332c;
  position: relative;
}
.furnace-arrow span {
  display: block;
  height: 100%;
  width: 0;
  background: #e0a030;
}
.furnace-fuel-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.furnace-fire {
  width: 16px;
  height: 28px;
  background: #2a2018;
  display: flex;
  align-items: flex-end;
}
.furnace-fire span {
  display: block;
  width: 100%;
  height: 0;
  background: linear-gradient(#ffe56a, #ff7a18);
}

.menu .error { color: #ff5555; min-height: 1.2em; text-shadow: 2px 2px #000; }

.pe-create {
  width: min(980px, 100%);
  max-height: 100%;
  overflow: auto;
  background: #2b2b2b;
  border: 3px solid #111;
  color: #eee;
  font-family: "Press Start 2P", monospace;
}
.pe-create-head {
  display: flex; align-items: center; gap: 12px;
  background: #3a3a3a; padding: 10px 12px; border-bottom: 2px solid #111;
}
.pe-create-head h1 { font-size: 12px; margin: 0; letter-spacing: 1px; }
.pe-back {
  background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer;
}
.pe-create-body { display: grid; grid-template-columns: 220px 1fr; min-height: 420px; }
.pe-create-side {
  padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #262626;
}
.pe-preview {
  height: 120px; border: 3px solid #111;
  background:
    linear-gradient(#78a7ff, #78a7ff) 0 0 / 100% 55% no-repeat,
    linear-gradient(#5a9a3a, #5a9a3a);
}
.pe-green, .pe-purple, .pe-mc-btn {
  width: 100%; padding: 12px 8px; font: inherit; font-size: 9px; cursor: pointer;
  border: 3px solid #111; color: #fff; text-shadow: 2px 2px #1a1a1a;
}
.pe-green, .pe-mc-btn.green {
  background: linear-gradient(#6cc349, #3c8527);
  box-shadow: inset 0 3px 0 #9ae06a, inset 0 -3px 0 #2d6a1c;
}
.pe-purple { background: linear-gradient(#7b4ad6, #5a2db3); }
.pe-side-link { font-size: 8px; color: #cfcfcf; margin: 6px 0 0; }
.pe-create-main { padding: 16px 18px; }
.pe-create-main label, .pe-label { display: block; font-size: 9px; margin: 10px 0 6px; }
.pe-create-main input {
  width: 100%; height: 36px; background: #1d1d1d; border: 2px solid #111; color: #fff;
  font: inherit; font-size: 10px; padding: 0 8px;
}
.pe-toggle { display: flex; gap: 0; border: 3px solid #111; }
.pe-toggle button {
  flex: 1; padding: 12px 6px; background: #c6c6c6; color: #333; border: 0;
  font: inherit; font-size: 8px; cursor: pointer;
}
.pe-toggle button.is-on {
  background: linear-gradient(#6cc349, #3c8527); color: #fff;
}
.pe-toggle.four button { font-size: 7px; }
.pe-hint { font-size: 7px; line-height: 1.7; color: #bbb; margin: 8px 0 12px; }

.pe-pause-2d {
  background: linear-gradient(90deg, rgba(0,0,0,.62) 0 52%, transparent 52%) !important;
  align-items: stretch !important;
  padding: 0 !important;
}
.pe-pause-split {
  display: grid; grid-template-columns: 1fr 1fr; width: 100%; height: 100%;
}
.pe-pause-left {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px;
}
.pe-logo {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(16px, 4vw, 32px); letter-spacing: 2px; margin-bottom: 8px;
  text-shadow: 3px 3px 0 #3f3f3f;
}
.pe-mc-btn.gray {
  background: linear-gradient(#d4d4d4, #bdbdbd); color: #333; text-shadow: none;
}
.pe-pause-icons { display: flex; gap: 10px; margin-top: 6px; }
.pe-pause-icons button {
  width: 44px; height: 36px; background: #c6c6c6; border: 3px solid #111; font-size: 16px; cursor: pointer;
}
.pe-paused-pill {
  margin-top: 8px; background: #3c8527; color: #fff; padding: 8px 14px;
  font-family: "Press Start 2P", monospace; font-size: 8px; border: 3px solid #111;
}
.pe-pause-right {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end;
  padding: 18px;
}
.pe-bubble {
  background: #4aa0e8; color: #fff; padding: 10px 12px;
  font-family: "Press Start 2P", monospace; font-size: 8px; line-height: 1.7;
  max-width: 280px; margin-bottom: 8px;
}
.pe-skin {
  width: 72px; height: 150px; margin: 0 20px 8px 0;
  background:
    linear-gradient(#c68642, #c68642) 22px 6px / 28px 24px no-repeat,
    linear-gradient(#0095d7, #0095d7) 16px 30px / 40px 44px no-repeat,
    linear-gradient(#4b3a2f, #4b3a2f) 20px 74px / 32px 48px no-repeat,
    linear-gradient(#2b2b2b, #2b2b2b) 20px 122px / 14px 24px no-repeat,
    linear-gradient(#2b2b2b, #2b2b2b) 40px 122px / 14px 24px no-repeat;
}
.pe-wardrobe {
  background: #c6c6c6; color: #222; border: 3px solid #111;
  font-family: "Press Start 2P", monospace; font-size: 8px; padding: 8px 12px;
}

#chat {
  position: absolute; inset: 0; z-index: 30;
  display: grid; grid-template-rows: 36px 1fr 48px;
  font-family: "Press Start 2P", monospace;
}
#chat.is-hidden { display: none; }
#chat header {
  background: #c6c6c6; color: #333; display: flex; align-items: center; gap: 12px;
  padding: 0 10px; font-size: 11px; border-bottom: 2px solid #8b8b8b;
}
#chat-back { background: none; border: 0; font: inherit; font-size: 12px; cursor: pointer; color: #333; }
#chat-msgs {
  overflow: auto; padding: 8px 10px; font-size: 9px; line-height: 1.7; color: #fff;
  text-shadow: 2px 2px #000;
}
#chat-form {
  display: flex; background: #5a5a5a; padding: 6px; gap: 6px; align-items: center;
}
#chat-input {
  flex: 1; height: 34px; background: #3a3a3a; border: 2px solid #222; color: #fff;
  font: inherit; font-size: 10px; padding: 0 8px;
}
#chat-send {
  width: 40px; height: 34px; background: #4aa0e8; border: 2px solid #1a4a78;
  color: #fff; font-size: 16px; cursor: pointer;
}
#chat-hud {
  position: absolute; left: 10px; bottom: 70px; width: min(420px, 48vw);
  font-family: "Press Start 2P", monospace; font-size: 8px; line-height: 1.7;
  pointer-events: none; z-index: 7; color: #fff; text-shadow: 2px 2px #000;
}
#chat-hud p, #chat-msgs p { margin: 0 0 3px; }

#turn-phone {
  display: none; position: fixed; inset: 0; z-index: 80; background: #111;
  color: #fff; font-family: "Press Start 2P", monospace;
  place-items: center; text-align: center; padding: 24px;
  cursor: pointer; pointer-events: auto;
}
#turn-phone b { font-size: 42px; display: block; margin-bottom: 18px; }
#turn-phone p { font-size: 11px; line-height: 1.8; }

@media (pointer: coarse) {
  body.is-playing.portrait-lock #turn-phone { display: grid; }
  body.is-playing .status-row {
    position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px;
    z-index: 6; pointer-events: none;
  }
  body.is-playing .hud-top {
    position: fixed; top: calc(6px + env(safe-area-inset-top)); left: 50%;
    transform: translateX(-50%); z-index: 7; background: none; padding: 0;
    pointer-events: auto;
  }
}

.texpack-card { max-width: 860px; }
.texpack-card .tiny { line-height: 1.85; max-width: 38em; margin: 0 auto 16px; }
.tex-view { max-width: 420px; margin: 0 auto 16px; }
.tex-view button { font-size: 14px; min-height: 48px; padding: 14px 8px; }
.texpack-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
  margin: 12px 0;
}
.texpack-label { font-size: 10px; line-height: 1.7; margin: 0 0 10px; color: #ddd; min-height: 1.7em; }
.tex-palette {
  display: grid;
  grid-template-columns: repeat(10, 20px);
  gap: 4px;
  max-width: 244px;
}
.tex-swatch {
  width: 20px; height: 20px; border: 2px solid #111; padding: 0; cursor: pointer;
  image-rendering: pixelated;
}
.tex-swatch.is-on { outline: 2px solid #fff; }
.tex-swatch.is-empty { background: repeating-conic-gradient(#888 0 25%, #ccc 0 50%) 0 0 / 8px 8px; }
.texpack-mix { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.texpack-mix .mc-btn { width: auto; padding: 8px 10px; margin: 0; font-size: 9px; min-height: 0; }
#tex-color { width: 42px; height: 32px; padding: 0; border: 2px solid #111; background: #111; }
#tex-canvas, #tex-preview, #tex-preview-top, #tex-preview-bot, #tex-preview-inv {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background:
    repeating-conic-gradient(#3a3a3a 0 25%, #2a2a2a 0 50%) 0 0 / 16px 16px;
}
#tex-preview, #tex-preview-top, #tex-preview-bot, #tex-preview-inv {
  border: 3px solid #111;
}
.tex-face { max-width: 320px; margin: 0 0 10px; display: grid; grid-template-columns: repeat(3, 1fr); }
.tex-face button { font-size: 9px; min-height: 36px; padding: 8px 4px; }
.tex-canvas-stack {
  position: relative;
  width: 288px;
  height: 288px;
  border: 3px solid #111;
}
#tex-canvas {
  width: 100%; height: 100%; cursor: crosshair; touch-action: none;
  box-sizing: border-box; display: block; border: 0;
}
#tex-grid {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; border: 0; background: none;
  image-rendering: auto;
}
.tex-grid-row {
  display: flex; align-items: center; gap: 10px; margin: 8px 0 0;
}
.tex-grid-row .texpack-label { margin: 0; min-height: 0; }
.tex-grid-toggle { max-width: 220px; flex: 1; }
.tex-grid-toggle button { font-size: 8px; min-height: 32px; padding: 6px 4px; }
#tex-preview, #tex-preview-top, #tex-preview-bot, #tex-preview-inv { width: 48px; height: 48px; }
.tex-preview-row { display: flex; align-items: flex-end; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.tex-mini { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 8px; color: #ddd; }
.tex-mini canvas { cursor: pointer; }
#tex-ok { color: #9ae06a; min-height: 1.2em; }

#item-tip {
  position: fixed;
  transform: translate(-50%, calc(-100% - 8px));
  pointer-events: none;
  z-index: 90;
  background: #000000dd;
  color: #fff;
  border: 2px solid #000;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
  opacity: 0;
}
#item-tip.on { opacity: 1; }

@media (max-width: 720px) {
  .texpack-layout { grid-template-columns: 1fr; }
  .tex-canvas-stack {
    width: min(288px, 92vw);
    height: min(288px, 92vw);
  }
}

