/* The canvas world is the hero. The HUD is monospace signage around the edges:
   present, legible, never competing with the build. */

:root {
  --ink: #e7e9ee;
  --muted: #8a90a0;
  --panel: rgba(20, 22, 28, 0.72);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #f2c14e;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #15171c;
  color: var(--ink);
  font-family: var(--mono);
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  cursor: crosshair;
}

/* top bar -------------------------------------------------------------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end; /* only the status/logout cluster remains; level, gold, and the name live in the canvas HUD now */
  padding: 14px 18px;
  pointer-events: none;
}

#status {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  backdrop-filter: blur(8px);
}

/* toolbar -------------------------------------------------------------- */
#toolbar {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(8px);
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tool-group + .tool-group {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.tool-group-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.tool-row {
  display: flex;
  gap: 6px;
}

.tool {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid transparent;
  border-radius: 9px;
  padding: 6px 9px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.08s ease, opacity 0.1s ease;
}
.tool:hover {
  transform: translateY(-2px);
}
.tool.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.2);
}
.tool.broke {
  opacity: 0.4;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.tool-cost {
  font-size: 11px;
  color: var(--accent);
}

/* bottom help ---------------------------------------------------------- */
#help {
  position: fixed;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

#help b {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 560px) {
  #help span:nth-child(3) {
    display: none;
  }
}

/* auth gating ---------------------------------------------------------- */
/* The game chrome stays hidden until there's a session. */
#hud,
#toolbar,
#inventory,
#help {
  display: none;
}
body.authed #hud {
  display: flex;
}
body.authed #toolbar {
  display: flex;
}
body.authed #inventory {
  display: block;
}
body.authed #help {
  display: flex;
}

/* inventory ------------------------------------------------------------ */
#inventory {
  position: fixed;
  left: 18px;
  top: 64px;
  width: 168px;
  padding: 12px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.panel-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.inv-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.inv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.inv-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  image-rendering: pixelated;
}

.inv-name {
  flex: 1;
  text-transform: capitalize;
}

.inv-count {
  color: var(--accent);
  font-weight: 600;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#logout {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: color 0.1s ease, border-color 0.1s ease;
}
#logout:hover {
  color: var(--ink);
  border-color: var(--accent);
}

/* login gate ----------------------------------------------------------- */
#auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1d2128, #121419 70%);
  z-index: 10;
}
body.authed #auth-overlay {
  display: none;
}

#auth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(340px, calc(100vw - 40px));
  padding: 28px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.auth-brand {
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 15px;
  text-align: center;
}
.auth-brand span {
  color: var(--accent);
}

.auth-tagline {
  margin-top: -4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

#auth-card input {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.1s ease;
}
#auth-card input:focus {
  border-color: var(--accent);
}

#auth-card button {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  padding: 11px;
  cursor: pointer;
  transition: filter 0.1s ease, opacity 0.1s ease;
}
#auth-card button:disabled {
  opacity: 0.5;
  cursor: default;
}
#auth-login {
  background: var(--accent);
  color: #1a1305;
}
#auth-login:hover:not(:disabled) {
  filter: brightness(1.08);
}
#auth-card button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
#auth-card button.secondary:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--accent);
}

.auth-error {
  font-size: 12px;
  color: #f08a7a;
  background: rgba(240, 110, 90, 0.1);
  border: 1px solid rgba(240, 110, 90, 0.25);
  border-radius: 8px;
  padding: 8px 11px;
}

.auth-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* visiting -------------------------------------------------------------- */
/* The edit toolbar is meaningless on someone else's plot. */
body.visiting #toolbar { display: none; }

#visit-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

#visit-home {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
}
#visit-home:hover {
  border-color: var(--accent);
}

/* "home" only appears while visiting */
#visit-home { display: none; }
body.visiting #visit-home { display: inline-block; }

#viewing {
  display: none;
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  backdrop-filter: blur(8px);
}
body.visiting #viewing { display: block; }

/* hide edit hints while visiting */
body.visiting #help { display: none; }

/* Server message log — bottom-left, fades out, doesn't block clicks. */
#log {
  position: fixed;
  left: 12px;
  /* clear the in-canvas hotbar (BAR_H = 82px in ui.js) so messages sit above it */
  bottom: 94px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(340px, 70vw);
  pointer-events: none;
  z-index: 6;
}
.log-msg {
  background: rgba(20, 22, 28, 0.88);
  color: #e8e6df;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 6px 11px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.35;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  opacity: 1;
  transition: opacity 0.5s ease;
}
.log-msg.fade { opacity: 0; }

/* Tutorial objective banner — top-center, shown only during the tutorial. */
#quest {
  display: none;
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(440px, 84vw);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 9px 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 7;
}
#quest.show { display: block; }
.quest-title {
  font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.quest-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(242, 193, 78, 0.16);
  color: var(--accent);
  font-size: 12px;
}
.quest-hint {
  margin-top: 3px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.4;
  color: #cfccc3;
}

/* Generic modal overlay — list-for-sale today, reusable for later forms. --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 14, 0.55);
  z-index: 20;
}
.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, calc(100vw - 40px));
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.sell-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  text-transform: capitalize;
}
.sell-item-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}

.modal-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}
.modal-label input,
.modal-select {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.1s ease;
}
.modal-label input:focus,
.modal-select:focus {
  border-color: var(--accent);
}
.modal-select {
  text-transform: capitalize;
}

.sell-total {
  font-size: 12px;
  color: var(--accent);
  min-height: 15px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}
.modal-actions button {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  padding: 11px;
  cursor: pointer;
  transition: filter 0.1s ease, opacity 0.1s ease;
}
.modal-actions button:disabled {
  opacity: 0.5;
  cursor: default;
}
#sell-confirm {
  background: var(--accent);
  color: #1a1305;
}
#sell-confirm:hover:not(:disabled) {
  filter: brightness(1.08);
}
.modal-actions button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.modal-actions button.secondary:hover {
  color: var(--ink);
  border-color: var(--accent);
}
