:root {
  color-scheme: dark;
  --sky: #78a7c7;
  --grass: #4f8f3f;
  --grass-light: #6fb15f;
  --dirt: #7b5738;
  --dirt-dark: #4d3424;
  --stone: #8d928d;
  --stone-dark: #3c4242;
  --coal: #151a18;
  --torch: #f3c650;
  --redstone: #d84f45;
  --text: #f4f1e7;
  --muted: #b9c1b5;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(120, 167, 199, 0.24), rgba(21, 26, 24, 0) 280px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    var(--coal);
  background-size: auto, 48px 48px, 48px 48px, auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 4px solid var(--dirt-dark);
  background:
    linear-gradient(180deg, rgba(36, 42, 37, 0.96), rgba(21, 26, 24, 0.96)),
    var(--coal);
  box-shadow: 0 16px 32px var(--shadow);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: clamp(0.92rem, 2vw, 1.05rem);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-cube,
.torch {
  display: inline-block;
  flex: 0 0 auto;
  image-rendering: pixelated;
}

.brand-cube {
  width: 28px;
  height: 28px;
  border: 3px solid #24331f;
  background:
    linear-gradient(180deg, var(--grass-light) 0 36%, var(--dirt) 36% 100%);
  box-shadow:
    inset -5px -5px 0 rgba(0, 0, 0, 0.22),
    inset 5px 5px 0 rgba(255, 255, 255, 0.12);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 2px solid rgba(244, 241, 231, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  border-color: var(--torch);
  outline: none;
}

.server-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: clamp(32px, 7vw, 72px) 0;
  align-items: center;
}

.status-panel,
.online-panel,
.empty-gallery {
  border: 4px solid var(--stone-dark);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #252b29;
  box-shadow:
    0 18px 42px var(--shadow),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.status-panel {
  padding: clamp(20px, 4vw, 40px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--torch);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  max-width: 12ch;
  margin-bottom: 20px;
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  line-height: 0.95;
}

.address-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 24px;
}

.address-primary {
  width: max-content;
  max-width: 100%;
  padding: 10px 12px;
  border: 3px solid var(--dirt-dark);
  background: var(--dirt);
  color: #fff6dd;
  font-size: clamp(1rem, 2.8vw, 1.4rem);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.address-options {
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.stat-block {
  min-height: 98px;
  padding: 12px;
  border: 3px solid #1a1f1d;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.14)),
    var(--stone-dark);
}

.stat-block span,
.screenshot-copy span,
.muted {
  color: var(--muted);
}

.stat-block span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-block strong {
  display: block;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.4rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stat-block .is-online {
  color: #9bf07e;
}

.stat-block .is-offline {
  color: #ff8c7f;
}

.motd {
  max-width: 70ch;
  margin-bottom: 0;
  color: #e3ddc7;
}

.online-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.torch {
  width: 18px;
  height: 30px;
  background:
    linear-gradient(180deg, #fff2a8 0 24%, var(--torch) 24% 46%, #8b4a2f 46% 100%);
  box-shadow: 0 0 22px rgba(243, 198, 80, 0.45);
}

.player-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-list li {
  min-height: 42px;
  padding: 9px 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  overflow-wrap: anywhere;
}

.gallery-band {
  padding: 56px clamp(16px, 4vw, 48px) 72px;
  border-top: 8px solid var(--grass);
  background:
    linear-gradient(180deg, rgba(79, 143, 63, 0.16), rgba(79, 143, 63, 0) 120px),
    #1d221f;
}

.section-heading,
.gallery-grid,
.empty-gallery {
  width: min(1180px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
}

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

.relay-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  width: min(1180px, 100%);
  margin: 18px auto 0;
}

.relay-log-list {
  display: grid;
  gap: 10px;
}

.relay-log-item {
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.18);
}

.relay-log-item p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.relay-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.relay-log-error,
.relay-severity--error {
  color: #ff8c7f;
}

.relay-severity--warning {
  color: var(--torch);
}

.relay-severity--info {
  color: #9bf07e;
}

.screenshot-card {
  min-width: 0;
  border: 4px solid #171b19;
  background: #242b28;
  box-shadow: 0 12px 28px var(--shadow);
}

.screenshot-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  image-rendering: auto;
  border-bottom: 4px solid var(--dirt-dark);
  background: #111;
}

.screenshot-copy {
  padding: 14px;
}

.screenshot-copy h3 {
  margin-bottom: 6px;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.screenshot-copy p {
  margin-bottom: 10px;
  color: #ddd6bf;
}

.screenshot-copy span {
  display: block;
  font-size: 0.78rem;
}

.empty-gallery {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 24px;
}

.empty-gallery h3 {
  margin-bottom: 6px;
}

.empty-gallery p {
  margin-bottom: 0;
  color: var(--muted);
}

.empty-frame {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border: 4px solid var(--dirt-dark);
  background:
    linear-gradient(180deg, var(--sky) 0 50%, var(--grass) 50% 64%, var(--dirt) 64% 100%);
  image-rendering: pixelated;
}

.empty-frame span {
  width: 34px;
  height: 34px;
  background: var(--stone);
  box-shadow:
    22px 12px 0 var(--stone-dark),
    -18px 20px 0 #d8d7c9;
}

/* --- Map ---------------------------------------------------------------- */

.map-page {
  height: calc(100vh - 76px);
  display: flex;
}

.map-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.map-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  padding: 48px 24px;
}

.map-empty code {
  padding: 2px 6px;
  background: var(--stone-dark);
}

.btn-map {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  min-height: 38px;
  padding: 8px 16px;
  border: 2px solid var(--sky);
  background: rgba(120, 167, 199, 0.15);
  color: var(--sky);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-map:hover,
.btn-map:focus-visible {
  background: var(--sky);
  color: var(--coal);
  outline: none;
}

/* --- Settings & Forms --------------------------------------------------- */

.settings-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(32px, 7vw, 72px) 0;
}

.settings-page .section-heading {
  margin-bottom: 28px;
}

.settings-page h1 {
  max-width: none;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.settings-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.container-status strong {
  text-transform: capitalize;
}

.active-world-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 3px solid var(--grass);
  background: rgba(79, 143, 63, 0.12);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 16px;
  border: 2px solid rgba(244, 241, 231, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--torch);
  outline: none;
}

.btn-primary {
  border-color: var(--grass);
  background: var(--grass);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  border-color: var(--grass-light);
  background: var(--grass-light);
}

.btn-danger {
  border-color: var(--redstone);
  background: rgba(216, 79, 69, 0.15);
  color: var(--redstone);
}

.btn-danger:hover,
.btn-danger:focus-visible {
  background: var(--redstone);
  color: #fff;
}

.btn-warning {
  border-color: var(--torch);
  background: rgba(243, 198, 80, 0.15);
  color: var(--torch);
}

.btn-warning:hover,
.btn-warning:focus-visible {
  background: var(--torch);
  color: var(--coal);
}

.btn-small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* World Cards */

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.world-card {
  border: 4px solid var(--stone-dark);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #252b29;
  box-shadow: 0 12px 28px var(--shadow);
  padding: 18px;
}

.world-card--active {
  border-color: var(--grass);
}

.world-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.world-card-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge-active {
  border: 2px solid var(--grass);
  color: #9bf07e;
}

.world-card-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 16px;
  font-size: 0.85rem;
}

.world-card-details dt {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.world-card-details dd {
  margin: 0;
}

.world-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline {
  display: inline;
}

/* Forms */

.world-form fieldset {
  border: 3px solid var(--stone-dark);
  padding: 18px;
  margin: 0 0 20px;
}

.world-form legend {
  padding: 0 8px;
  color: var(--torch);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 700;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  max-width: 480px;
  padding: 8px 10px;
  border: 3px solid var(--stone-dark);
  background: var(--coal);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--torch);
  outline: none;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.help-text {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.error-text {
  display: block;
  margin-top: 3px;
  color: var(--redstone);
  font-size: 0.78rem;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--redstone);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

/* Confirm card */

.confirm-card {
  max-width: 560px;
  padding: 24px;
  border: 4px solid var(--stone-dark);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #252b29;
}

.confirm-card .form-actions {
  margin-top: 18px;
}

/* Alerts / Messages */

.messages {
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto 0;
}

.alert {
  padding: 12px 16px;
  margin-bottom: 10px;
  border: 3px solid var(--stone-dark);
  font-size: 0.88rem;
  font-weight: 600;
}

.alert-success {
  border-color: var(--grass);
  background: rgba(79, 143, 63, 0.15);
  color: #9bf07e;
}

.alert-error {
  border-color: var(--redstone);
  background: rgba(216, 79, 69, 0.15);
  color: #ff8c7f;
}

.alert-warning {
  border-color: var(--torch);
  background: rgba(243, 198, 80, 0.12);
  color: var(--torch);
}

/* Status indicators */

.is-online {
  color: #9bf07e;
}

.is-offline {
  color: #ff8c7f;
}

@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .server-board {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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

@media (max-width: 560px) {
  .status-grid,
  .gallery-grid,
  .empty-gallery {
    grid-template-columns: 1fr;
  }

  .top-nav a {
    min-height: 34px;
    padding: 7px 9px;
  }

  .empty-frame {
    width: 88px;
    height: 88px;
  }
}
