:root {
  --deep: #061a12; --deep2: #0b2a1f; --ink: #0b3b26;
  --mint: #2ee88a; --mint2: #18c06c; --emerald: #0f8f55; --aqua: #3fd0ff; --water: #2a8cff;
  --gold: #ffd34d; --rare: #5aa2ff; --red: #ff6b6b; --text: #eafff4; --muted: #8fb8a6;
  --glass: rgba(6, 30, 22, 0.62); --glass-line: rgba(110, 255, 190, 0.22);
  --display: "Lilita One", "Trebuchet MS", sans-serif; --px: "Press Start 2P", monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--text); font-family: var(--display); }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; image-rendering: pixelated; touch-action: none; transition: filter 1s ease; }
body:not(.playing) #game { filter: blur(2px) saturate(1.2) brightness(0.8); }

/* ================= MAIN MENU ================= */
#title { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; overflow-y: auto; overflow-x: hidden;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); transition: opacity .8s ease, transform .9s ease; }
#title.leaving { opacity: 0; transform: scale(1.06); pointer-events: none; }
.menu-shade { position: fixed; inset: 0; pointer-events: none; background:
  radial-gradient(ellipse at 50% 30%, rgba(46, 232, 138, .12), transparent 55%),
  linear-gradient(180deg, rgba(4, 18, 12, .25), rgba(4, 18, 12, .55) 55%, rgba(4, 18, 12, .92)); }
.menu-cubes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.menu-cubes i { position: absolute; bottom: -30px; width: var(--s); height: var(--s); background: var(--c); border: 2px solid rgba(0, 0, 0, .25);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .18), inset 3px 3px 0 rgba(255, 255, 255, .25); opacity: .8; animation: cube var(--d) linear infinite; animation-delay: var(--dl); }
@keyframes cube { from { transform: translateY(0) rotate(0); } to { transform: translateY(-115vh) rotate(var(--r)); } }

.menu { position: relative; width: min(1040px, 100%); display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.4vh, 22px); min-width: 0; }
.banner-card { position: relative; width: 100%; aspect-ratio: 3 / 1; max-height: 42vh; border-radius: 24px; overflow: hidden;
  border: 3px solid rgba(160, 255, 210, .6); box-shadow: 0 0 0 5px rgba(4, 18, 12, .7), 0 26px 70px rgba(0, 0, 0, .55), 0 0 90px rgba(46, 232, 138, .35);
  animation: pop .9s cubic-bezier(.2, 1.3, .4, 1) both; }
.banner-img { width: 100%; height: 100%; object-fit: cover; object-position: center 35%; display: block; animation: drift 18s ease-in-out infinite alternate; }
.banner-shine { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.banner-shine::after { content: ""; position: absolute; top: -40%; left: -40%; width: 22%; height: 180%; transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); animation: shine 6s ease-in-out infinite 1.5s; }
@keyframes drift { from { transform: scale(1.02) translateX(-1%); } to { transform: scale(1.1) translateX(1.5%); } }
@keyframes shine { 0%, 70% { left: -40%; } 100% { left: 130%; } }

