* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05030a; color: #f2ecf5; overflow: hidden;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; }
.hidden { display: none !important; }

/* ---------- menus ---------- */
#ui { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; padding: 16px; }
.panel { pointer-events: auto; width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 28px 30px;
  background: rgba(8, 5, 14, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px;
  backdrop-filter: blur(6px); box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6); }
.panel.small { width: min(320px, 100%); text-align: center; }
h1 { margin: 0; font-size: 40px; letter-spacing: 0.14em; font-weight: 800; line-height: 1; }
h1 span { display: block; font-weight: 300; letter-spacing: 0.42em; font-size: 22px; margin-top: 6px;
  background: linear-gradient(90deg, #ff3b4e, #ffb53b, #7fd4ff, #4dff88); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0 0 6px; font-size: 30px; letter-spacing: 0.1em; }
.tag { margin: 10px 0 20px; color: #b9aec4; font-size: 14px; }
input { width: 100%; padding: 11px 12px; margin-bottom: 10px; font: inherit; color: #fff; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 8px; outline: none; user-select: text; -webkit-user-select: text; }
input:focus { border-color: #ffb53b; }
button { font: inherit; font-weight: 700; color: #120a12; background: #ffb53b; border: 0; border-radius: 8px; padding: 11px 16px; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.45; cursor: default; filter: none; }
button.ghost { background: transparent; color: #f2ecf5; border: 1px solid rgba(255, 255, 255, 0.25); }
button.big { width: 100%; padding: 15px; font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 16px; }
button.link { background: none; color: #9d92a8; font-weight: 400; padding: 8px 0 0; font-size: 13px; }
a.foot, .foot a { display: inline-block; color: #9d92a8; font-size: 13px; padding: 8px 0 0; }
.row.foot { align-items: baseline; }
.row.foot > * { flex: 0 1 auto; }
.row.foot > :last-child { margin-left: auto; }
button.danger { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.5); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; margin-bottom: 0; }
.msg { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: #ff8a8a; }
.msg.ok { color: #9dff6a; }
details { margin-top: 14px; font-size: 13px; color: #b9aec4; }
summary { cursor: pointer; padding: 4px 0; }
details input { margin-top: 8px; }
#party { padding: 14px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: #b9aec4; }
.hint { text-transform: none; letter-spacing: 0; color: #776d82; margin-left: 6px; }
#code { font-size: 34px; font-weight: 800; letter-spacing: 0.3em; margin: 6px 0; color: #ffb53b; user-select: text; -webkit-user-select: text; }
#members { list-style: none; margin: 0 0 12px; padding: 0; }
#members li { padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: 15px; }
#members li.empty { color: #5f566a; font-style: italic; }
#members small { color: #ffb53b; margin-left: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
td, th { text-align: left; padding: 4px 6px 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
th { color: #776d82; font-weight: 400; }
#endTable { margin: 6px 0 4px; font-size: 14px; }
#endTable tr.mine td { color: #ffb53b; }
#endTable td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-size: 14px; text-shadow: 0 1px 3px #000; }
#top { position: absolute; top: 14px; right: 18px; text-align: right; font-weight: 700; letter-spacing: 0.06em; }
#zone { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 20px;
  background: rgba(0, 0, 0, 0.45); font-weight: 600; white-space: nowrap; }
#zone.warn { background: rgba(255, 42, 109, 0.55); }
#feed { position: absolute; top: 44px; right: 18px; text-align: right; font-size: 13px; line-height: 1.5; }
#feed div { opacity: 0.92; }
#feed b { font-weight: 700; }
#squad { position: absolute; top: 14px; left: 18px; width: 170px; }
.mate { margin-bottom: 8px; }
.mate .n { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }
.mate .b { height: 5px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.mate .b i { display: block; height: 100%; }
.mate.dead { opacity: 0.4; }
#banner { position: absolute; top: 22%; left: 0; right: 0; text-align: center; font-size: 26px; font-weight: 800; letter-spacing: 0.14em; }
#banner small { display: block; font-size: 14px; font-weight: 400; letter-spacing: 0.02em; margin-top: 6px; color: #e6dcef; }
#prompt { position: absolute; bottom: 132px; left: 0; right: 0; text-align: center; font-weight: 600; }
#prompt kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 6px; border-radius: 4px; background: #f2ecf5; color: #120a12; text-shadow: none; font: inherit; font-weight: 800; }
#vitals { position: absolute; left: 18px; bottom: 18px; width: 260px; }
.bar { position: relative; height: 16px; background: rgba(0, 0, 0, 0.55); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.bar:first-child { height: 8px; }
#hp { height: 100%; background: #f2ecf5; transition: width 0.12s; }
#ar { height: 100%; background: #7fd4ff; transition: width 0.12s; }
#hptext { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; font-weight: 800; color: #120a12; text-shadow: none; mix-blend-mode: difference; color: #fff; }
#slots { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; }
.slot { min-width: 108px; padding: 7px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.5); border: 2px solid rgba(255, 255, 255, 0.12); }
.slot.on { background: rgba(0, 0, 0, 0.75); }
.slot .k { font-size: 10px; color: #b9aec4; letter-spacing: 0.1em; }
.slot .t { font-weight: 700; white-space: nowrap; }
.slot .a { font-size: 12px; color: #d8cfe0; font-variant-numeric: tabular-nums; }
.slot.none .t { color: #776d82; font-weight: 400; }
#minimap { position: absolute; right: 18px; bottom: 18px; width: 260px; height: 42px; border-radius: 6px; background: rgba(0, 0, 0, 0.5); }
@media (max-width: 900px) {
  #squad { width: 120px; } #vitals { width: 170px; } .slot { min-width: 70px; padding: 5px 7px; font-size: 12px; }
  #minimap { bottom: 86px; } #prompt { bottom: 150px; }
}

/* ---------- 3D view extras ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
#labels .tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; text-align: center; will-change: transform; }
#labels .tag .pip { width: 38px; height: 4px; margin: 2px auto 0; background: rgba(0, 0, 0, 0.6); border-radius: 2px; overflow: hidden; }
#labels .tag .pip i { display: block; height: 100%; }
#labels .num { position: absolute; left: 0; top: 0; font-size: 18px; font-weight: 800; will-change: transform; }
#outfit { margin-top: 14px; }
#skins { margin-top: 6px; }
#skins button { padding: 8px 4px; font-size: 12.5px; font-weight: 600; background: transparent; color: #f2ecf5; border: 1px solid rgba(255, 255, 255, 0.2); }
#skins button.on { border-color: #ffb53b; color: #ffb53b; background: rgba(255, 181, 59, 0.1); }
@media (min-width: 1000px) { #ui:has(#menu:not(.hidden)) { justify-content: flex-end; padding-right: 7vw; } }

/* ---------- touch controls ---------- */
html, body { overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#touch * { touch-action: none; }
#game canvas { touch-action: none; }
#touch { position: fixed; inset: 0; touch-action: none; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.85); }
#tMove { position: absolute; left: 0; top: 18%; bottom: 0; width: 46%; }
#tBase { position: absolute; display: none; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.25); }
#tKnob, #tAimKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
#tAim { position: absolute; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%;
  background: rgba(255, 90, 110, 0.12); border: 2px solid rgba(255, 120, 135, 0.5); }
#tAim span { position: absolute; left: 0; right: 0; top: -16px; text-align: center; font-size: 9px; opacity: 0.6; }
#tAim.down { background: rgba(255, 90, 110, 0.28); }
.tb { position: absolute; display: flex; align-items: center; justify-content: center; width: 58px; height: 58px; border-radius: 50%;
  background: rgba(10, 6, 16, 0.5); border: 2px solid rgba(255, 255, 255, 0.3); right: calc(var(--r) + env(safe-area-inset-right)); bottom: calc(var(--b) + env(safe-area-inset-bottom)); }
.tb.down { background: rgba(255, 181, 59, 0.45); border-color: #ffb53b; }
#tJump { --r: 158px; --b: 14px; width: 72px; height: 72px; }
#tUse { --r: 158px; --b: 100px; }
#tMenu { right: auto; bottom: auto; left: 50%; top: calc(48px + env(safe-area-inset-top)); width: 34px; height: 34px; margin-left: -17px; opacity: 0.7; }
#rotate { display: none; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; text-align: center; padding: 30px;
  background: #05030a; font-size: 20px; font-weight: 700; letter-spacing: 0.06em; }
@media (orientation: portrait) { body.touch #rotate { display: flex; } }

/* HUD on touch devices: keep the thumbs' corners clear */
body.touch #vitals { left: 50%; transform: translateX(-50%); bottom: calc(70px + env(safe-area-inset-bottom)); width: 190px; }
body.touch #slots { bottom: calc(8px + env(safe-area-inset-bottom)); gap: 5px; }
body.touch .slot { min-width: 70px; padding: 7px 8px; font-size: 11px; }
body.touch .slot.down { background: rgba(255, 181, 59, 0.45); }
body.touch .slot .k { display: none; }
body.touch .slot .a { font-size: 10px; }
body.touch #minimap { right: auto; bottom: auto; left: 50%; transform: translateX(-50%); top: calc(90px + env(safe-area-inset-top)); width: 190px; height: 30px; opacity: 0.85; }
body.touch #prompt { bottom: calc(118px + env(safe-area-inset-bottom)); font-size: 13px; }
body.touch #squad { width: 120px; left: calc(12px + env(safe-area-inset-left)); top: 8px; font-size: 11px; }
body.touch #top { right: calc(12px + env(safe-area-inset-right)); top: 8px; font-size: 12px; }
body.touch #feed { right: calc(12px + env(safe-area-inset-right)); top: 30px; font-size: 11px; }
body.touch #zone { top: 8px; font-size: 12px; padding: 4px 10px; }
body.touch #banner { top: 16%; font-size: 20px; }
@media (max-height: 520px) {
  .panel { padding: 16px 20px; }
  h1 { font-size: 26px; } h1 span { font-size: 15px; display: inline; margin-left: 10px; }
  .tag { margin: 6px 0 10px; } #code { font-size: 24px; margin: 2px 0; } #members li { padding: 2px 0; font-size: 13px; }
  button.big { padding: 11px; margin-top: 10px; } #party { padding: 10px; }
  #menu { width: min(640px, 100%); }
  #members li.empty, #menu details, .hint { display: none; }
  #members { margin-bottom: 6px; } input { padding: 8px 10px; } #outfit { margin-top: 8px; }
}
