:root {
  color-scheme: dark;
  --bg: #0f1720;
  --bg-soft: #162231;
  --panel: rgba(10, 18, 28, 0.88);
  --panel-strong: rgba(14, 23, 34, 0.96);
  --line: rgba(255, 255, 255, 0.1);
  --text: #edf3ea;
  --muted: #9eb0a4;
  --gold: #f0c36b;
  --mint: #7edcb2;
  --hot: #ff8b61;
  --sky: #91c6ff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --asset-floor: url("./assets/tilesets/chaotic-farming-floor.png");
  --asset-tilemap: url("./assets/tilesets/chaotic-farming-tilemap.png");
  --asset-harvest: url("./assets/sprites/chaotic-farming-harvest.png");
  --asset-tools: url("./assets/ui/chaotic-farming-tools.png");
  --asset-idle: url("./assets/portraits/chaotic-farming-idle.png");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 180, 112, 0.2), transparent 32%),
    radial-gradient(circle at top right, rgba(110, 176, 255, 0.18), transparent 26%),
    linear-gradient(180deg, #182433 0%, #101823 45%, #091019 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 90%);
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(19, 29, 42, 0.94), rgba(9, 15, 23, 0.96));
  box-shadow: var(--shadow);
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 54px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.16));
  pointer-events: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
  background:
    linear-gradient(180deg, rgba(19, 29, 42, 0.76), rgba(9, 15, 23, 0.94)),
    radial-gradient(circle at right top, rgba(126, 220, 178, 0.16), transparent 28%),
    linear-gradient(120deg, rgba(240, 195, 107, 0.15), transparent 32%),
    var(--asset-tilemap);
  background-repeat: repeat, no-repeat, no-repeat, repeat;
  background-size: auto, auto, auto, 160px 160px;
}

.hero-copy {
  max-width: 700px;
}

.hero h1,
.section-heading h2,
.brief-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: clamp(2.8rem, 5vw, 4.7rem);
}

.hero-text,
.section-note,
.neighbor-flavor,
.neighbor-heat,
.brief-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 12px;
  min-width: min(100%, 380px);
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.crop-card,
.plot-card,
.automation-card,
.event-item,
.brief-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.stat-card,
.brief-card {
  padding: 16px;
  text-align: left;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  color: var(--text);
}

.brief-card {
  min-height: 154px;
  background:
    linear-gradient(180deg, rgba(9, 15, 23, 0.82), rgba(9, 15, 23, 0.92)),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.08), transparent 34%),
    var(--asset-tools);
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: center, top right, right 12px bottom 12px;
  background-size: auto, auto, 56px 38px;
}

.brief-title {
  font-size: 1.28rem;
}

.brief-card.tone-ready {
  border-color: rgba(240, 195, 107, 0.3);
}

.brief-card.tone-alert {
  border-color: rgba(255, 139, 97, 0.32);
}

.brief-card.tone-agent {
  border-color: rgba(145, 198, 255, 0.28);
}

.brief-card.tone-calm {
  border-color: rgba(126, 220, 178, 0.22);
}

.layout > .panel:nth-child(1),
.layout > .panel:nth-child(2),
.layout > .panel:nth-child(3),
.layout > .panel:nth-child(4) {
  grid-column: span 6;
}

.panel-wide {
  grid-column: 1 / -1;
}

