:root { font-family: system-ui, Arial, sans-serif; }

body { margin: 0; background: #111; color: #eee; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px; }

a { color: #8fd3ff; text-decoration: none; }
a:hover { text-decoration: underline; }

.card {
  background:#1b1b1b;
  border:1px solid #2a2a2a;
  border-radius:14px;
  padding:16px;
  margin:12px 0;
}

.row { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
.hud { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }

button, input, select {
  background:#2a2a2a;
  color:#eee;
  border:1px solid #3a3a3a;
  border-radius:10px;
  padding:10px 12px;
  font-size:16px;
}

button:hover { border-color:#6a6a6a; cursor:pointer; }
small { color:#aaa; }

canvas {
  background:#000;
  border:1px solid #333;
  border-radius:10px;
}

/* --- Mobile friendly additions --- */
canvas {
  width: 100%;
  height: auto;
  max-width: 900px;
  touch-action: none; /* stops scrolling while playing */
}

button { min-height: 44px; }
input { min-height: 44px; }

/* Touch control panel */
.touch-pad {
  display: none;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.touch-pad button {
  flex: 1;
  font-size: 18px;
  padding: 14px 16px;
}

/* Show touch controls on small screens */
@media (max-width: 720px) {
  .touch-pad { display: flex; }
}

#status, #log, #feedback, #msg { min-height: 1.2em; margin-top: 8px; }

/* === Fun animated background === */
body {
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(120deg, #0b1020, #1a0b2e, #0b2a2a, #1d1a0b);
  background-size: 400% 400%;
  animation: bgShift 18s ease-in-out infinite;
}

/* moving gradient */
@keyframes bgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* star/particle overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;

  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.10) 1px, transparent 2px),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,0.08) 1px, transparent 2px),
    radial-gradient(circle at 30% 70%, rgba(255,255,255,0.07) 1px, transparent 2px),
    radial-gradient(circle at 60% 80%, rgba(255,255,255,0.06) 1px, transparent 2px),
    radial-gradient(circle at 90% 90%, rgba(255,255,255,0.07) 1px, transparent 2px),
    radial-gradient(circle at 20% 90%, rgba(255,255,255,0.06) 1px, transparent 2px),
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.06) 1px, transparent 2px);

  background-size: 220px 220px;
  opacity: 0.7;
  animation: starsDrift 35s linear infinite;
}

@keyframes starsDrift {
  from { transform: translateY(0px); }
  to   { transform: translateY(-220px); }
}

/* Make cards pop against the background */
.card, .gamebtn {
  backdrop-filter: blur(6px);
  background: rgba(15, 15, 20, 0.78);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* Slightly brighter headings */
h1, h2, h3 {
  text-shadow: 0 2px 18px rgba(0,0,0,0.55);
}

/* ================================
   CLICKER: 3x3 GRID (SHOP + SKILLS ONLY)
   Keeps old button + Random Events look
================================ */

/* SHOP grid */
#tab-shop #shop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* SKILLS grid (supports either .shopgrid or .skillgrid inside #skills) */
#tab-skills #skills > .shopgrid,
#tab-skills #skills > .skillgrid,
#tab-skills #skills .shopgrid,
#tab-skills #skills .skillgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Make sure each item stretches in the grid WITHOUT redesigning buttons */
#tab-shop #shop .shopitem,
#tab-skills #skills .shopitem {
  width: 100%;
  margin: 0;
}

/* IMPORTANT: prevent mobile clipping */
#tab-shop,
#tab-skills,
#tab-shop .card,
#tab-skills .card,
#shop,
#skills {
  overflow: visible !important;
  max-height: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  #tab-shop #shop,
  #tab-skills #skills > .shopgrid,
  #tab-skills #skills > .skillgrid,
  #tab-skills #skills .shopgrid,
  #tab-skills #skills .skillgrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  #tab-shop #shop,
  #tab-skills #skills > .shopgrid,
  #tab-skills #skills > .skillgrid,
  #tab-skills #skills .shopgrid,
  #tab-skills #skills .skillgrid {
    grid-template-columns: 1fr;
  }
}

/* ================================
   CLICKER: MOBILE HUD FIX
   Prevent pills/status from disappearing
================================ */

