/* Open Field - mobile-first UI shell.
   The game canvas is the page; every panel floats above it. */

:root {
  --glass-bg: rgba(10, 18, 14, 0.62);
  --glass-line: rgba(255, 255, 255, 0.14);
  --accent: #7ee787;
  --accent-dim: #a8e6b4;
  --text: #eef7f0;
  --muted: #9db8a6;
  --danger: #ff8787;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  background: #0b1410;
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Text", system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

input { -webkit-user-select: text; user-select: text; font-family: inherit; }

.hidden { display: none !important; }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 0;
}

/* ------------------------------- HUD ------------------------------- */

#topbar {
  position: fixed;
  top: calc(8px + var(--sat));
  left: calc(8px + var(--sal));
  right: calc(8px + var(--sar));
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.brand {
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.chip {
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dim);
  font-variant-numeric: tabular-nums;
}

.chip.warn { color: #ffd43b; }
#netChip { margin-left: auto; }

#locChip {
  position: fixed;
  top: calc(52px + var(--sat));
  left: calc(8px + var(--sal));
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-dim);
  max-width: min(72vw, 340px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 20;
  pointer-events: none;
}

#actions {
  position: fixed;
  right: calc(10px + var(--sar));
  bottom: calc(14px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 25;
}

/* ------------------------------- minimap --------------------------- */

#minimap {
  position: fixed;
  top: calc(54px + var(--sat));
  right: calc(8px + var(--sar));
  width: 116px;
  height: 116px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  background: rgba(6, 14, 10, 0.6);
  z-index: 22;
  pointer-events: none;
}

.fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  font-size: 21px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background 0.12s ease;
}

.fab:active { transform: scale(0.9); background: rgba(46, 84, 60, 0.7); }

/* ----------------------------- joystick ----------------------------- */

#joy {
  position: fixed;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 18, 14, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 15;
}

#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(126, 231, 135, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ------------------------------- chat ------------------------------- */

#chatBar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--sab));
  transform: translateX(-50%);
  width: min(94vw, 540px);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 8px 7px 16px;
  border-radius: 999px;
  z-index: 40;
}

#chatInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16px; /* >=16px stops iOS from zooming on focus */
  padding: 8px 0;
}

#chatInput::placeholder { color: var(--muted); }

#chatSend {
  border: 0;
  background: var(--accent);
  color: #06230f;
  font-weight: 800;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  flex: none;
}

#chatSend:active { transform: scale(0.92); }

/* --------------------------- player list ---------------------------- */

.panel {
  position: fixed;
  right: calc(10px + var(--sar));
  top: calc(180px + var(--sat)); /* below the minimap */
  width: min(86vw, 330px);
  max-height: min(56vh, 420px);
  border-radius: 16px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.panelHead b { color: var(--accent); font-variant-numeric: tabular-nums; }

.panelHead button {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

#listBody {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#listBody li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 10px;
}

#listBody li:hover { background: rgba(255, 255, 255, 0.05); }

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
  flex: none;
}

.rowMain { min-width: 0; display: flex; flex-direction: column; }
.rowName { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowName .you { color: var(--accent); font-weight: 600; font-size: 11px; margin-left: 6px; }
.rowLoc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------- join ------------------------------- */

#join {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, rgba(5, 14, 10, 0.25), rgba(4, 10, 8, 0.78));
}

.joinCard {
  width: min(92vw, 380px);
  border-radius: 22px;
  padding: 26px 24px 20px;
  text-align: center;
}

.logo { font-size: 40px; line-height: 1; margin-bottom: 6px; }

