/* Bremo Company — cream / big-type / black-nav / purple-CTA + RuneScape game feel */
:root {
  --bg: #FFFDF7;
  --bg-warm: #FFFAF0;
  --bg-card: #FFFFFF;
  --ink: #111111;
  --ink-soft: #4B5563;
  --ink-muted: #6B7280;
  --line: #E8E0D4;
  --line-soft: #EFE8DC;
  --shadow: 0 12px 32px rgba(17, 17, 17, 0.045);
  --shadow-sm: 0 8px 24px rgba(76, 29, 149, 0.06);
  --radius: 18px;
  --radius-sm: 14px;
  --purple: #7C3AED;
  --purple-mid: #9F7AEA;
  --purple-deep: #6D28D9;
  --purple-dark: #4C1D95;
  --purple-soft: #F3E8FF;
  --purple-line: #DDD6FE;
  --mint-soft: #ECFDF5;
  --mint-ink: #047857;
  --warn-bg: #FFFBEB;
  --warn-ink: #92400E;
  --warn-line: #FDE68A;
  --gold: #F59E0B;
  --gold-soft: #FEF3C7;
  --tile-grass: #D1FAE5;
  --tile-stone: #E7E5E4;
  --tile-wood: #FEF3C7;
  --font: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --cta: linear-gradient(135deg, #7C3AED, #9F7AEA);
  --map-cols: 12;
  --map-rows: 8;
  --tile: 48px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

.wrap {
  width: min(1280px, calc(100% - 2rem));
  margin-inline: auto;
}

/* —— Sticky black nav —— */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 13px 18px;
  background: #000;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.nav-link {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 4px 2px;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  box-shadow: inset 0 -2px 0 #9F7AEA;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--cta);
  color: #fff !important;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.nav-cta:hover { filter: brightness(1.06); }

/* —— Loading / error —— */
.loading-state,
.error-state {
  width: min(640px, calc(100% - 2rem));
  margin: 3rem auto;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  text-align: center;
  color: var(--ink-soft);
}

.error-state {
  background: #FFF1F2;
  border-color: #FECDD3;
  color: #BE123C;
}

/* —— Hero —— */
.hero-band {
  padding: 2.25rem 0 1.25rem;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(124, 58, 237, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 20%, rgba(245, 158, 11, 0.08), transparent 55%),
    var(--bg);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.85rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge {
  background: var(--purple-soft);
  color: var(--purple-dark);
  border: 1px solid var(--purple-line);
}

.soft-pill {
  background: var(--bg-warm);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.hero-band h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.grad-text {
  background: var(--cta);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lead {
  margin: 0 0 0.4rem;
  font-size: 1.08rem;
  color: var(--ink-soft);
  max-width: 42rem;
}

.helper-line {
  margin: 0;
  font-size: 0.92rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}

/* —— Game layout —— */
.game-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(220px, 300px);
  gap: 1rem;
  padding: 0.5rem 0 2.5rem;
  align-items: start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.5rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.panel-note {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.sim-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid var(--warn-line);
}

/* —— Activity chat log (RuneScape style) —— */
.activity-log {
  height: min(520px, 62vh);
  overflow-y: auto;
  background: #0f0f12;
  color: #e8e0d4;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  border: 2px solid #2a2a32;
  box-shadow: inset 0 0 0 1px #3f3f46;
  font-variant-numeric: tabular-nums;
}

.log-line {
  margin: 0 0 0.45rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  animation: logIn 0.28s ease;
}

.log-line:last-child { border-bottom: none; margin-bottom: 0; }

.log-time {
  color: #a1a1aa;
  font-size: 0.72rem;
  margin-right: 6px;
}

.log-name {
  font-weight: 700;
  margin-right: 4px;
}

.log-line.order { color: #c4b5fd; }
.log-line.rally { color: #fbbf24; font-weight: 600; }
.log-line.system { color: #86efac; }
.log-line.warn { color: #fcd34d; }

@keyframes logIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* —— Tile map —— */
.map-stage {
  position: relative;
  overflow: auto;
  border-radius: 14px;
  border: 2px solid var(--line);
  background:
    repeating-conic-gradient(#f5f0e6 0% 25%, #efe8dc 0% 50%) 0 0 / 24px 24px;
  padding: 10px;
}

.tile-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--map-cols), var(--tile));
  grid-template-rows: repeat(var(--map-rows), var(--tile));
  width: calc(var(--map-cols) * var(--tile));
  height: calc(var(--map-rows) * var(--tile));
  margin: 0 auto;
  image-rendering: pixelated;
}

.zone-tile {
  position: absolute;
  border-radius: 10px;
  border: 2px solid rgba(17, 17, 17, 0.12);
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: flex-start;
  padding: 4px 6px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.zone-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background: var(--zone-color, #ddd);
  pointer-events: none;
}

.zone-label {
  position: relative;
  z-index: 1;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 253, 247, 0.85);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(17, 17, 17, 0.08);
  pointer-events: none;
  white-space: nowrap;
}

.zone-tile.throne {
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), inset 0 0 20px rgba(245, 158, 11, 0.12);
}

/* Pixel-ish character sprites */
.sprite {
  position: absolute;
  z-index: 5;
  width: 36px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transform: translate(-50%, -70%);
  transition: filter 0.15s ease, transform 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

.sprite:hover,
.sprite:focus-visible {
  filter: brightness(1.08);
  outline: none;
  z-index: 8;
}

.sprite.selected {
  z-index: 10;
  filter: drop-shadow(0 0 6px rgba(124, 58, 237, 0.7));
}

.sprite.selected .sprite-body {
  box-shadow: 0 0 0 2px #7C3AED, 0 4px 0 rgba(17, 17, 17, 0.2);
}

.sprite.flash {
  animation: rallyFlash 0.7s ease;
}

.sprite.walking .sprite-body {
  animation: walkBob 0.35s ease infinite;
}

.sprite-body {
  width: 28px;
  height: 28px;
  border-radius: 4px 4px 6px 6px;
  background: var(--spr-color, #7C3AED);
  border: 2px solid rgba(17, 17, 17, 0.35);
  box-shadow: 0 3px 0 rgba(17, 17, 17, 0.18);
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  image-rendering: pixelated;
  position: relative;
}

.sprite-body::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 18px;
  height: 4px;
  background: rgba(17, 17, 17, 0.18);
  border-radius: 50%;
  transform: translateX(-50%);
}

.sprite.god .sprite-body {
  background: linear-gradient(180deg, #FBBF24, #D97706);
  border-color: #92400E;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.45), 0 3px 0 rgba(146, 64, 14, 0.3);
}

.sprite.npc .sprite-body {
  opacity: 0.75;
  filter: grayscale(0.25);
}

.sprite-name {
  margin-top: 2px;
  font-size: 0.58rem;
  font-weight: 800;
  background: rgba(17, 17, 17, 0.82);
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

@keyframes walkBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes rallyFlash {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  30% { filter: drop-shadow(0 0 12px #F59E0B) brightness(1.3); }
  60% { filter: drop-shadow(0 0 18px #7C3AED) brightness(1.2); }
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(17, 17, 17, 0.2);
}

/* —— Play bar / orders —— */
.play-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
}

.play-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.play-select {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  min-width: 160px;
  max-width: 100%;
}

.order-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.btn-order {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--purple-line);
  background: var(--purple-soft);
  color: var(--purple-dark);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-order:hover {
  filter: brightness(0.97);
  transform: translateY(-1px);
}

.btn-order:active { transform: translateY(0); }

.btn-order:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-rally {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #F59E0B, #FBBF24);
  color: #78350F;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.btn-rally:hover { filter: brightness(1.05); }

.keys-hint {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* —— HUD —— */
.hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 0.85rem;
}

.hud-card {
  background: var(--bg-warm);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.7rem;
}

.hud-card.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 2px;
}

.hud-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hud-value.unknown {
  color: var(--warn-ink);
  font-size: 1.05rem;
}

.hud-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 2px;
  font-weight: 500;
}

.hud-sub.up { color: var(--mint-ink); }
.hud-sub.down { color: #BE123C; }

.xp-block {
  margin-bottom: 0.7rem;
}

.xp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.xp-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.xp-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--purple-dark);
  font-variant-numeric: tabular-nums;
}

.xp-bar {
  height: 14px;
  border-radius: 999px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(17, 17, 17, 0.06);
}

.xp-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--cta);
  transition: width 0.45s ease;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  image-rendering: pixelated;
  background-image:
    linear-gradient(135deg, #7C3AED, #9F7AEA),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 6px,
      rgba(255, 255, 255, 0.15) 6px,
      rgba(255, 255, 255, 0.15) 7px
    );
  background-blend-mode: normal;
}

.xp-bar.energy .xp-fill {
  background: linear-gradient(135deg, #10B981, #34D399);
}

.xp-bar.boost .xp-fill {
  animation: xpPulse 0.8s ease 3;
}

@keyframes xpPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

/* Selected card */
.selected-card {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--purple-line);
  background: var(--purple-soft);
  min-height: 88px;
}

.sel-empty {
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.sel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sel-emoji {
  font-size: 1.4rem;
  line-height: 1;
}

.sel-name {
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.sel-role {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--purple-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sel-blurb {
  margin: 0.3rem 0 0.45rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.sel-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}

.sel-xp {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.breakdown {
  margin-top: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.bd-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.bd-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 0;
}

.bd-row span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--purple-dark);
}

/* Footer */
.site-foot {
  padding: 0 0 2.5rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.site-foot code {
  font-size: 0.78rem;
  background: var(--bg-warm);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
}

/* —— Mobile —— */
@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .activity-log {
    height: 200px;
  }

  :root {
    --tile: 40px;
  }

  .chat-panel { order: 2; }
  .map-panel { order: 1; }
  .hud-panel { order: 3; }
}

@media (max-width: 520px) {
  :root { --tile: 32px; }

  .hero-band h1 { font-size: 1.75rem; }

  .sprite {
    width: 30px;
    height: 38px;
  }

  .sprite-body {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .sprite-name { font-size: 0.5rem; max-width: 56px; }

  .hud-grid { grid-template-columns: 1fr 1fr; }

  .play-bar { flex-direction: column; align-items: stretch; }

  .play-select { width: 100%; }
}

/* Rally overlay flash on map */
.map-stage.rallying {
  animation: mapRally 0.9s ease;
}

@keyframes mapRally {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.55), 0 0 24px rgba(124, 58, 237, 0.35); }
}
