:root {
  color-scheme: light;
  --ink: #161b1c;
  --muted: #64706b;
  --paper: #f6f2e8;
  --panel: #fffaf0;
  --line: #d9cfbd;
  --field: #fffcf6;
  --forest: #173f35;
  --forest-2: #245b4b;
  --brass: #b98535;
  --copper: #8f4e2f;
  --blue: #345f9c;
  --plum: #684468;
  --danger: #aa3c34;
  --shadow: 0 14px 34px rgba(32, 28, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
  min-width: 0;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--field);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  border: 1px solid rgba(22, 27, 28, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  background: #171b1c;
  color: #fffaf0;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
  white-space: nowrap;
}

.brand-lockup strong {
  font-size: 1.02rem;
}

.brand-lockup span {
  margin-top: 2px;
  color: #b9c7bf;
  font-size: 0.8rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: var(--brass);
  color: #171b1c;
  font-weight: 900;
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid rgba(255, 250, 240, 0.16);
  border-radius: 8px;
  padding: 0 12px;
  color: #dfe8e3;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
  white-space: nowrap;
}

.server-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--brass);
}

.server-dot.online {
  background: #58c27d;
}

.server-dot.offline {
  background: var(--danger);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  min-width: 0;
}

.content-area {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel,
.metric-tile,
.horse-card,
.pack-card,
.market-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.player-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  display: grid;
  gap: 20px;
}

.section-heading {
  display: grid;
  gap: 4px;
}

.section-heading p {
  margin: 0;
  color: var(--brass);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.08;
}

.section-heading h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.section-heading h2 {
  font-size: 1.2rem;
}

.row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subtle-text {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 12px;
}

.primary-button {
  padding: 0 15px;
  color: #fffaf0;
  background: var(--forest);
  font-weight: 850;
}

.primary-button:hover:not(:disabled) {
  background: var(--forest-2);
}

.ghost-button,
.feed-button {
  min-height: 38px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: #fffdf8;
  font-weight: 800;
}

.ghost-button:hover:not(:disabled),
.feed-button:hover:not(:disabled) {
  border-color: var(--forest-2);
}

.player-summary {
  display: grid;
  gap: 12px;
}

.player-summary div {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.player-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.player-summary strong {
  overflow-wrap: anywhere;
}

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

.metric-tile {
  min-width: 0;
  min-height: 92px;
  padding: 16px;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  color: var(--forest);
  font-size: 2rem;
  line-height: 1;
}

.packs-grid,
.launch-grid,
.inventory-grid,
.stable-grid,
.market-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.packs-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.launch-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.launch-group {
  display: grid;
  gap: 8px;
}

.launch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fffdf8;
}

.launch-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.launch-row span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.switch-indicator {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #c9c0af;
}

.switch-indicator::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fffaf0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.switch-indicator.is-on {
  background: var(--forest-2);
}

.switch-indicator.is-on::after {
  left: 24px;
}

.pack-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.pack-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pack-card h3 {
  margin: 0;
  font-size: 1rem;
}

.price-tag {
  align-self: start;
  border-radius: 8px;
  padding: 4px 8px;
  color: #fff;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.pack-items,
.inventory-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pack-items {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.inventory-item {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fffdf8;
}

.inventory-item span,
.horse-meta span,
.market-row span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.inventory-item strong {
  display: block;
  margin-top: 4px;
}

.breeding-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.stable-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.horse-card {
  overflow: hidden;
  box-shadow: none;
}

.horse-visual {
  position: relative;
  min-height: 178px;
  background: #dfe9df;
}

.horse-visual canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.rarity-ribbon {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 8px;
  padding: 5px 8px;
  color: #fff;
  background: var(--forest);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.rarity-ribbon.uncommon {
  background: var(--blue);
}

.rarity-ribbon.rare {
  background: var(--plum);
}

.rarity-ribbon.epic,
.rarity-ribbon.legendary {
  background: var(--copper);
}

.horse-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.horse-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.horse-title h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.18;
}

.gender-pill {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 4px 8px;
  color: #fff;
  background: var(--forest);
  font-size: 0.74rem;
  font-weight: 900;
}

.gender-pill.female {
  background: var(--plum);
}

.horse-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.horse-meta strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.stat-list {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stat-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e1d8c8;
}

.stat-fill {
  height: 100%;
  border-radius: 8px;
  background: var(--forest-2);
}

.feed-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  box-shadow: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
  font-weight: 750;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fffaf0;
  background: #171b1c;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
  font-weight: 760;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1020px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .player-panel {
    position: static;
  }

  .packs-grid,
  .launch-grid,
  .stable-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .row-heading,
  .horse-title {
    align-items: stretch;
    flex-direction: column;
  }

  .server-pill,
  .gender-pill,
  .price-tag {
    align-self: flex-start;
  }

  .metrics-grid,
  .inventory-grid,
  .pack-items,
  .breeding-controls {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .stat-row {
    grid-template-columns: 72px minmax(0, 1fr) 34px;
  }
}
