:root {
  color-scheme: dark;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --cream: #f2edcf;
  --deep: #090b1d;
  --glass: rgba(9, 11, 29, 0.9);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--deep); }
body { color: var(--cream); }
button, input { font: inherit; }
button { color: inherit; }

#world {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
#labels {
  position: fixed; z-index: 4; inset: 0; width: 100%; height: 100%; display: block;
  pointer-events: none;
}

.hud {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; padding: 15px 18px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.brand { color: var(--cream); text-decoration: none; font-family: Georgia, serif; font-size: 18px; text-shadow: 2px 2px 0 rgba(5,6,17,.5); }
.brand span { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 7px; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; background: rgba(16,44,40,.5); }
.hud-actions { display: flex; align-items: center; gap: 7px; }
.presence, .icon-button {
  height: 36px; border: 1px solid rgba(255,255,255,.18); border-radius: 9px;
  background: rgba(9,11,29,.76); box-shadow: 3px 3px 0 rgba(5,6,17,.3); backdrop-filter: blur(8px);
}
.presence { display: flex; align-items: center; gap: 6px; padding: 0 11px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.presence i { width: 6px; height: 6px; border-radius: 1px; background: #ce765f; }
.presence i.online { background: #b9d66e; box-shadow: 0 0 8px #b9d66e; }
.icon-button { width: 36px; padding: 0; cursor: pointer; font-size: 17px; }
.icon-button:hover, .icon-button.active { background: rgba(46,79,67,.9); }
.icon-button.muted { opacity: .48; text-decoration: line-through; }

.welcome {
  position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px;
  background: rgba(5,6,17,.36); backdrop-filter: blur(4px);
  transition: opacity .25s steps(4), visibility .25s;
}
.welcome.dismissed { opacity: 0; visibility: hidden; }
.creator-card {
  width: min(380px, 100%); padding: 26px; border: 2px solid rgba(255,242,199,.42); border-radius: 4px;
  background: var(--glass); box-shadow: 9px 9px 0 rgba(7,27,24,.34);
}
.creator-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.creator-copy p { margin: 0; color: #b8f2cb; font-size: 9px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font: 25px/1 Georgia, serif; letter-spacing: -.025em; }
#avatarPreview { display: block; width: 136px; height: 136px; margin: 12px auto 10px; image-rendering: pixelated; }
.name-field span, legend { display: block; margin-bottom: 6px; color: rgba(255,242,199,.58); font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
#nameInput { width: 100%; height: 42px; padding: 0 12px; border: 1px solid rgba(255,255,255,.16); border-radius: 3px; outline: 0; background: rgba(5,25,23,.46); color: white; }
#nameInput:focus { border-color: #b8f2cb; }
fieldset { margin: 15px 0 0; padding: 0; border: 0; }
.coat-picker, .path-picker { display: grid; gap: 6px; }
.coat-picker { grid-template-columns: repeat(4, 1fr); }
.coat-picker legend, .path-picker legend { grid-column: 1 / -1; }
.coat-picker input, .path-picker input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span, .path-picker label span { display: flex; align-items: center; justify-content: center; min-height: 35px; border: 1px solid rgba(255,255,255,.12); border-radius: 3px; cursor: pointer; font-size: 9px; }
.swatch span::before { content: ""; width: 8px; height: 8px; margin-right: 5px; background: #617f49; box-shadow: 1px 1px 0 #253b2d; }
.swatch.berry span::before { background: #ad4d50; }.swatch.sky span::before { background: #4188ae; }.swatch.sun span::before { background: #d79b24; }
.swatch input:checked + span, .path-picker input:checked + span { border-color: #eaf0b5; background: rgba(234,240,181,.11); color: white; }
.path-picker { grid-template-columns: repeat(3, 1fr); }
.path-picker label span { flex-direction: column; gap: 3px; min-height: 48px; }
.path-picker b { color: #b8f2cb; font-size: 15px; line-height: 1; }
.play-button { width: 100%; display: flex; justify-content: space-between; margin-top: 18px; padding: 13px 15px; border: 0; border-radius: 3px; cursor: pointer; background: #e7edaf; color: #173a34; font-weight: 900; box-shadow: 3px 3px 0 #759461; }
.play-button:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 #759461; }
.creator-card > small { display: block; margin-top: 12px; text-align: center; color: rgba(255,242,199,.38); font-size: 8px; }

.chat { position: fixed; z-index: 12; left: 50%; bottom: 22px; width: min(390px, calc(100% - 36px)); transform: translateX(-50%); display: flex; padding: 5px; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; background: rgba(10,34,31,.9); box-shadow: 5px 5px 0 rgba(8,25,23,.28); }
.chat[hidden] { display: none; }
.chat input { min-width: 0; flex: 1; padding: 9px 10px; border: 0; outline: 0; background: transparent; color: white; }
.chat button { width: 36px; border: 0; border-radius: 2px; background: #e7edaf; color: #173a34; cursor: pointer; font-weight: 900; }
.touch-controls {
  position: fixed; z-index: 11; inset: 0;
  display: none;
  pointer-events: none; touch-action: none; user-select: none; -webkit-user-select: none;
}
.touch-controls button {
  width: 54px; height: 54px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 0; border: 1px solid rgba(255,255,255,.25); border-radius: 10px;
  background: rgba(12,39,36,.76); color: #fff2c7; box-shadow: 3px 3px 0 rgba(6,23,21,.24);
  font-size: 20px; line-height: 1; backdrop-filter: blur(6px); touch-action: none; pointer-events: auto;
}
.touch-controls button small { font-size: 6px; font-weight: 900; letter-spacing: .08em; }
.touch-traversal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.touch-actions {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left));
  display: grid; grid-template-columns: repeat(3, 58px); align-items: end; justify-content: space-between; pointer-events: none;
}
.touch-controls button.touch-action { border-color: rgba(231,237,175,.74); background: rgba(74,100,65,.82); }
.touch-controls button.touch-dash { border-color: rgba(158,207,234,.58); background: rgba(31,43,68,.82); }
.touch-controls button.touch-attack { border-color: rgba(220,120,128,.54); background: rgba(55,38,42,.76); }
.touch-controls button.touch-direction {
  position: absolute; top: calc(50% - 37px); width: 74px; height: 74px; border-radius: 18px;
  border-color: rgba(255,255,255,.16); background: rgba(12,39,36,.24); box-shadow: none;
  color: rgba(255,242,199,.72); font-size: 31px; opacity: .42; backdrop-filter: blur(3px);
}
.touch-controls button.touch-left { left: max(14px, env(safe-area-inset-left)); }
.touch-controls button.touch-right { right: max(14px, env(safe-area-inset-right)); }
.touch-controls button.touch-jump,
.touch-controls button.touch-drop {
  position: static; width: 62px; height: 62px; border-radius: 16px;
  color: rgba(242,237,207,.82); font-size: 27px; opacity: .48;
}
.touch-controls button.touch-drop { background: rgba(24,25,48,.34); }
.touch-controls button.pressed, .touch-controls button:active { transform: translate(2px,2px); background: rgba(115,143,87,.94); box-shadow: 1px 1px 0 rgba(6,23,21,.3); }
.hint { position: fixed; z-index: 9; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; padding: 7px 10px; border-radius: 3px; background: rgba(12,35,32,.56); color: rgba(255,242,199,.7); font-size: 8px; white-space: nowrap; transition: opacity .6s; }
.hint.faded { opacity: 0; }
.toast { position: fixed; z-index: 30; left: 50%; top: 64px; transform: translate(-50%,-6px); padding: 8px 11px; border: 1px solid rgba(255,255,255,.17); border-radius: 3px; background: rgba(10,31,29,.9); font-size: 9px; opacity: 0; pointer-events: none; transition: .16s steps(2); }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 520px) {
  .hud { padding: 11px; }
  .brand { font-size: 15px; }
  .brand span { width: 25px; height: 25px; }
  .presence { display: none; }
  .creator-card { padding: 21px; }
  .creator-copy { display: block; }
  .creator-copy p { margin-bottom: 6px; }
  .hint { bottom: 12px; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
}

@media (hover: none) and (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: flex; }
  .hint { display: none; }
  .chat { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .touch-controls button { width: 50px; height: 50px; }
  .touch-controls button.touch-direction { width: 68px; height: 68px; }
  .touch-controls button.touch-jump,
  .touch-controls button.touch-drop { width: 56px; height: 56px; }
  .touch-traversal { gap: 8px; }
  .touch-actions { grid-template-columns: repeat(3, 54px); }
}

@media (max-height: 500px) and (orientation: landscape) {
  .welcome { padding: 0; }
  .creator-card { width: min(520px, calc(100% - 120px)); padding: 12px 18px; }
  #avatarPreview { display: none; }
  #nameInput { height: 34px; }
  fieldset { margin-top: 8px; }
  .swatch span { min-height: 30px; }
  .path-picker label span { min-height: 36px; }
  .play-button { margin-top: 9px; padding: 9px 12px; }
  .creator-card > small { margin-top: 6px; }
  .touch-controls button { width: 46px; height: 46px; }
  .touch-controls button.touch-direction { width: 64px; height: 64px; }
  .touch-controls button.touch-jump,
  .touch-controls button.touch-drop { width: 48px; height: 48px; }
  .touch-traversal { top: 48%; gap: 6px; }
  .touch-actions { bottom: calc(6px + env(safe-area-inset-bottom)); grid-template-columns: repeat(3, 48px); }
}
