:root {
  --bg: #14141a;
  --bg2: #1c1c26;
  --panel: #20202c;
  --panel2: #262635;
  --ink: #e7e4ee;
  --ink-dim: #9a94ab;
  --line: #33333f;
  --accent: #d8524a;    /* grunge red */
  --accent2: #e0a13a;   /* dirty gold */
  --flock: #6fbf73;     /* movement green */
  --heat: #e0553f;
  --grip: #7d6bd0;      /* corporate purple */
  --shadow: 0 6px 22px rgba(0,0,0,.45);
  font-size: clamp(13px, 1.15vw, 17px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.7rem;
  gap: 0.5rem;
  background:
    radial-gradient(circle at 15% -10%, rgba(216,82,74,.10), transparent 45%),
    radial-gradient(circle at 90% 110%, rgba(125,107,208,.10), transparent 45%),
    var(--bg);
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 800; letter-spacing: 0.05em;
}
.brand-bird { font-size: 1.6rem; filter: drop-shadow(0 0 6px rgba(224,161,58,.5)); }
.brand-txt { font-size: 1.15rem; text-transform: uppercase; }
.brand-txt .amp { color: var(--accent); }

#resources { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.res {
  display: flex; align-items: baseline; gap: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  min-width: 5.2rem;
}
.res-ico { font-size: 0.95rem; }
.res-val { font-weight: 800; font-variant-numeric: tabular-nums; }
.res-lbl { font-size: 0.65rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .06em; }
.res-heat .res-val { color: var(--heat); }

