:root {
  color-scheme: dark;
  --bg: #07100b;
  --bg-raised: #0c1811;
  --panel: #102219;
  --panel-soft: #14291e;
  --line: #294638;
  --line-bright: #3c6750;
  --ink: #f3f7f1;
  --muted: #a9b9ad;
  --green: #8ee59a;
  --green-strong: #54c875;
  --green-ink: #06130a;
  --amber: #f4c96e;
  --amber-bg: #322914;
  --red: #ff9b94;
  --red-bg: #381c1d;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html { min-width: 0; overflow-x: hidden; }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(74, 151, 91, 0.15), transparent 32rem),
    linear-gradient(180deg, #09140e, var(--bg) 28rem);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.app-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  min-height: 62px;
  margin-bottom: 22px;
  padding: 0 4px;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  color: var(--green);
  background: var(--panel);
  font-weight: 900;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: 0.08em; }
.brand small { color: var(--muted); font-size: 0.73rem; }
.header-status { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 0.82rem; }
.role-badge, .protected-badge, .state-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.role-badge { color: var(--green); text-transform: capitalize; }
.protected-badge { color: var(--amber); background: var(--amber-bg); }

.auth-panel, .owner-login, .form-row, .dialog-actions, .control-action-row, .owner-actions, .catalog-pagination {
  display: flex;
  gap: 10px;
  align-items: center;
}
.owner-login input { width: 180px; min-height: 40px; }

.deck-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

#world-navigation, .primary-panel, .cost-panel, .controls-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 34, 25, 0.94);
  box-shadow: var(--shadow);
}

#world-navigation {
  position: sticky;
  top: 16px;
  min-width: 0;
  padding: 14px;
}