.section-heading,
.toolbar,
.neighbor-meta {
  position: relative;
  z-index: 1;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.section-note {
  max-width: 220px;
  text-align: right;
}

.crop-market,
.plot-grid,
.automation-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

.crop-market {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.plot-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.neighbor-grid {
  margin-top: 14px;
}

.crop-card,
.plot-card,
.automation-card {
  padding: 16px;
}

.plot-card::before,
.automation-card::before {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  opacity: 0.12;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.plot-card::before {
  background-image: var(--asset-harvest);
}

.automation-card::before {
  background-image: var(--asset-idle);
  image-rendering: pixelated;
}

.crop-card.selected {
  outline: 2px solid rgba(240, 195, 107, 0.6);
  background: linear-gradient(180deg, rgba(240, 195, 107, 0.15), rgba(255, 255, 255, 0.04));
}

.card-topline,
.plot-state,
.automation-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.crop-name,
.plot-title,
.automation-title {
  margin: 0;
  font-size: 1.08rem;
}

.crop-accent,
.plot-tag,
.status-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crop-meta,
.plot-meta,
.automation-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.meta-block {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-value {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.action-button,
.ghost-button,
.tab-button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.action-button:hover,
.ghost-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.action-button {
  width: 100%;
  color: #091019;
  background: linear-gradient(180deg, #f0c36b, #d29a45);
  font-weight: 700;
}

.ghost-button,
.tab-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.tab-button.active {
  background: rgba(145, 198, 255, 0.18);
  outline: 1px solid rgba(145, 198, 255, 0.45);
}

.plot-card.empty {
  background:
    linear-gradient(180deg, rgba(126, 220, 178, 0.12), rgba(255, 255, 255, 0.04)),
    var(--asset-floor),
    rgba(255, 255, 255, 0.04);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: auto, 32px 32px, auto;
}

.plot-card.growing {
  background:
    linear-gradient(180deg, rgba(145, 198, 255, 0.18), rgba(255, 255, 255, 0.04)),
    var(--asset-floor),
    rgba(255, 255, 255, 0.04);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: auto, 32px 32px, auto;
}

.plot-card.ready {
  background:
    linear-gradient(180deg, rgba(240, 195, 107, 0.22), rgba(255, 255, 255, 0.04)),
    var(--asset-floor),
    rgba(255, 255, 255, 0.04);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: auto, 32px 32px, auto;
}

.plot-card.neighbor.ready {
  background:
    linear-gradient(180deg, rgba(255, 139, 97, 0.18), rgba(255, 255, 255, 0.04)),
    var(--asset-floor),
    rgba(255, 255, 255, 0.04);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: auto, 32px 32px, auto;
}

.plot-copy {
  min-height: 60px;
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.45;
}

.progress-track {
  margin: 12px 0 16px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7edcb2, #f0c36b);
}

.neighbor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.neighbor-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.neighbor-flavor,
.neighbor-heat {
  flex: 1;
}

.status-pill.locked,
.crop-accent.locked {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.status-pill.idle {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.status-pill.running,
.crop-accent.profit {
  background: rgba(126, 220, 178, 0.18);
  color: var(--mint);
}

.status-pill.ready,
.crop-accent.fast {
  background: rgba(240, 195, 107, 0.18);
  color: var(--gold);
}

.status-pill.alert,
.crop-accent.risk {
  background: rgba(255, 139, 97, 0.18);
  color: var(--hot);
}

.event-log {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.event-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;
  border-left: 3px solid transparent;
}

.event-item.tone-alert {
  border-left-color: rgba(255, 139, 97, 0.85);
}

.event-item.tone-ready {
  border-left-color: rgba(240, 195, 107, 0.85);
}

.event-item.tone-agent {
  border-left-color: rgba(145, 198, 255, 0.85);
}

.event-item.tone-heat {
  border-left-color: rgba(255, 139, 97, 0.55);
}

.event-item.tone-calm {
  border-left-color: rgba(126, 220, 178, 0.55);
}

.event-time {
  color: var(--gold);
  font-size: 0.84rem;
}

.event-text {
  margin: 0;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  justify-content: end;
}

@media (max-width: 1100px) {
  .briefing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .hero,
  .neighbor-meta,
  .section-heading {
    flex-direction: column;
    align-items: start;
  }

  .hero-stats {
    width: 100%;
    min-width: 0;
  }

  .section-note {
    max-width: none;
    text-align: left;
  }

  .layout > .panel:nth-child(1),
  .layout > .panel:nth-child(2),
  .layout > .panel:nth-child(3),
  .layout > .panel:nth-child(4),
  .panel-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .briefing-grid,
  .hero-stats {
    grid-template-columns: 1fr;
  }
}