/* ---------- bars ---------- */
#bars { display: flex; gap: 0.6rem; }
.bar-block { flex: 1; }
.bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.6rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 0.2rem;
}
.bar-track {
  height: 0.55rem; background: #0e0e14;
  border: 1px solid var(--line); border-radius: 1rem; overflow: hidden;
}
.bar-fill { height: 100%; width: 0%; transition: width .35s ease; border-radius: 1rem; }
.grip-fill { background: linear-gradient(90deg, #5a4aa8, var(--grip)); }
.flock-fill { background: linear-gradient(90deg, #3f8a4c, var(--flock)); }
.heat-fill { background: linear-gradient(90deg, #b8452f, var(--heat)); }

/* ---------- main grid ---------- */
#main {
  flex: 1;
  display: grid;
  grid-template-columns: 1.1fr 1.15fr 0.95fr;
  gap: 0.6rem;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.7rem;
  display: flex; flex-direction: column;
  min-height: 0;
  box-shadow: var(--shadow);
}
.panel-h {
  font-size: 0.72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent2); margin-bottom: 0.5rem; font-weight: 800;
  display: flex; align-items: baseline; gap: 0.5rem;
}
.panel-sub { color: var(--ink-dim); font-size: 0.6rem; letter-spacing: .05em; font-weight: 600; }

/* ---------- stage / gig ---------- */
#stage { align-items: stretch; }
#gig-area { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.7rem; text-align: center; }
.gig-verdict {
  font-size: 1rem; font-weight: 700; min-height: 2.4rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.gig-verdict.good { color: var(--flock); }
.gig-verdict.bad { color: var(--heat); }

.gig-meter {
  position: relative; height: 2.2rem;
  background: #0d0d13; border: 1px solid var(--line); border-radius: 0.5rem;
  overflow: hidden; margin: 0 auto; width: 92%;
}
.gig-sweet {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(111,191,115,.45), rgba(111,191,115,.15));
  border-left: 2px solid var(--flock); border-right: 2px solid var(--flock);
  box-shadow: 0 0 14px rgba(111,191,115,.5);
}
.gig-needle {
  position: absolute; top: -2px; bottom: -2px; width: 3px;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  left: 0;
}
.gig-combo { font-size: 0.85rem; font-weight: 800; color: var(--accent2); letter-spacing: .05em; }

#gig-controls { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; margin-top: 0.3rem; }
.big-btn {
  width: 92%; padding: 0.75rem 1rem; font-size: 0.95rem; font-weight: 800;
  border: none; border-radius: 0.6rem; cursor: pointer; letter-spacing: .03em;
  color: #14141a; transition: transform .06s ease, filter .15s ease;
  text-transform: uppercase;
}
.big-btn:active { transform: translateY(2px); }
.big-btn:disabled { filter: grayscale(.7) brightness(.6); cursor: not-allowed; }
.big-btn.scream { background: linear-gradient(180deg, #e5645b, var(--accent)); color: #fff; }
.big-btn.hit { background: linear-gradient(180deg, #7fd083, var(--flock)); font-size: 1.15rem; animation: pulse .5s infinite alternate; }
.big-btn.laylow { background: linear-gradient(180deg, #3a3a4d, #2b2b3a); color: var(--ink); border: 1px solid var(--line); }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.25); } }
.gig-tip { font-size: 0.62rem; color: var(--ink-dim); }

/* ---------- ops ---------- */
#ops-list { overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding-right: 0.2rem; }
.op {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 0.55rem;
  padding: 0.55rem 0.65rem; text-align: left; cursor: pointer;
  transition: border-color .12s ease, transform .06s ease;
}
.op:hover:not(.locked) { border-color: var(--accent); }
.op:active:not(.locked) { transform: translateY(1px); }
.op.locked { opacity: 0.45; cursor: not-allowed; }
.op-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.op-name { font-weight: 800; font-size: 0.85rem; }
.op-name .op-ico { margin-right: 0.35rem; }
.op-cost { font-size: 0.62rem; color: var(--ink-dim); white-space: nowrap; }
.op-cost .c-cred { color: var(--accent2); }
.op-cost .c-dist { color: #6bb6d0; }
.op-cost .c-heat { color: var(--heat); }
.op-desc { font-size: 0.66rem; color: var(--ink-dim); margin-top: 0.25rem; line-height: 1.35; }

/* ---------- aviary + log ---------- */
#side { min-height: 0; }
#aviary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
  gap: 0.35rem; overflow-y: auto; max-height: 34%; align-content: start;
  padding: 0.15rem;
}
.bird {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; border-radius: 0.5rem; cursor: help;
  background: var(--panel2); border: 1px solid var(--line);
  position: relative;
}
.bird.common { border-color: #4a4a5c; }
.bird.rare { border-color: #4a86c7; box-shadow: 0 0 8px rgba(74,134,199,.35); }
.bird.legendary { border-color: var(--accent2); box-shadow: 0 0 10px rgba(224,161,58,.5); }
.bird.hiding { opacity: 0.3; filter: grayscale(1); }
.bird .bird-n {
  position: absolute; bottom: -1px; right: 1px; font-size: 0.55rem;
  background: rgba(0,0,0,.6); border-radius: 0.3rem; padding: 0 0.2rem; color: var(--ink);
}
.aviary-empty { grid-column: 1/-1; font-size: 0.66rem; color: var(--ink-dim); padding: 0.5rem 0; }

.log-h { margin-top: 0.6rem; }
#log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.68rem; }
.log-line { padding: 0.25rem 0.4rem; border-radius: 0.35rem; background: var(--bg2); line-height: 1.3; }
.log-line.good { border-left: 2px solid var(--flock); }
.log-line.bad { border-left: 2px solid var(--heat); }
.log-line.bird { border-left: 2px solid var(--accent2); }
.log-line.info { border-left: 2px solid var(--line); color: var(--ink-dim); }

/* ---------- bottom bar ---------- */
#botbar { display: flex; align-items: center; gap: 0.5rem; }
.mini-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  padding: 0.4rem 0.7rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.72rem;
  font-weight: 600;
}
.mini-btn:hover { border-color: var(--accent2); }
.mini-btn.danger:hover { border-color: var(--heat); color: var(--heat); }
.footer-flavor { margin-left: auto; font-size: 0.68rem; color: var(--ink-dim); font-style: italic; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 1rem;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.8rem;
  max-width: 40rem; width: 100%; max-height: 85vh; overflow-y: auto;
  padding: 1.4rem; position: relative; box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 0.6rem; right: 0.8rem; background: none; border: none;
  color: var(--ink-dim); font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--accent); }
#modal-content h2 { color: var(--accent2); margin-bottom: 0.6rem; font-size: 1.2rem; }
#modal-content h3 { color: var(--accent); margin: 0.9rem 0 0.3rem; font-size: 0.95rem; }
#modal-content p, #modal-content li { font-size: 0.82rem; line-height: 1.5; color: var(--ink); }
#modal-content ul { margin-left: 1.1rem; margin-top: 0.3rem; }
#modal-content .win-big { font-size: 1.5rem; color: var(--flock); font-weight: 800; text-align: center; margin: 0.5rem 0; }

.lb-table { width: 100%; border-collapse: collapse; margin-top: 0.6rem; font-size: 0.78rem; }
.lb-table th, .lb-table td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line); }
.lb-table th { color: var(--ink-dim); font-size: 0.65rem; text-transform: uppercase; letter-spacing: .06em; }
.lb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb-win { color: var(--flock); }
.lb-form { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.lb-form input {
  flex: 1; background: var(--bg2); border: 1px solid var(--line); color: var(--ink);
  padding: 0.5rem 0.7rem; border-radius: 0.5rem; font-size: 0.85rem;
}
.lb-form button {
  background: var(--accent); color: #fff; border: none; border-radius: 0.5rem;
  padding: 0.5rem 1rem; cursor: pointer; font-weight: 700;
}

.hidden { display: none !important; }

/* screen shake on big events */
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(3px, -3px); }
  75% { transform: translate(-2px, 3px); }
}
.shake { animation: shake .4s; }

@media (max-width: 820px) {
  #main { grid-template-columns: 1fr; grid-auto-rows: minmax(0, auto); overflow-y: auto; }
  #app { overflow-y: auto; height: auto; min-height: 100vh; }
  html, body { overflow: auto; }
}
