:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d11;
  color: #edf0f4;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  --surface: #14181e;
  --surface-raised: #1a2028;
  --border: #2a323d;
  --text-muted: #929dac;
  --cyan: #4cc9d8;
  --green: #52c788;
  --amber: #e6b44d;
  --red: #e0646f;
  --violet: #9487e8;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: #0b0d11;
}

button {
  font: inherit;
  letter-spacing: 0;
}

.app-shell {
  width: min(100%, 1080px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.topbar,
.identity-band,
.section-heading,
.combatants {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 64px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
  font-weight: 750;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.connection[data-state="online"] .connection-dot {
  background: var(--green);
}

.connection[data-state="error"] .connection-dot {
  background: var(--red);
}

.identity-band {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.identity-band h2 {
  margin-bottom: 4px;
  font-size: 1.12rem;
}

.identity-band p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  background: #211e17;
  color: #f2dfb6;
}

.notice.error {
  border-color: var(--red);
  background: #24171b;
  color: #f2c4c8;
}

.notice.success {
  border-color: var(--green);
  background: #14231c;
  color: #c4ead5;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.panel {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
}

.section-heading {
  min-height: 30px;
  margin-bottom: 14px;
}

.section-heading > span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

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

.resource {
  min-height: 78px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
}

.resource span,
.combatant span {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.resource strong {
  display: block;
  margin-top: 5px;
  font-size: 1.05rem;
}

.gold-resource strong {
  color: var(--amber);
}

.stat-resource strong {
  color: var(--violet);
}

.meter {
  height: 4px;
  margin-top: 9px;
  overflow: hidden;
  background: #080a0d;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  transition: width 160ms ease;
}

.health-resource .meter span {
  background: var(--red);
}

.energy-resource .meter span {
  background: var(--cyan);
}

.location-list {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
}

.location-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.location-list dt {
  color: var(--text-muted);
}

.location-list dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.button {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #3a6570;
  border-radius: 6px;
  background: #18333a;
  color: #e6fbff;
  cursor: pointer;
}

.button:active:not(:disabled) {
  background: #21444d;
}

.button:disabled {
  border-color: var(--border);
  background: #171b20;
  color: #65707d;
  cursor: not-allowed;
}

.button-secondary {
  min-height: 40px;
  background: transparent;
  color: var(--cyan);
}

.button-reward:not(:disabled) {
  border-color: #75612d;
  background: #332a15;
  color: #f7dda0;
}

.button-battle:not(:disabled) {
  border-color: #514a83;
  background: #282542;
  color: #ded9ff;
}

.button-danger:not(:disabled) {
  border-color: #7c3d46;
  background: #3b1d22;
  color: #ffd8dc;
}

.counter {
  min-width: 25px;
  padding: 2px 7px;
  border: 1px solid #75612d;
  border-radius: 6px;
  color: var(--amber) !important;
  text-align: center;
}

.primary-goal {
  margin-bottom: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  color: #f1f4f7;
}

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

.goal-item {
  padding: 10px;
  border-left: 3px solid var(--border);
  background: var(--surface-raised);
}

.goal-item.claimable {
  border-left-color: var(--amber);
}

.goal-item strong,
.goal-item span {
  display: block;
}

.goal-item span,
.goal-item small {
  margin-top: 4px;
  color: var(--text-muted);
}

.battle-content {
  min-height: 116px;
}

.combatant {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px;
  border-left: 3px solid var(--cyan);
  background: var(--surface-raised);
}

.combatant.opponent {
  border-left-color: var(--red);
  text-align: right;
}

.combatant strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

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

.battle-status {
  margin: 12px 0 0;
  color: var(--text-muted);
  text-align: center;
}

.empty-state,
.muted {
  color: var(--text-muted);
}

.text-button {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
}

.event-log {
  max-height: 250px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.event-log li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.event-log li:last-child {
  border-bottom: 0;
}

.event-log .event-reward {
  color: var(--amber);
}

.event-log .event-finished {
  color: var(--green);
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .app-shell {
    padding-right: 22px;
    padding-left: 22px;
  }

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

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

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

@media (max-width: 390px) {
  .identity-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .identity-band .button {
    width: 100%;
  }

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

  .combatant.opponent {
    text-align: left;
  }

  .versus {
    text-align: center;
  }
}