.menu-panel { width: min(460px, 100%); padding: 18px; border-radius: 24px; animation: rise .8s .2s both;
  background: linear-gradient(180deg, rgba(14, 58, 43, .82), rgba(6, 28, 20, .9)); border: 1px solid var(--glass-line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.mscreen { display: flex; flex-direction: column; gap: 12px; animation: fade .25s; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mtitle { margin: 0; font: 400 24px var(--display); color: #fff; text-align: center; text-shadow: 0 3px 0 var(--ink); }
#login-name { font: 22px var(--display); padding: 14px 16px; border-radius: 14px; outline: none; color: var(--ink); text-align: center;
  background: #effff7; border: 3px solid var(--ink); box-shadow: inset 0 -4px 0 #c6ecd9; }
#login-name:focus { box-shadow: 0 0 0 4px rgba(46, 232, 138, .5), inset 0 -4px 0 #c6ecd9; }
.err { color: #ffb3b3; font-size: 14px; min-height: 0; margin: 0; text-align: center; }
.err:empty { display: none; }
.link-btn { background: none; border: 0; color: var(--muted); font: 15px var(--display); padding: 4px; cursor: pointer; }
.link-btn:hover { color: var(--mint); }
.back { align-self: center; }

/* chunky voxel buttons */
.vbtn { position: relative; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 18px; border-radius: 12px;
  font: 400 19px var(--display); letter-spacing: .5px; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); border: 3px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, .3), inset 0 -4px 0 rgba(0, 0, 0, .18); transition: transform .08s, box-shadow .08s, filter .15s; }
.vbtn:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, .3), inset 0 -4px 0 rgba(0, 0, 0, .18); }
.vbtn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, .3); }
.vbtn:disabled { filter: grayscale(.6); opacity: .7; }
.vbtn-play { font-size: 30px; padding: 16px; color: #04281a; text-shadow: 0 2px 0 rgba(255, 255, 255, .45);
  background: linear-gradient(180deg, #9dffcf, var(--mint) 45%, var(--mint2)); }
.vbtn-play::after { content: ""; position: absolute; inset: 0; border-radius: 9px; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 45%, transparent 60%) -200% 0 / 200% 100% no-repeat; animation: sweep 2.8s ease-in-out infinite; }
@keyframes sweep { 0%, 40% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.vbtn-play .pill3d { width: 34px; height: 16px; }
.vbtn-wood { background: linear-gradient(180deg, #c99a5c, #9a703c); }
.vbtn-stone { background: linear-gradient(180deg, #9a9ca4, #6e7078); }
.vbtn-dark { background: linear-gradient(180deg, #1c4a39, #0e2f22); font-size: 16px; padding: 11px; }
.vbtn.loading .vbtn-label { opacity: .6; }

.who-chip { display: flex; align-items: center; gap: 8px; justify-content: center; font: 16px var(--display); color: #cfeee0; }
.who-chip b { font-weight: 400; color: #fff; }
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; }
.reward-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.reward-strip div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; background: rgba(0, 0, 0, .25); font: 13px var(--display); color: var(--muted); }
.reward-strip b { font-weight: 400; color: var(--gold); font-size: 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.common { background: #c9e8da; } .dot.rare { background: var(--rare); box-shadow: 0 0 8px var(--rare); }
.dot.legendary { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.dot.live { background: var(--mint); box-shadow: 0 0 10px var(--mint); animation: blink 1.4s infinite; }
.menu-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 0; font: 14px var(--display); color: var(--muted); animation: rise .8s .35s both; }
.menu-foot .sep { opacity: .5; }
#sound-hint { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 14px; z-index: 21;
  font: 14px var(--display); color: #cffbe6; padding: 8px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); transition: opacity .5s; }
#sound-hint.gone { opacity: 0; pointer-events: none; }
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@keyframes blink { 50% { opacity: .3; } }
@media (max-width: 560px) {
  .banner-card { border-radius: 16px; aspect-ratio: 2.2 / 1; }
  .vbtn-play { font-size: 26px; }
  .vbtn { font-size: 17px; }
}

/* ================= PAUSE MENU ================= */
#pause { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 16px; background: rgba(2, 12, 8, .55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade .2s; }
.pause-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 22px 18px 16px; border-radius: 24px; text-align: center;
  background: linear-gradient(180deg, rgba(14, 58, 43, .92), rgba(6, 28, 20, .95)); border: 1px solid var(--glass-line); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop2 .3s cubic-bezier(.2, 1.3, .4, 1); }
.pause-logo { width: 84px; height: 84px; border-radius: 20px; margin: -60px auto 0; border: 3px solid rgba(160, 255, 210, .6); box-shadow: 0 0 0 4px rgba(4, 18, 12, .8), 0 0 30px rgba(46, 232, 138, .45); }
.pause-card h2 { margin: 0; font: 400 30px var(--display); color: #fff; text-shadow: 0 3px 0 var(--ink); letter-spacing: 1px; }
.pause-keys { margin: 2px 0 0; font: 12px var(--display); color: var(--muted); line-height: 1.5; }

/* how to play + settings */
.how-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.how-step { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .05); display: flex; flex-direction: column; gap: 4px; }
.how-step b { font-weight: 400; font-size: 18px; color: var(--mint); }
.how-step p { margin: 0; font-size: 14px; color: #cfeee0; line-height: 1.35; }
.how-ico { font-size: 26px; height: 30px; display: flex; align-items: center; }
.how-table { display: grid; gap: 6px; }
.how-table div { display: grid; grid-template-columns: 14px 90px 100px 1fr; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05); font-size: 15px; }
.how-table b { font-weight: 400; color: var(--gold); } .how-table span { color: var(--muted); font-size: 13px; }
.how-keys { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 14px; color: #cfeee0; }
kbd { display: inline-block; min-width: 24px; padding: 2px 6px; margin-right: 3px; border-radius: 6px; text-align: center; font: 12px var(--px); color: var(--ink); background: #effff7; box-shadow: 0 3px 0 #8fb8a6; }
.set-row { display: grid; grid-template-columns: 1fr 1.3fr 48px; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 16px; }
.set-row b { font-weight: 400; color: var(--gold); text-align: right; }
.set-row.check { grid-template-columns: 1fr auto; }
.set-row input[type=range] { accent-color: var(--mint); width: 100%; }
.set-row input[type=checkbox] { accent-color: var(--mint); width: 22px; height: 22px; }
@media (max-width: 560px) { .how-steps { grid-template-columns: 1fr; } .how-table div { grid-template-columns: 14px 80px 1fr; } .how-table span { display: none; } }

/* ================= HUD ================= */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) 12px 0; pointer-events: none; opacity: 0; transform: translateY(-20px); transition: .6s .3s; }
body.playing #hud { opacity: 1; transform: none; }
#hud > * { pointer-events: auto; }
.glass { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.player { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: #04281a;
  background: linear-gradient(180deg, #7dffbe, var(--mint2)); border: 2px solid var(--ink); }
.who { display: flex; flex-direction: column; line-height: 1.15; }
.who b { font-weight: 400; font-size: 17px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 12px; color: var(--muted); }
.bag { flex: 1; min-width: 170px; max-width: 360px; padding: 8px 14px; }
.bag-top { display: flex; align-items: baseline; gap: 6px; }
.bag-top b { font-weight: 400; font-size: 20px; color: var(--gold); text-shadow: 0 0 12px rgba(255, 211, 77, .35); }
.bag-top span:last-child { font-size: 13px; color: var(--muted); }
.pill-ico { width: 16px; height: 9px; border-radius: 9px; align-self: center; background: linear-gradient(90deg, var(--mint) 50%, #fff 50%); border: 2px solid var(--ink); transform: rotate(-30deg); }
.bar { height: 8px; border-radius: 8px; background: rgba(0, 0, 0, .45); overflow: hidden; margin: 5px 0 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.bar i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--emerald), var(--mint), var(--aqua)); transition: width .6s cubic-bezier(.2, 1, .3, 1); }
#hud.full .bar i, .bar.big i[style*="100%"] { background: linear-gradient(90deg, #ffb800, var(--gold), #fff3b0); animation: pulse .9s infinite; }
.bag small { font-size: 11px; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 4px; padding: 5px; margin-left: auto; }
.actions button { display: flex; align-items: center; gap: 6px; height: 40px; min-width: 40px; padding: 0 10px; border-radius: 12px; border: 0;
  background: transparent; color: var(--text); font-size: 15px; transition: background .2s; }
.actions button:hover { background: rgba(46, 232, 138, .14); }
.actions svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#btn-bag { background: rgba(46, 232, 138, .14); }
#hud.full #btn-bag { background: var(--gold); color: #3a2a00; animation: pulse .9s infinite; }
#btn-sound .off-i, #btn-sound.off .on-i { display: none; }
#btn-sound.off .off-i { display: block; color: var(--muted); }

#toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 12; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { font-size: 18px; padding: 8px 18px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(8px);
  animation: toast 3.2s ease forwards; color: var(--gold); }
.toast b { font-weight: 400; color: #fff; }
.toast.rare { border-color: var(--rare); box-shadow: 0 0 22px rgba(90, 162, 255, .5); }
.toast.legendary { border-color: var(--gold); box-shadow: 0 0 30px rgba(255, 211, 77, .65); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px) scale(.8); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px); } }

/* ================= MODALS ================= */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(2, 10, 7, .6); backdrop-filter: blur(4px); animation: fade .25s; }
.panel { width: min(560px, 100%); max-height: 86vh; overflow: auto; padding: 18px; border-radius: 22px; color: var(--text);
  background: linear-gradient(180deg, #0f3b2c, #082419); border: 1px solid var(--glass-line); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop2 .3s cubic-bezier(.2, 1.3, .4, 1); }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-weight: 400; font-size: 26px; flex: 1; color: var(--mint); text-shadow: 0 2px 0 var(--ink); }
.count { font-size: 14px; color: var(--muted); }
.panel-head button { width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .05); color: var(--text); font-size: 14px; }
.panel h3 { font-weight: 400; font-size: 16px; color: var(--muted); margin: 18px 0 8px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dex-card { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06); }
.dex-card canvas { width: 52px; height: 52px; image-rendering: pixelated; flex: none; background: radial-gradient(circle, rgba(46, 232, 138, .2), transparent 70%); border-radius: 10px; }
.dex-card div { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.dex-card b { font-weight: 400; font-size: 16px; }
.dex-card span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dex-card em { font-style: normal; font-size: 12px; color: var(--gold); }
.dex-card.unseen canvas { filter: brightness(0) drop-shadow(0 0 1px rgba(160, 255, 210, .5)); opacity: .55; }
.dex-card.unseen em { color: var(--muted); }
.wbal { display: flex; align-items: baseline; gap: 10px; }
.wbal b { font-weight: 400; font-size: 42px; color: var(--gold); text-shadow: 0 0 20px rgba(255, 211, 77, .35); }
.wbal span { color: var(--muted); }
.bar.big { height: 12px; margin: 6px 0 14px; }
.holdings { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.hold { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-size: 15px; }
.hold b { font-weight: 400; color: var(--gold); }
.muted { color: var(--muted); font-size: 14px; }
#w-form { display: grid; gap: 8px; margin-top: 8px; }
#w-form label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
#w-form input { font: 14px ui-monospace, monospace; padding: 12px; border-radius: 12px; border: 2px solid var(--glass-line); background: rgba(0, 0, 0, .3); color: var(--text); outline: none; }
#w-form input:focus { border-color: var(--mint); }
.big-btn { font: 12px var(--px); padding: 14px; border-radius: 14px; border: 3px solid var(--ink); color: #3a2a00;
  background: linear-gradient(180deg, #fff3b0, var(--gold)); box-shadow: 0 5px 0 var(--ink); }
.big-btn:disabled { filter: grayscale(1); opacity: .6; }
.ok { color: var(--mint); font-size: 14px; min-height: 18px; }
.hist { display: flex; gap: 10px; font-size: 14px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); align-items: center; }
.hist span:first-child { flex: 1; color: var(--muted); }
.hist .st { text-transform: capitalize; } .hist.pending .st { color: var(--gold); } .hist.paid .st { color: var(--mint); } .hist.rejected .st { color: var(--red); }
.hist a { color: var(--aqua); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop2 { from { opacity: 0; transform: scale(.92) translateY(10px); } }

@media (max-width: 640px) {
  .actions button span { display: none; }
  .actions { margin-left: 0; }
  #hud { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .bag { order: 3; max-width: none; flex-basis: 100%; }
  .player { flex: 1; }
  #toasts { top: 140px; }
}

/* ================= CHAT ================= */
#chat { position: fixed; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 11; width: min(380px, calc(100vw - 24px));
  display: none; flex-direction: column; gap: 6px; pointer-events: none; }
body.playing #chat { display: flex; }
#chat-log { max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 14px;
  background: linear-gradient(180deg, transparent, rgba(6, 30, 22, .55) 30%); scrollbar-width: none;
  mask-image: linear-gradient(180deg, transparent 0, #000 22px); -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  opacity: .55; transition: opacity .4s; }
#chat-log::-webkit-scrollbar { display: none; }
#chat.fresh #chat-log, #chat.open #chat-log, #chat:hover #chat-log { opacity: 1; }
#chat.open #chat-log, #chat:hover #chat-log { pointer-events: auto; }
.msg { font: 15px/1.3 var(--display); color: #eafff4; text-shadow: 0 1px 2px #000a; word-wrap: break-word; animation: fade .3s; }
.msg b { font-weight: 400; margin-right: 6px; }
.msg b::after { content: ":"; color: #eafff499; }
.msg.mine span { color: #d8fff0; }
.msg.sys { color: var(--gold); font-size: 14px; }
#chat-form { display: flex; gap: 6px; pointer-events: auto; padding: 5px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#chat-input { flex: 1; min-width: 0; font: 15px var(--display); color: var(--text); background: transparent; border: 0; outline: none; padding: 6px 8px; }
#chat-input::placeholder { color: var(--muted); }
#chat-form button { width: 36px; border-radius: 10px; border: 0; background: rgba(46, 232, 138, .25); color: var(--text); display: grid; place-items: center; }
#chat-form button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
#chat:focus-within #chat-form { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(46, 232, 138, .25); }

/* phones: chat sits above the touch pad, input only when opened */
@media (pointer: coarse) {
  #chat { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 150px); width: min(300px, calc(100vw - 24px)); }
  #chat-log { max-height: 18vh; }
  #chat:not(.open) #chat-form { display: none; }
  #chat.open { bottom: max(12px, env(safe-area-inset-bottom)); left: 8px; width: calc(100vw - 16px); z-index: 25; }
  #chat.open #chat-log { max-height: 36vh; }
}

@media (max-width: 400px) { #btn-full { display: none; } }

/* ================= 3D OVERLAYS ================= */
#game { cursor: crosshair; }
#crosshair, #hotbar, #area-banner, #touch { display: none; }
body.playing #crosshair, body.playing #hotbar, body.playing #area-banner { display: block; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); z-index: 8; pointer-events: none; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: rgba(255, 255, 255, .9); box-shadow: 0 0 2px #000; }
#crosshair::before { left: 10px; top: 2px; width: 2px; height: 18px; }
#crosshair::after { top: 10px; left: 2px; height: 2px; width: 18px; }

#area-banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 9; pointer-events: none; opacity: 0;
  font: clamp(22px, 4vw, 40px) var(--display); color: #fff; letter-spacing: 1px; white-space: nowrap;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink), 0 0 30px rgba(46, 232, 138, .6); }
#area-banner.show { animation: banner 3s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -8px); } }

@media (pointer: coarse) { #crosshair { width: 18px; height: 18px; } }

#hotbar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9; pointer-events: none; text-align: center; }
#hotbar .slot { position: relative; width: 64px; height: 64px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(14, 58, 43, .85), rgba(6, 30, 22, .9)); border: 3px solid var(--mint); box-shadow: 0 0 0 3px var(--ink), 0 0 24px rgba(46, 232, 138, .5); }
#hotbar .slot em { position: absolute; right: 6px; bottom: 2px; font: 400 16px var(--display); font-style: normal; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.hotbar-tip { margin: 6px 0 0; font: 13px var(--display); color: #eafff4cc; text-shadow: 0 1px 3px #000; }
.pill3d { display: block; width: 40px; height: 18px; border-radius: 18px; transform: rotate(-35deg); border: 3px solid var(--ink);
  background: linear-gradient(90deg, var(--mint) 50%, #f4fbf7 50%); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45); }

/* phones: joystick left, throw + jump right */
@media (pointer: coarse) {
  body.playing #touch { display: block; }
  #hotbar { display: none !important; }
  #chat { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 150px) !important; }
  #chat.open { bottom: max(12px, env(safe-area-inset-bottom)) !important; }
}
#touch { position: fixed; inset: auto 0 0 0; height: 0; z-index: 9; }
#joy { position: fixed; left: max(22px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%;
  background: rgba(6, 30, 22, .42); border: 2px solid rgba(160, 255, 210, .35); touch-action: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9dffcf, var(--mint2)); border: 3px solid var(--ink); pointer-events: none; }
#btn-throw, #btn-jump { position: fixed; border-radius: 50%; touch-action: none; display: grid; place-items: center; border: 3px solid var(--ink); }
#btn-throw { right: max(22px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 92px; height: 92px;
  background: radial-gradient(circle at 35% 30%, rgba(46, 232, 138, .55), rgba(6, 30, 22, .7)); box-shadow: 0 0 0 3px rgba(46, 232, 138, .5), 0 0 26px rgba(46, 232, 138, .5); }
#btn-throw:active { transform: scale(.94); }
#btn-jump { right: max(126px, calc(env(safe-area-inset-right) + 126px)); bottom: max(24px, env(safe-area-inset-bottom)); width: 62px; height: 62px;
  background: rgba(6, 30, 22, .55); color: #eafff4; font: 26px var(--display); }
@media (pointer: coarse) { #chat-log { max-height: 11vh !important; } #chat.open #chat-log { max-height: 30vh !important; } #chat { width: min(260px, calc(100vw - 24px)) !important; } }

/* ================= VOICE ================= */
#talk { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%) translateY(10px); z-index: 12; display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; font: 16px var(--display); color: #04281a; background: var(--mint); border: 3px solid var(--ink);
  box-shadow: 0 0 24px rgba(46, 232, 138, .6); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
#talk.show { opacity: 1; transform: translateX(-50%); }
#talk.asking { background: var(--gold); }
.talk-dot { width: 10px; height: 10px; border-radius: 50%; background: #e84040; box-shadow: 0 0 0 3px rgba(232, 64, 64, .3); animation: blink .8s infinite; }
.hotbar-tip b { color: var(--mint); font-weight: 400; }
#btn-mic { position: fixed; right: max(126px, calc(env(safe-area-inset-right) + 126px)); bottom: max(98px, calc(env(safe-area-inset-bottom) + 98px)); width: 56px; height: 56px;
  border-radius: 50%; touch-action: none; display: grid; place-items: center; font-size: 24px; border: 3px solid var(--ink); background: rgba(6, 30, 22, .6); }
#btn-mic.on { background: var(--mint); box-shadow: 0 0 22px rgba(46, 232, 138, .7); }
@media (pointer: coarse) { #talk { bottom: auto; top: 46%; } }

/* X link in the main menu */
.x-link { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 14px; border-radius: 12px; text-decoration: none;
  font: 16px var(--display); color: #eafff4; background: #000; border: 2px solid rgba(255, 255, 255, .18); box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  transition: transform .1s, border-color .2s, box-shadow .1s; }
.x-link svg { width: 18px; height: 18px; fill: currentColor; }
.x-link b { font-weight: 400; color: var(--mint); }
.x-link:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .45); box-shadow: 0 6px 0 rgba(0, 0, 0, .45); }
.x-link:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .45); }

/* ================= ANNOUNCEMENTS ================= */
#announce { position: fixed; left: 50%; top: 92px; z-index: 13; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 24px);
  padding: 12px 22px; border-radius: 16px; text-decoration: none; color: #3a2a00; font: 20px var(--display); letter-spacing: .5px;
  background: linear-gradient(180deg, #fff3b0, var(--gold) 55%, #f0b400); border: 3px solid #5a4100;
  box-shadow: 0 6px 0 #5a4100, 0 0 40px rgba(255, 211, 77, .65); transform: translateX(-50%); pointer-events: none; }
#announce.linked { pointer-events: auto; cursor: pointer; }
#announce.big { font-size: clamp(22px, 4vw, 34px); padding: 14px 28px; }
#announce.show { animation: ann 7.5s ease forwards; }
#announce .ann-ico { font-size: 1.2em; animation: wiggle .6s ease-in-out infinite alternate; }
#announce em { font-style: normal; font-size: 13px; padding: 3px 9px; border-radius: 999px; background: rgba(90, 65, 0, .18); white-space: nowrap; }
#announce em:empty { display: none; }
@keyframes ann { 0% { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(.8); } 8% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  12%, 88% { opacity: 1; transform: translateX(-50%) scale(1); } 100% { opacity: 0; transform: translateX(-50%) translateY(-12px); } }
@keyframes wiggle { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
@media (max-width: 640px) { #announce { top: 150px; font-size: 17px; } }
.msg.ann, .msg.ann a { color: var(--gold); font-size: 15px; text-decoration: none; }
.msg.ann a:hover { text-decoration: underline; }
