:root {
  color-scheme: dark;
  font-family: "Segoe UI", Roboto, sans-serif;
  background-color: #0f111a;
  color: #f1f3fb;
}

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

body {
  margin: 0;
  background-color: #0f111a;
  color: inherit;
}

header {
  background: linear-gradient(135deg, #1f2937, #121826);
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.6rem;
  flex: 1 1 auto;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header h1 a:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 3px;
}

.version-badge {
  border: 1px solid #334155;
  border-radius: 999px;
  color: #cbd5e1;
  background-color: rgba(15, 23, 42, 0.72);
  padding: 0.35rem 0.7rem;
  font-size: 1.1rem;
  white-space: nowrap;
}

.connection-badge {
  border: 1px solid rgba(34, 197, 94, 0.45);
  border-radius: 999px;
  color: #bbf7d0;
  background-color: rgba(22, 101, 52, 0.28);
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.about-trigger {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid #334155;
  background: none;
  color: #f8fafc;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.about-trigger:hover {
  background-color: rgba(148, 163, 184, 0.2);
  transform: translateY(-1px);
}

.about-trigger:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 3px;
}

main {
  padding: 2rem;
  max-width: 90%;
  margin: 0 auto;
}

a {
  color: #7dd3fc;
}

.card {
  background: #141926;
  border: 1px solid #1f2635;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 12px 28px rgba(4, 6, 12, 0.55);
}

.card + .card {
  margin-top: 1.5rem;
}

.function-layout .card + .card {
  margin-top: 0;
}

.function-workspace {
  display: grid;
  gap: 1rem;
}

.function-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.function-tab[aria-selected="true"] {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-color: transparent;
}

.function-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.function-layout[data-mode="give"] {
  grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
}

.function-layout[data-mode="waypoints"],
.function-layout[data-mode="spawns"],
.function-layout[data-mode="command-log"] {
  grid-template-columns: minmax(0, 1fr);
}

.function-layout[data-mode="give"] [data-function-card="give"] {
  order: 1;
}

.function-layout[data-mode="give"] [data-function-card="console"] {
  order: 2;
}

.function-layout .card {
  display: flex;
  flex-direction: column;
}

.function-layout [hidden] {
  display: none !important;
}

.card-console {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-console .console {
  flex: 0 0 auto;
}

.card-console form {
  margin-top: 1rem;
}

.console-command-form {
  display: block;
}

.function-layout[data-mode="give"] .console-command-form,
.function-layout[data-mode="give"] #disconnect-form {
  display: none;
}

.card-console form:last-of-type {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.console-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-quick {
  display: grid;
  gap: 1.25rem;
}

.side-panel-section {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.side-panel-section + .side-panel-section {
  border-top: 1px solid #1f2635;
  padding-top: 1.25rem;
}

.side-panel-section h2 {
  margin: 0;
}

.side-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}

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

.player-list li {
  border: 1px solid #1f2635;
  border-radius: 8px;
  background-color: #0d1220;
  padding: 0.45rem 0.65rem;
  overflow-wrap: anywhere;
}

.player-list-empty {
  color: #98a2b3;
}

.quick-command-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  margin: 0;
}

.flash {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.flash-info {
  background-color: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.flash-error {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea {
  width: 100%;
  max-width: 100%;
  background-color: #0d1220;
  border: 1px solid #1f2635;
  color: inherit;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

textarea {
  resize: vertical;
  min-height: 3rem;
}

button {
  border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #f9fafb;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
  background: none;
  border: 1px solid #334155;
}

dialog.about-modal {
  border: 0;
  padding: 0;
  border-radius: 12px;
  background: #141926;
  color: #f1f3fb;
  box-shadow: 0 18px 36px rgba(4, 6, 12, 0.6);
  min-width: min(420px, 90vw);
}

dialog.about-modal::backdrop {
  background: rgba(10, 12, 22, 0.6);
}

dialog.about-modal article {
  margin: 0;
  padding: 1.75rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.about-modal__title {
  margin: 0;
  font-size: 1.3rem;
}

.about-modal__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.about-modal__list li {
  display: flex;
  gap: 0.5rem;
}

.about-modal__list strong {
  font-weight: 600;
  min-width: 130px;
}

.modal-close {
  align-self: flex-start;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.console {
  background-color: #0b0f1a;
  border: 1px solid #1e2230;
  border-radius: 8px;
  padding: 1rem;
  font-family: "Consolas", "Fira Code", monospace;
  height: clamp(240px, 42vh, 420px);
  max-height: 420px;
  overflow-y: auto;
  line-height: 1.4;
}

.console-entry {
  margin-bottom: 0.35rem;
}

.console-entry.command {
  color: #93c5fd;
}

.console-entry.server {
  color: #f8fafc;
}

.console-entry.system {
  color: #34d399;
}

.console-entry.error {
  color: #f87171;
}

.history {
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

.history ul {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.history li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #1f2635;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.history-label {
  flex: 1 1 auto;
}

.history-actions {
  display: flex;
  gap: 0.5rem;
}

.history-actions form {
  margin: 0;
}

.generator-card {
  margin-top: 2.75rem;
}

.function-layout .generator-card {
  margin-top: 0;
}

.generator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.generator-header p {
  margin: 0;
  color: #cbd5f5;
}

.generator-header h2 {
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.generator-panel {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.generator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 1rem;
}

.generator-grid > div,
.generator-stack,
.generator-output {
  min-width: 0;
}

.generator-stack {
  display: grid;
  gap: 1rem;
}

.generator-fieldset {
  border: 1px solid #1f2635;
  border-radius: 8px;
  padding: 1rem;
}

.generator-fieldset legend {
  color: #cdd5f5;
  font-weight: 700;
  padding: 0 0.35rem;
}

select {
  width: 100%;
  max-width: 100%;
  background-color: #0d1220;
  border: 1px solid #1f2635;
  color: inherit;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.generator-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.generator-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.generator-output {
  display: flex;
  flex-direction: column;
}

.generator-output textarea {
  font-family: "Consolas", "Fira Code", monospace;
  min-height: 10rem;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.generator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.generator-actions form {
  margin: 0;
}

.player-refresh-status {
  color: #98a2b3;
  font-size: 0.9rem;
  text-align: right;
}

.profile-card h2,
.profile-card h3,
.profile-card h4 {
  margin-top: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.section-heading p,
.muted {
  color: #98a2b3;
}

.inline-editor {
  border: 1px solid #1f2635;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.coordinate-grid,
.spawn-entry {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(90px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid #1f2635;
  text-align: left;
  vertical-align: top;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: start;
}

.table-actions form,
.spawn-profile > form {
  margin: 0;
}

.button-link {
  color: #93c5fd;
  cursor: pointer;
  font-weight: 700;
}

.spawn-sections,
.spawn-profile-editor {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.spawn-profile-editor > label {
  margin-bottom: 0;
}

.spawn-profile-editor > label > input {
  display: block;
  margin-top: 0.4rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 1rem;
}

.spawn-profile {
  border: 1px solid #1f2635;
  border-radius: 8px;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.spawn-profile > * {
  margin-top: 0;
  margin-bottom: 0;
}

.profile-execution-form {
  display: grid;
  gap: 0.5rem;
}

.spawn-entry {
  grid-template-columns: minmax(0, 1fr) minmax(80px, 100px);
}

.spawn-entry [data-remove-spawn] {
  grid-column: 1 / -1;
  justify-self: start;
}

.spawn-entry [data-custom-mob-input] {
  grid-column: 1 / -1;
}

.mapping-source {
  margin-top: -0.5rem;
}

dialog.editor-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-sizing: border-box;
  width: min(600px, calc(100vw - 2rem));
  height: fit-content;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #141926;
  color: #f1f3fb;
  box-shadow: 0 24px 60px rgba(4, 6, 12, 0.75);
}

dialog.editor-modal-wide {
  width: min(760px, calc(100vw - 2rem));
}

dialog.editor-modal::backdrop {
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(2px);
}

.editor-modal article {
  margin: 0;
  padding: 1.5rem;
}

.editor-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid #1f2635;
}

.editor-modal-header h3,
.editor-modal-header p {
  margin: 0;
}

.editor-modal-header p {
  margin-top: 0.35rem;
  color: #98a2b3;
}

.editor-modal-form {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.editor-modal-form label {
  margin: 0;
}

.editor-modal-form label > input {
  display: block;
  margin-top: 0.4rem;
}

.editor-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.editor-modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.execution-preview {
  color: #cbd5f5;
  background: #0d1220;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  min-height: 1.25rem;
}

.command-log-table {
  min-width: 900px;
}

.command-log-table code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-badge.success {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.status-badge.failure {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

@media (max-width: 900px) {
  .function-layout,
  .function-layout[data-mode="give"],
  .generator-header,
  .generator-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .coordinate-grid,
  .spawn-entry {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .editor-modal-grid {
    grid-template-columns: 1fr;
  }

  .editor-modal-header {
    display: grid;
  }

  .editor-modal-close {
    justify-self: start;
  }
}
