:root {
  color-scheme: dark;
  --black: #050505;
  --panel: #111;
  --panel-soft: #151515;
  --panel-2: #1a1a1a;
  --border: #333;
  --border-soft: #242424;
  --red: #8a1c1c;
  --red-hover: #b91c1c;
  --text: #ccc;
  --white: #fff;
  --muted: #6b7280;
  --blue: #2a475e;
  --steam: #66c0f4;
  --green: #22c55e;
  --yellow: #eab308;
  --danger: #ef4444;
  --head: "Rajdhani", sans-serif;
  --mono: "Courier Prime", monospace;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.58);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(138, 28, 28, 0.13), transparent 210px),
    radial-gradient(circle at 90% 12%, rgba(102, 192, 244, 0.08), transparent 220px),
    var(--black);
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 78%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover {
  border-color: var(--red-hover);
  color: var(--white);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--steam);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: rgba(255, 255, 255, 0.84);
  font-family: var(--head);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.app-header {
  position: sticky;
  top: 30px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.96);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.38);
  padding: 14px clamp(16px, 4vw, 38px);
  backdrop-filter: blur(10px);
}

.brand,
.header-actions,
.section-head,
.section-actions,
.row-actions,
.modal-titlebar,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
  min-width: 0;
}

.brand img {
  width: 54px;
  height: 54px;
  border: 1px solid #27272a;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.48);
}

.brand h1,
.section-head h2,
.modal-titlebar h2 {
  margin: 0;
  color: var(--white);
  font-family: var(--head);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.brand h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.brand h1 span {
  color: var(--white);
}

.brand h1::after {
  content: " EDITOR";
  color: var(--red-hover);
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.header-actions,
.section-actions {
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-button,
.primary-button,
.square-button {
  min-width: 44px;
  padding: 0 13px;
  font-family: var(--head);
  font-size: 13px;
  font-weight: 700;
}

.tool-button.danger {
  color: #fca5a5;
}

.tool-button.save {
  border-color: rgba(34, 197, 94, 0.38);
  color: #bbf7d0;
}

.primary-button {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}

.primary-button:hover {
  background: var(--red-hover);
}

.page {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

.section-kicker {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.data-section {
  margin-top: 24px;
}

.section-head {
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 12px;
}

.section-head h2,
.modal-titlebar h2 {
  margin-top: 5px;
  font-size: clamp(26px, 3vw, 36px);
}

.search-input,
.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  background: #0a0a0a;
  color: var(--white);
  padding: 0 12px;
  outline: none;
}

.search-input {
  width: min(290px, 100%);
  font-family: var(--head);
  font-size: 15px;
  text-transform: uppercase;
}

.search-input::placeholder,
.field input::placeholder {
  color: #555;
}

.table-frame {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.72);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border-soft);
  padding: 15px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr {
  background: rgba(17, 17, 17, 0.62);
  transition: background 160ms ease;
}

tbody tr:hover {
  background: rgba(138, 28, 28, 0.12);
}

.playtest-row {
  position: relative;
}

.playtest-row.playtest-upcoming {
  background: linear-gradient(90deg, rgba(42, 71, 94, 0.28), rgba(17, 17, 17, 0.72));
}

.playtest-row.playtest-live {
  background:
    linear-gradient(110deg, transparent 0%, rgba(34, 197, 94, 0.18) 22%, transparent 44%),
    linear-gradient(90deg, rgba(20, 83, 45, 0.3), rgba(17, 17, 17, 0.75));
  background-size: 260% 100%, 100% 100%;
  animation: liveShimmer 2.8s linear infinite;
}

.playtest-row.playtest-finished {
  background: rgba(17, 17, 17, 0.42);
  opacity: 0.58;
}

.playtest-row.playtest-upcoming:hover {
  background: linear-gradient(90deg, rgba(42, 71, 94, 0.38), rgba(17, 17, 17, 0.8));
}

.playtest-row.playtest-live:hover {
  background:
    linear-gradient(110deg, transparent 0%, rgba(34, 197, 94, 0.24) 22%, transparent 44%),
    linear-gradient(90deg, rgba(20, 83, 45, 0.38), rgba(17, 17, 17, 0.82));
  background-size: 260% 100%, 100% 100%;
}

.playtest-row.playtest-finished:hover {
  background: rgba(40, 16, 18, 0.5);
  opacity: 0.72;
}

.actions-column {
  text-align: right;
}

.server-name,
.map-card h3 {
  color: var(--white);
  font-family: var(--head);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.08;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.server-meta,
.map-card p,
.subtle {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.tag,
.key-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 22px;
  align-items: center;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(20, 83, 45, 0.35);
  color: #dcfce7;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.playtest-status {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  margin-left: 7px;
  border: 1px solid currentColor;
  padding: 3px 8px;
  font-family: var(--head);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.playtest-status.upcoming {
  background: rgba(42, 71, 94, 0.42);
  color: #93c5fd;
}

.playtest-status.live {
  background: rgba(20, 83, 45, 0.46);
  color: #86efac;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.18);
}

.playtest-status.finished {
  background: rgba(127, 29, 29, 0.32);
  color: #fca5a5;
}

.row-actions {
  justify-content: flex-end;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  padding: 0 9px;
  font-family: var(--head);
  font-size: 12px;
  font-weight: 700;
}

.mini-button.delete {
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.map-card {
  position: relative;
  min-height: 192px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    rgba(17, 17, 17, 0.9);
  padding: 14px;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.map-card::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 72px;
  height: 3px;
  content: "";
  background: var(--red);
}

.map-card:hover {
  border-color: var(--red-hover);
  background: rgba(20, 20, 20, 0.95);
  transform: translateY(-2px);
}

.map-card h3 {
  margin: 12px 0 8px;
}

.map-card p {
  margin: 7px 0;
}

.map-card .row-actions {
  justify-content: flex-start;
  margin-top: 14px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  background: rgba(17, 17, 17, 0.45);
  color: var(--muted);
  padding: 28px;
  text-align: center;
  text-transform: uppercase;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.82);
  animation: fadeIn 160ms ease both;
}

.modal-panel {
  width: min(700px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-top: 4px solid var(--red);
  background: #0a0a0a;
  box-shadow: var(--shadow);
  animation: rise 220ms ease both;
}

.modal-titlebar {
  position: sticky;
  top: 0;
  z-index: 2;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: #111;
  padding: 18px;
}

.square-button {
  width: 42px;
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 20px;
}

.record-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.field label {
  display: block;
  margin-bottom: 7px;
  color: #9ca3af;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.form-actions {
  justify-content: flex-end;
  gap: 9px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(370px, calc(100vw - 36px));
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  background: #111;
  color: var(--white);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes liveShimmer {
  from {
    background-position: 180% 0, 0 0;
  }
  to {
    background-position: -80% 0, 0 0;
  }
}

@media (max-width: 760px) {
  .app-header,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .section-actions {
    justify-content: stretch;
  }

  .header-actions button,
  .section-actions button,
  .search-input {
    width: 100%;
  }

  .page {
    width: min(100vw - 20px, 1220px);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