h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.tagline {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.geoPreview {
  background: rgba(126, 231, 135, 0.12);
  border: 1px solid rgba(126, 231, 135, 0.3);
  color: var(--accent-dim);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

#nameInput {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 16px;
  padding: 13px 14px;
  outline: none;
}

#nameInput:focus { border-color: rgba(126, 231, 135, 0.6); }
#nameInput::placeholder { color: var(--muted); }

.colorRow {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease;
}

.swatch[aria-checked="true"] {
  transform: scale(1.18);
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

#enterBtn {
  width: 100%;
  border: 0;
  border-radius: 13px;
  padding: 15px;
  font-size: 16.5px;
  font-weight: 800;
  color: #06230f;
  background: linear-gradient(180deg, #8bf19a, #45c46a);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

#enterBtn:active { transform: scale(0.975); }
#enterBtn:disabled { opacity: 0.55; }

.joinMsg {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.joinMeta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------- toast ------------------------------ */

#toast {
  position: fixed;
  top: calc(64px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  max-width: min(88vw, 460px);
  text-align: center;
  animation: msgIn 0.2s ease;
  transition: opacity 0.4s ease;
}

#toast.faded { opacity: 0; }

@keyframes msgIn {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ------------------------------ wallet ----------------------------- */

#walletChip {
  position: fixed;
  top: calc(52px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #ffe08a;
  z-index: 20;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ------------------------- interact button ------------------------- */

#btnInteract {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--sab));
  transform: translateX(-50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(126, 231, 135, 0.9);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(126, 231, 135, 0.6);
  font-size: 27px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  z-index: 30;
  touch-action: manipulation;
  animation: popIn 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}

#btnInteract:active { transform: translateX(-50%) scale(0.9); }
#btnInteract::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(126, 231, 135, 0.7);
  animation: ping 1.6s ease-out infinite;
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* --------------------- proximity chat bar -------------------------- */

#proxBar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--sab));
  transform: translateX(-50%);
  width: min(94vw, 540px);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  z-index: 41;
  border-color: rgba(126, 231, 135, 0.55);
}

#proxTag {
  flex: none;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--accent);
  background: rgba(126, 231, 135, 0.14);
  border-radius: 999px;
  padding: 5px 9px;
  white-space: nowrap;
}

#proxInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16px;
  padding: 8px 0;
}

#proxInput::placeholder { color: var(--muted); }

#proxSend {
  border: 0;
  background: var(--accent);
  color: #06230f;
  font-weight: 800;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  flex: none;
}

#proxSend:active { transform: scale(0.92); }

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

#shopBody {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.shopCat {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding: 9px 8px 5px;
}

.shopRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 11px;
}

.shopRow:hover { background: rgba(255, 255, 255, 0.05); }

.shopIcon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 17px;
  flex: none;
}

.shopInfo { flex: 1; min-width: 0; }
.shopName { font-weight: 700; font-size: 13.5px; }
.shopPrice { font-size: 12px; color: var(--muted); }

.shopBtn {
  border: 0;
  border-radius: 9px;
  padding: 8px 13px;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
  flex: none;
  background: linear-gradient(180deg, #8bf19a, #45c46a);
  color: #06230f;
}

.shopBtn.owned { background: rgba(255, 255, 255, 0.12); color: var(--muted); }
.shopBtn.equipped { background: var(--accent); color: #06230f; }
.shopBtn.poor { background: rgba(255, 255, 255, 0.08); color: #ff8787; }
.shopBtn:active { transform: scale(0.95); }

/* --------------------------- task board ---------------------------- */

#taskPost {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.chipRow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.chipRow:last-of-type { margin-bottom: 9px; }

.tchip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.tchip[aria-checked="true"] {
  background: rgba(126, 231, 135, 0.16);
  border-color: rgba(126, 231, 135, 0.55);
  color: var(--accent);
}

.postRow {
  display: flex;
  gap: 6px;
}

.postRow input {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}

.postRow input:focus { border-color: rgba(126, 231, 135, 0.6); }
.postRow input::placeholder { color: var(--muted); }
#taskTarget { flex: 1; }
#taskReward { width: 74px; }

#taskPostBtn {
  border: 0;
  border-radius: 9px;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #06230f;
  background: linear-gradient(180deg, #8bf19a, #45c46a);
  cursor: pointer;
  touch-action: manipulation;
  flex: none;
}

#taskPostBtn:active { transform: scale(0.95); }

#taskList {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  max-height: min(38vh, 300px);
}

.taskRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 11px;
}

.taskRow:hover { background: rgba(255, 255, 255, 0.05); }

.taskMain { flex: 1; min-width: 0; }
.taskWhat {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.taskPay { font-size: 12px; color: #ffe08a; font-variant-numeric: tabular-nums; }

.taskBtn {
  border: 0;
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  touch-action: manipulation;
  flex: none;
  background: linear-gradient(180deg, #8bf19a, #45c46a);
  color: #06230f;
}

.taskBtn.mine { background: rgba(255, 255, 255, 0.12); color: var(--muted); }
.taskBtn:active { transform: scale(0.95); }
.taskEmpty { color: var(--muted); font-size: 13px; padding: 14px 10px; text-align: center; }

@media (min-width: 900px) {
  .brand { font-size: 15px; }
  #chatLog { font-size: 14px; bottom: calc(24px + var(--sab)); }
}