.world-nav-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 2px 2px 12px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.capacity-copy, .status-copy, .world-meta, .progress-copy, .access-note { margin: 0; color: var(--muted); }
.capacity-copy { font-size: 0.76rem; }
.world-nav-list { display: grid; gap: 8px; }
.world-nav-item {
  min-width: 0;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 13px;
}
.world-nav-item[data-selected="true"] { border-color: var(--line-bright); background: var(--panel-soft); }
.world-select {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.world-select-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.world-select-name { overflow: hidden; font-weight: 780; text-overflow: ellipsis; white-space: nowrap; }
.world-state { flex: none; color: var(--muted); font-size: 0.68rem; }
.world-state[data-state="READY"] { color: var(--green); }
.world-state[data-state="ERROR"], .world-state[data-state="FINAL_CHECKPOINT_STUCK"] { color: var(--red); }
.world-select-meta { overflow: hidden; color: var(--muted); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.world-nav-actions { display: flex; padding: 0 8px 7px; }

#world-dashboard { display: grid; gap: 14px; min-width: 0; }
.world-overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 14px; min-width: 0; }
.primary-panel { min-width: 0; padding: clamp(22px, 4vw, 38px); }
.cost-panel { display: flex; flex-direction: column; min-width: 0; padding: 24px; }
.world-title-row, .section-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.world-title { margin: 0; overflow-wrap: anywhere; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1; letter-spacing: -0.045em; }
.world-meta { margin-top: 10px; font-size: 0.82rem; }
.selected-status { display: flex; gap: 12px; align-items: center; margin: 24px 0 18px; }
.state-badge { color: var(--muted); text-transform: uppercase; }
.state-badge[data-state="READY"] { color: var(--green); border-color: var(--green); }
.state-badge[data-state="FINAL_CHECKPOINT_STUCK"], .state-badge[data-state="ERROR"] { color: var(--red); border-color: var(--red); }
.state-badge[data-state="CREATING_VM"], .state-badge[data-state="RESTORING_WORLD"], .state-badge[data-state="INSTALLING_SERVER"], .state-badge[data-state="STARTING_MINECRAFT"], .state-badge[data-state="CHECKPOINTING"], .state-badge[data-state="SHUTTING_DOWN"] { color: var(--amber); border-color: var(--amber); }

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel-soft);
  font-weight: 760;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--line-bright); }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button.primary-action {
  width: 100%;
  min-height: 60px;
  margin-top: 4px;
  color: var(--green-ink);
  background: linear-gradient(180deg, #9aefa5, var(--green-strong));
  box-shadow: 0 12px 30px rgba(84, 200, 117, 0.16);
  font-size: 1.08rem;
}
.button.secondary { border-color: var(--line); background: var(--panel-soft); }
.compact-button { min-height: 36px; padding: 0 11px; font-size: 0.78rem; }
.stop-button { border-color: #865958; color: #ffd7d3; background: #2b1a1a; }
.danger-button { border-color: #8d4545; color: #ffe5e2; background: var(--red-bg); }
.text-button { min-height: 36px; border: 0; padding: 4px 8px; color: var(--muted); background: transparent; text-decoration: underline; cursor: pointer; }

.button:focus-visible, .world-select:focus-visible, .text-button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.capacity-warning, .notice {
  margin: 10px 0 0;
  color: var(--amber);
  font-size: 0.82rem;
}
.selected-connection {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid #356447;
  border-radius: 12px;
  background: rgba(41, 93, 57, 0.2);
}
.connection-label { grid-column: 1 / -1; color: var(--muted); font-size: 0.72rem; }
.selected-connection code { min-width: 0; overflow-wrap: anywhere; color: var(--green); font-size: 1rem; }
.cost-value { margin-top: 4px; font-size: 1.55rem; letter-spacing: -0.03em; }
.cost-session, .cost-aggregate { margin-top: 5px; color: var(--muted); font-size: 0.8rem; }
.cost-aggregate { color: var(--green); }
.cost-scope { margin-top: auto; padding-top: 24px; color: #84968a; font-size: 0.68rem; }

.controls-panel { min-width: 0; padding: 20px; }
.world-controls-summary { display: grid; gap: 12px; }
.section-heading { font-size: 1rem; font-weight: 800; }
.control-action-row, .owner-actions { flex-wrap: wrap; }
.access-note { font-size: 0.82rem; }
.recovery-card {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid #865958;
  border-radius: 12px;
  color: #ffd7d3;
  background: var(--red-bg);
}
.recovery-card p { margin: 0; }
.selected-world-tools { margin-top: 14px; border-top: 1px solid var(--line); }
.owner-session { padding-top: 18px; }
h2, h3, h4 { margin: 0; }
.owner-state { max-width: 50%; color: var(--amber); font-size: 0.78rem; text-align: right; }
.owner-console { display: grid; gap: 7px; margin-top: 16px; }
.owner-output, .owner-log {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #d5e2d8;
  background: #07100b;
  font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.owner-output { min-height: 42px; margin: 9px 0 0; padding: 10px; white-space: pre-wrap; }
.owner-log { max-height: 340px; margin: 12px 0 0; padding: 12px 12px 12px 34px; }

.tool-section, .owner-danger {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 12, 7, 0.16);
}
.tool-section > summary, .owner-danger > summary { padding: 14px; font-weight: 780; cursor: pointer; }
.tool-section > :not(summary), .owner-danger > :not(summary) { margin-right: 14px; margin-left: 14px; }
.tool-section > :last-child, .owner-danger > :last-child { margin-bottom: 14px; }
.owner-danger { border-color: #704445; background: rgba(56, 28, 29, 0.35); }
.owner-warning { color: var(--red); }
.owner-ack { display: flex; gap: 8px; align-items: center; margin: 12px 0; }

input, select {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  color: var(--ink);
  background: #09140e;
}
input[type="checkbox"], input[type="radio"] { min-height: auto; }
.profile-form, .owner-map-tools { display: grid; gap: 8px; padding-bottom: 14px; }
.profile-form label, .owner-map-tools label, .owner-console label { color: var(--muted); font-size: 0.76rem; }
.profile-form > button, .owner-map-tools > button { margin-top: 7px; }
.provider-picker { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 4px 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.provider-picker legend { padding: 0 4px; color: var(--muted); font-size: 0.76rem; }
.provider-picker label { display: inline-flex; gap: 7px; align-items: center; color: var(--ink); }
.catalog-results, .backup-list { display: grid; gap: 9px; margin: 10px 0; padding: 0; list-style: none; }
.catalog-card, .backup-list li { display: grid; gap: 6px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.catalog-card img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.catalog-card h4, .catalog-card p { margin: 0; overflow-wrap: anywhere; }
.catalog-card p, .backup-meta { color: var(--muted); font-size: 0.8rem; }
.backup-title { overflow-wrap: anywhere; font: 700 0.8rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.save-method-label { margin: 0; color: var(--ink); font-weight: 700; }
.tool-divider { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.revision-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.revision-badge { width: fit-content; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--muted); font-size: 0.7rem; font-weight: 760; }
.current-revision { border-color: #4d765c; color: #c7f4d5; background: #10251a; }
.owner-map-tools progress { width: 100%; accent-color: var(--green); }

.confirmation-dialog {
  width: min(500px, calc(100% - 30px));
  border: 1px solid var(--line-bright);
  border-radius: 18px;
  padding: 24px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.confirmation-dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
/* Wider than a confirmation because it carries the modpack catalogue, and
   capped in height so a long result list scrolls inside the dialog instead of
   pushing Save off the screen. */
.world-form-dialog {
  width: min(760px, calc(100% - 30px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  border: 1px solid var(--line-bright);
  border-radius: 18px;
  padding: 24px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.world-form-dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
.world-form-dialog h2 { margin: 0 0 18px; }
.confirmation-dialog p:not(.eyebrow) { color: var(--muted); }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }

footer { display: flex; justify-content: center; gap: 9px; margin-top: 20px; color: #7f9084; font-size: 0.76rem; }
footer a { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hint-button { width: 1.2rem; height: 1.2rem; margin-left: 0.35rem; border: 1px solid var(--line); border-radius: 50%; padding: 0; color: var(--muted); background: transparent; cursor: help; }
.hint-panel { position: absolute; z-index: 10; max-width: min(320px, calc(100vw - 32px)); margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line-bright); border-radius: 10px; color: var(--ink); background: var(--panel); box-shadow: var(--shadow); font-size: 0.78rem; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 24px, 620px); padding-top: 12px; }
  .app-header { grid-template-columns: 1fr auto; gap: 10px; }
  .header-status { grid-row: 2; grid-column: 1 / -1; }
  .auth-panel { justify-content: flex-end; }
  .owner-login { align-items: stretch; flex-direction: column; }
  .owner-login input { width: 150px; }
  .deck-layout { grid-template-columns: minmax(0, 1fr); }
  #world-navigation { position: static; }
  .world-nav-list { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
  .world-overview-grid { grid-template-columns: minmax(0, 1fr); }
  .cost-panel { min-height: 0; }
  .cost-scope { margin-top: 8px; padding-top: 6px; }
	.owner-map-tools .button, .owner-map-tools progress { width: 100%; }
}

@media (max-width: 430px) {
  .app-header { grid-template-columns: 1fr; }
  .auth-panel { justify-content: flex-start; }
  .owner-login { width: 100%; }
  .owner-login input { width: 100%; }
  .world-nav-heading { align-items: stretch; flex-direction: column; }
  .world-nav-heading .compact-button { width: 100%; }
  .world-title-row, .section-heading-row, .selected-status { align-items: flex-start; flex-direction: column; }
  .selected-connection, .form-row { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
  .connection-label { grid-column: auto; }
  .button { width: 100%; }
  .control-action-row, .owner-actions, .catalog-pagination, .dialog-actions { align-items: stretch; flex-direction: column; }
  .owner-state { max-width: none; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