@media (max-width: 600px) {
  /* Make the HUD wrap nicely instead of spacing out */
  .hud {
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  /* Make each pill smaller + allow it to fit */
  .pill {
    font-size: 12px !important;
    padding: 6px 8px !important;
    white-space: normal !important;   /* IMPORTANT: stops overflow on phones */
    flex: 1 1 auto;
  }

  /* Ensure the XP bar always shows */
  .bar {
    height: 12px !important;
    margin-top: 10px !important;
  }
}

/* =========================================================
   NeoLife Simulator UI Upgrade (scoped)
   Add: <body class="dark neolife"> in simulator HTML
   Paste this at the BOTTOM of games.css
   ========================================================= */

body.neolife {
  --bg0: #070a12;
  --bg1: rgba(255,255,255,0.04);
  --bg2: rgba(255,255,255,0.06);
  --line: rgba(255,255,255,0.10);
  --line2: rgba(255,255,255,0.14);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --muter: rgba(255,255,255,0.55);
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
  --shadow2: 0 10px 24px rgba(0,0,0,0.35);
  --r: 16px;
  --r2: 22px;
  --pad: 14px;
  --pad2: 18px;
  --max: 1220px;
  --gap: 14px;

  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.35;

  background:
    radial-gradient(1200px 700px at 10% 10%, rgba(110, 70, 255, 0.22), transparent 60%),
    radial-gradient(1000px 700px at 90% 20%, rgba(0, 190, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 50% 90%, rgba(255, 120, 70, 0.10), transparent 60%),
    var(--bg0);
}

/* Light mode (your JS toggles body.light) */
body.neolife.light {
  --bg0: #f6f7fb;
  --bg1: rgba(0,0,0,0.04);
  --bg2: rgba(0,0,0,0.06);
  --line: rgba(0,0,0,0.10);
  --line2: rgba(0,0,0,0.14);
  --text: rgba(0,0,0,0.88);
  --muted: rgba(0,0,0,0.65);
  --muter: rgba(0,0,0,0.55);
  --shadow: 0 14px 40px rgba(0,0,0,0.10);
  --shadow2: 0 10px 22px rgba(0,0,0,0.08);

  background:
    radial-gradient(1100px 650px at 10% 10%, rgba(110, 70, 255, 0.18), transparent 60%),
    radial-gradient(1000px 650px at 90% 20%, rgba(0, 190, 255, 0.14), transparent 55%),
    radial-gradient(900px 600px at 50% 90%, rgba(255, 120, 70, 0.10), transparent 60%),
    var(--bg0);
}

body.neolife * { box-sizing: border-box; }
body.neolife h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0.2px; }
body.neolife h4 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 650; }

body.neolife .muted { color: var(--muted); }
body.neolife .small { font-size: 12px; }
body.neolife .row { display: flex; align-items: center; gap: 10px; }
body.neolife .row.between { justify-content: space-between; }
body.neolife .row.gap { gap: 10px; }
body.neolife .wrap { flex-wrap: wrap; }

/* ---- Global page centering ---- */
body.neolife .topbar,
body.neolife .statusbar,
body.neolife .stats,
body.neolife .layout,
body.neolife .logbox {
  width: min(var(--max), calc(100% - 22px));
  margin: 0 auto;
}

/* ---- Topbar ---- */
body.neolife .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--r2);
  background: color-mix(in srgb, var(--bg1) 70%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow2);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

body.neolife .brand {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
  user-select: none;
}

body.neolife .top-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- Buttons ---- */
body.neolife .btn {
  border: 1px solid var(--line2);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
  user-select: none;
}

body.neolife .btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--line2) 60%, white 20%);
  background: rgba(255,255,255,0.08);
}

body.neolife .btn:active { transform: translateY(0px) scale(0.98); }
body.neolife .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

body.neolife .btn.ghost {
  background: transparent;
  border-color: var(--line);
}

body.neolife .btn.danger {
  border-color: color-mix(in srgb, #ff4d4d 50%, var(--line2));
  background: color-mix(in srgb, #ff4d4d 14%, transparent);
}

/* ---- Pills ---- */
body.neolife .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* ---- Statusbar ---- */
body.neolife .statusbar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

/* ---- Stats (compact & clean) ---- */
body.neolife .stats {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--gap);
}

@media (max-width: 980px) {
  body.neolife .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

body.neolife .stat {
  padding: var(--pad);
  border-radius: var(--r);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

body.neolife .stat .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

body.neolife .stat .value {
  margin-top: 8px;
  font-weight: 800;
  font-size: 14px;
}

body.neolife .bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}

body.neolife .bar.mini { height: 8px; }

body.neolife #barEnergy,
body.neolife #barHunger,
body.neolife #barHappy,
body.neolife #barHealth,
body.neolife #barRep,
body.neolife #barQuest {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 220ms ease;
  background: linear-gradient(90deg, rgba(90,160,255,0.95), rgba(140,90,255,0.95));
}

/* ---- Main layout: sticky left panel ---- */
body.neolife .layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

@media (max-width: 980px) {
  body.neolife .layout { grid-template-columns: 1fr; }
}

body.neolife .left {
  position: sticky;
  top: 86px; /* below topbar */
  align-self: start;
  display: grid;
  gap: var(--gap);
}

@media (max-width: 980px) {
  body.neolife .left { position: static; }
}

/* ---- Cards ---- */
body.neolife .card {
  padding: var(--pad2);
  border-radius: var(--r2);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  box-shadow: var(--shadow2);
}

body.neolife .card.actions .btn {
  width: 100%;
  justify-content: center;
}

body.neolife .card.actions {
  display: grid;
  gap: 8px;
}

body.neolife ul#statusList {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

/* ---- Tabs ---- */
body.neolife .tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: auto;
  padding: 10px;
  border-radius: var(--r2);
  background: rgba(255,255,255,0.040);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(0,0,0,0.20);
  scroll-snap-type: x mandatory;
}

