:root {
  --bg: #f4f0e8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d6dbe3;
  --ink: #18202b;
  --muted: #667085;
  --accent: #1f7a5c;
  --accent-dark: #155d45;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --warning: #9a6700;
  --shadow: rgba(24, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f6efe2 0%, #eef4ef 52%, #f4eadb 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
}

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

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.pixel-world-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.pixel-world-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(31, 122, 92, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 122, 92, 0.055) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.62;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 82%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 82%);
}

.pixel-map {
  position: absolute;
  display: block;
  aspect-ratio: 96 / 44;
  background-image: url("pixel-world-map.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: saturate(0.95);
  image-rendering: pixelated;
}

.pixel-map-primary {
  top: 42px;
  right: max(-180px, calc((100vw - 1180px) / 2 - 230px));
  width: min(820px, 76vw);
  opacity: 0.52;
}

.pixel-map-secondary {
  bottom: 18px;
  left: max(-180px, calc((100vw - 1180px) / 2 - 240px));
  width: min(640px, 62vw);
  opacity: 0.3;
  transform: scaleX(-1);
}

.pixel-map-tertiary {
  top: 42%;
  left: 56%;
  width: min(460px, 42vw);
  opacity: 0.18;
  transform: translate(-50%, -50%);
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.title-block {
  position: relative;
  isolation: isolate;
  min-width: min(100%, 360px);
  padding: 14px 22px 12px 0;
}

.title-block h1,
.title-block p {
  position: relative;
  z-index: 1;
}

.title-map {
  position: absolute;
  z-index: 0;
  display: block;
  aspect-ratio: 96 / 44;
  background-image: url("pixel-world-map.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: saturate(0.95);
  image-rendering: pixelated;
  pointer-events: none;
}

.title-map-left {
  left: -42px;
  top: -8px;
  width: 175px;
  opacity: 0.22;
  transform: scaleX(-1);
}

.title-map-right {
  left: 190px;
  top: 2px;
  width: 195px;
  opacity: 0.34;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.manager-controls {
  display: grid;
  gap: 10px;
  min-width: min(100%, 460px);
}

.auth-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.auth-summary {
  display: grid;
  justify-items: end;
  gap: 5px;
  min-width: 0;
}

.auth-status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-progress {
  display: grid;
  width: min(260px, 100%);
  gap: 4px;
}

.auth-progress-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
}

.auth-progress-track {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.16);
}

.auth-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.auth-login,
.auth-logout {
  flex: 0 0 auto;
}

.auth-logout {
  color: var(--accent);
  background: #e8f5ef;
}

.auth-logout:hover,
.auth-logout:focus-visible {
  color: #ffffff;
  background: var(--accent-dark);
}

.create-form {
  display: flex;
  gap: 10px;
}

.create-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
}

.notice {
  margin: 0 0 18px;
  border: 1px solid #f1c27d;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--warning);
  background: #fff8eb;
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.server-card {
  display: grid;
  gap: 16px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: 0 12px 28px var(--shadow);
}

.server-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.server-name {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.server-url {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.server-state {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  color: #155d45;
  background: #e8f5ef;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.server-state.is-stopped {
  color: var(--danger);
  background: var(--danger-soft);
}

.server-state.is-warning {
  color: var(--warning);
  background: #fff8eb;
}

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

.stats div {
  min-width: 0;
  min-height: 74px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--surface-soft);
}

.stats dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.stats dd {
  margin: 0;
  overflow: hidden;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-detail {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.server-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.close-server {
  color: var(--danger);
  background: var(--danger-soft);
}

.close-server:hover,
.close-server:focus-visible {
  color: #ffffff;
  background: var(--danger);
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .title-block {
    min-width: 0;
    padding: 22px 0 14px;
  }

  .title-map-left {
    left: -78px;
    top: -4px;
    width: 188px;
    opacity: 0.2;
  }

  .title-map-right {
    left: auto;
    right: -78px;
    top: 4px;
    width: 230px;
    opacity: 0.34;
  }

  .create-form {
    min-width: 0;
  }

  .auth-controls {
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .auth-summary {
    flex: 1 1 100%;
    justify-items: start;
  }

  .auth-status {
    flex: 1 1 100%;
    text-align: left;
  }

  .auth-progress {
    width: min(300px, 100%);
  }

  .auth-progress-label {
    text-align: left;
  }

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

  .pixel-world-bg::before {
    background-size: 18px 18px;
    opacity: 0.42;
  }

  .pixel-map-primary {
    top: 42px;
    right: -190px;
    width: 560px;
    opacity: 0.24;
  }

  .pixel-map-tertiary {
    display: none;
  }

  .pixel-map-secondary {
    bottom: 28px;
    left: -260px;
    width: 520px;
    opacity: 0.14;
  }
}

@media (max-width: 430px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .create-form {
    flex-direction: column;
  }
}
