:root {
  --bg: #14110e;
  --panel: rgba(36, 28, 22, 0.94);
  --line: rgba(232, 180, 90, 0.3);
  --ink: #f6eee4;
  --muted: #9a8a78;
  --warm: #e8b45a;
  --warm-hot: #ffd078;
  --ok: #6ecf7a;
  --warn: #e8b45a;
  --bad: #e05555;
  --sky: #7eb8d8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #0e0c0a;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  background: #9ec9e0;
  image-rendering: auto;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(14, 12, 10, 0.88), transparent);
  pointer-events: none;
}

#topbar button, #topbar .tb-right {
  pointer-events: auto;
}

.tb-left, .tb-mid, .tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--warm);
}

#sim-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
}

.chip {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(232, 180, 90, 0.15);
  border: 1px solid var(--line);
  color: var(--warm-hot);
}

#clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}

#day-label, #weather-label {
  color: var(--muted);
  font-size: 0.82rem;
}

#money {
  color: var(--warm-hot);
  font-size: 1.05rem;
}

.save-hint {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ok);
  letter-spacing: 0.02em;
  transition: opacity 0.2s ease;
}

#topbar button {
  font-family: inherit;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(42, 34, 26, 0.85);
  color: var(--ink);
  padding: 7px 11px;
  border-radius: 10px;
  cursor: pointer;
}

#topbar button:hover {
  border-color: var(--warm);
  background: rgba(232, 180, 90, 0.18);
}

#panel {
  position: absolute;
  top: 58px;
  right: 12px;
  width: min(310px, calc(100vw - 20px));
  max-height: calc(100dvh - 72px);
  overflow: auto;
  z-index: 12;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.tab {
  font: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: var(--ink);
  background: rgba(232, 180, 90, 0.15);
  border-color: var(--line);
}

.tab-pane.hidden { display: none; }

.mood-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.mood {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.mood.ok { background: rgba(110, 207, 122, 0.18); color: var(--ok); }
.mood.meh { background: rgba(232, 180, 90, 0.18); color: var(--warn); }
.mood.bad { background: rgba(224, 85, 85, 0.2); color: #ff8a8a; }

#mood-score {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
}

.needs { display: grid; gap: 7px; margin-bottom: 10px; }

.need {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.bar {
  height: 11px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bar i {
  display: block;
  height: 100%;
  width: 70%;
  border-radius: 6px;
  background: linear-gradient(90deg, #4aa85a, var(--ok));
  transition: width 0.2s ease, background 0.2s ease;
}

.moodlets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 8px;
}

.moodlet {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.moodlet.good { color: var(--ok); border-color: rgba(110, 207, 122, 0.35); }
.moodlet.bad { color: #ff8a8a; border-color: rgba(224, 85, 85, 0.35); }

.status, .hint-mini, .meta {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.thought {
  font-family: "Fraunces", Georgia, serif;
  font-size: 0.9rem;
  color: var(--warm-hot);
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(232, 180, 90, 0.1);
  border-radius: 8px;
  border-left: 3px solid var(--warm);
}

.skills-list { display: grid; gap: 10px; margin-bottom: 10px; }

.skill-row {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
}

.skill-row header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.skill-row strong { color: var(--ink); }

.life-block {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.life-block h3 {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warm);
  margin-bottom: 6px;
}

.life-block p { font-size: 0.88rem; line-height: 1.4; }

.rel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin: 4px 0;
  color: var(--muted);
}

.rel strong { color: var(--ink); }

.journal {
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
  display: grid;
  gap: 4px;
  max-height: 120px;
  overflow: auto;
}

.back-line {
  margin-top: 10px;
  font-size: 0.78rem;
}

.back-line a {
  color: var(--muted);
  text-decoration: none;
}

.back-line a:hover { color: var(--warm-hot); }

#menu {
  position: absolute;
  z-index: 30;
  min-width: 180px;
  max-width: 240px;
  padding: 6px;
  background: rgba(28, 22, 16, 0.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#menu.hidden { display: none; }

#menu .menu-title {
  padding: 6px 8px 4px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 800;
}

#menu button, .shop button, .create button, .create-actions button {
  font-family: inherit;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(232, 180, 90, 0.1);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

#menu button:hover, .shop button:hover {
  background: rgba(232, 180, 90, 0.22);
}

#menu button .sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}

.shop {
  position: absolute;
  z-index: 25;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: auto;
  background: rgba(28, 22, 16, 0.97);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.shop.hidden { display: none; }

.shop header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.shop h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.4rem;
}

.shop-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.shop-list { display: grid; gap: 8px; }

.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.shop-item h4 { font-size: 0.95rem; }
.shop-item p { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.visitor-banner {
  position: absolute;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 10px 14px;
  background: rgba(28, 22, 16, 0.95);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.visitor-banner.hidden { display: none; }

.visitor-banner button {
  font: inherit;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(232, 180, 90, 0.18);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 16px;
  background: rgba(28, 22, 16, 0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 700;
  pointer-events: none;
  max-width: min(90vw, 420px);
  text-align: center;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 28%, rgba(126, 184, 216, 0.22), transparent 60%),
    rgba(12, 10, 8, 0.9);
}

.overlay.hidden { display: none; }

.create {
  width: min(440px, 100%);
  padding: 28px 26px 22px;
  background: rgba(42, 34, 26, 0.97);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.create .brand {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--warm);
}

.create h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2.5rem;
  margin: 4px 0 8px;
}

.create .tag {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 14px;
}

.rules {
  list-style: none;
  margin-bottom: 16px;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}

.rules li {
  padding-left: 14px;
  position: relative;
}

.rules li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--warm);
  font-weight: 800;
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input {
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}

.swatches {
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.swatches .row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--warm);
}

.create-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.create-actions #play {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  text-align: center;
  background: linear-gradient(180deg, #f0c46a, #d49a3a);
  color: #2a1c10;
  border: none;
}

.create-actions .ghost {
  text-align: center;
  background: transparent;
}

@media (max-width: 820px) {
  #panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 44vh;
    border-radius: 16px 16px 0 0;
  }
  #topbar { padding-bottom: 4px; }
}