body.neolife .tabs::-webkit-scrollbar { height: 8px; }
body.neolife .tabs::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
}

body.neolife .tab {
  scroll-snap-align: start;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

body.neolife .tab:hover {
  transform: translateY(-1px);
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

body.neolife .tab.active {
  color: var(--text);
  border-color: rgba(140,90,255,0.55);
  background: linear-gradient(90deg, rgba(140,90,255,0.20), rgba(90,160,255,0.14));
}

/* ---- Panes ---- */
body.neolife .panes {
  margin-top: var(--gap);
  padding: var(--pad2);
  border-radius: var(--r2);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 420px;
}

body.neolife .pane { display: none; }
body.neolife .pane.active { display: block; }

/* ---- Grids ---- */
body.neolife #invGrid,
body.neolife #shopGrid,
body.neolife #achGrid,
body.neolife #locGrid,
body.neolife #npcGrid,
body.neolife #carShopGrid,
body.neolife #garageGrid {
  display: grid;
  gap: 12px;
}

body.neolife #invGrid,
body.neolife #shopGrid,
body.neolife #achGrid,
body.neolife #npcGrid,
body.neolife #carShopGrid,
body.neolife #garageGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  body.neolife #invGrid,
  body.neolife #shopGrid,
  body.neolife #achGrid,
  body.neolife #npcGrid,
  body.neolife #carShopGrid,
  body.neolife #garageGrid { grid-template-columns: 1fr; }
}

body.neolife #locGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 980px) { body.neolife #locGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { body.neolife #locGrid { grid-template-columns: 1fr; } }

body.neolife .item,
body.neolife .shopitem,
body.neolife .skill,
body.neolife .ach,
body.neolife .loc,
body.neolife .npc,
body.neolife .car {
  padding: 14px;
  border-radius: var(--r);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
}

body.neolife .name {
  font-weight: 900;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}

body.neolife .desc {
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 10px;
}

body.neolife .meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muter);
  font-size: 12px;
  margin-bottom: 10px;
}

/* Skill layout tweak */
body.neolife .skill .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* ---- Inputs ---- */
body.neolife select,
body.neolife input,
body.neolife textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--text);
  outline: none;
}

body.neolife label { display: grid; gap: 8px; margin: 12px 0; color: var(--muted); }

body.neolife textarea {
  min-height: 110px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- Minigames cards ---- */
body.neolife .mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) { body.neolife .mini-grid { grid-template-columns: 1fr; } }

/* ---- Dividers ---- */
body.neolife .divider {
  height: 1px;
  background: var(--line);
  border: none;
  margin: 12px 0;
}
body.neolife .divider.mini { margin: 10px 0; opacity: 0.75; }

/* ---- Log ---- */
body.neolife .logbox {
  margin-top: var(--gap);
  margin-bottom: 20px;
  padding: var(--pad2);
  border-radius: var(--r2);
  background: rgba(255,255,255,0.040);
  border: 1px solid var(--line);
  box-shadow: var(--shadow2);
}

body.neolife #log {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  overflow: auto;
  max-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

/* ---- Modal ---- */
body.neolife .modal.hidden { display: none; }

body.neolife .modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}

body.neolife .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}

body.neolife .modal-box {
  position: relative;
  width: min(680px, 100%);
  border-radius: var(--r2);
  padding: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 70%, transparent);
  box-shadow: var(--shadow);
  animation: neolifePop 160ms ease-out;
}

@keyframes neolifePop {
  from { transform: translateY(10px) scale(0.98); opacity: 0.6; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

body.neolife .modal-box h3 { margin: 0 0 6px; }
body.neolife .modal-box .muted.small { margin-bottom: 12px; }

/* Make the “help” list look nicer */
body.neolife .modal-box ul { margin: 10px 0; padding-left: 18px; color: var(--muted); }