:root {
  color-scheme: dark;
  --ink: #06131b;
  --panel: rgba(6, 20, 30, 0.86);
  --panel-strong: rgba(4, 16, 24, 0.94);
  --line: rgba(236, 250, 246, 0.18);
  --line-strong: rgba(245, 211, 135, 0.62);
  --text: #edf9f6;
  --muted: #a8c2c6;
  --gold: #f0c65b;
  --gold-2: #f8dea0;
  --teal: #52e7e9;
  --red: #dc5550;
  --green: #71d28a;
  --blue: #72b8f1;
  --brand-a: #52e7e9;
  --brand-b: #f0c65b;
  --brand-ink: #06131b;
  --brand-glow: rgba(82, 231, 233, 0.34);
  --theme-line: rgba(82, 231, 233, 0.42);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #06131b;
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

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

.launcher {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
  overflow: hidden;
}

.backdrop,
.shade {
  position: fixed;
  inset: 0;
  z-index: -2;
}

.backdrop {
  background-image: var(--active-bg);
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  transition: opacity 260ms ease, transform 420ms ease, filter 260ms ease;
}

.stage.is-flipping ~ .library-dock,
.stage.is-flipping {
  animation: pageFlip 360ms ease both;
}

@keyframes pageFlip {
  0% {
    opacity: 0.48;
    transform: perspective(1400px) rotateY(-6deg) translateY(8px);
  }
  100% {
    opacity: 1;
    transform: perspective(1400px) rotateY(0) translateY(0);
  }
}

.shade {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(3, 11, 17, 0.2), rgba(3, 11, 17, 0.58) 42%, rgba(3, 11, 17, 0.9)),
    linear-gradient(180deg, rgba(2, 8, 12, 0.62), rgba(2, 8, 12, 0.18) 42%, rgba(2, 8, 12, 0.78)),
    radial-gradient(circle at 18% 30%, var(--brand-glow), transparent 28%);
}

.topbar {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 54px);
}

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(4, 16, 24, 0.86), rgba(4, 16, 24, 0.48)),
    radial-gradient(circle at 12% 20%, var(--brand-glow), transparent 42%);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22), 0 0 38px var(--brand-glow);
}

.brand img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 16px var(--brand-glow));
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 28px;
  line-height: 1;
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 26px var(--brand-glow);
}

.brand small,
.muted,
.kicker,
.stat span,
.path-box label,
.log-line time {
  color: var(--muted);
}

.topnav {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(7, 25, 34, 0.62);
  backdrop-filter: blur(12px);
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.client-mode .admin-only {
  display: none !important;
}

.ghost,
.icon-btn,
.gold-btn,
.outline-btn,
.segmented button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--theme-line);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.ghost {
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
}

.ghost.active,
.ghost:hover {
  color: var(--brand-ink);
  background: linear-gradient(180deg, var(--brand-b), var(--brand-a));
  border-color: transparent;
}

.icon-btn {
  width: 42px;
  display: inline-grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(9, 31, 42, 0.86), rgba(9, 31, 42, 0.68)),
    radial-gradient(circle at 25% 15%, var(--brand-glow), transparent 58%);
}

.gold-btn,
.outline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  font-weight: 900;
}

.gold-btn {
  background: linear-gradient(180deg, var(--brand-b), var(--brand-a));
  border-color: var(--theme-line);
  color: var(--brand-ink);
  box-shadow: 0 13px 28px var(--brand-glow);
}

.outline-btn {
  background:
    linear-gradient(180deg, rgba(9, 31, 42, 0.8), rgba(9, 31, 42, 0.62)),
    radial-gradient(circle at 12% 0%, var(--brand-glow), transparent 60%);
  color: var(--text);
}

.large {
  min-height: 54px;
  padding-inline: 22px;
}

.full {
  width: 100%;
}

.ghost:hover,
.icon-btn:hover,
.gold-btn:hover,
.outline-btn:hover,
.segmented button:hover {
  transform: translateY(-1px);
  border-color: var(--theme-line);
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.stage {
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 270px);
  padding: 34px clamp(18px, 5vw, 72px) 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: clamp(22px, 5vw, 64px);
  align-items: center;
}

.hero-copy {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  max-width: 760px;
  padding-bottom: 48px;
}

.game-identity {
  width: min(560px, 100%);
  margin-bottom: 20px;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(4, 16, 24, 0.78), rgba(4, 16, 24, 0.58)),
    radial-gradient(circle at 15% 16%, var(--brand-glow), transparent 42%);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.26), 0 0 26px var(--brand-glow);
}

.game-identity img {
  width: 100%;
  height: 255px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 30px rgba(0, 0, 0, 0.3);
}

.game-identity span,
.game-identity strong {
  display: block;
  text-align: right;
}

.game-identity span {
  color: var(--brand-b);
  font-size: 12px;
  font-weight: 900;
}

.game-identity strong {
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.kicker {
  margin: 0 0 8px;
  color: var(--brand-b);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-shadow: 0 16px 42px rgba(0, 0, 0, 0.48);
}

.hero-desc {
  max-width: 650px;
  color: #d8e9e8;
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.7;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.meta-row,
.hero-actions,
.panel-head,
.dock-head,
.game-meta,
.top-actions,
.path-box div,
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-row,
.hero-actions {
  flex-wrap: wrap;
}

.chip,
.status-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--theme-line);
  background: rgba(9, 31, 42, 0.72);
}

.source-chip {
  color: var(--brand-b);
  border-color: var(--theme-line);
}

.status-pill[data-status="مكتمل"] {
  color: #ccffd5;
  background: rgba(113, 210, 138, 0.18);
}

.status-pill[data-status="تجريبي"] {
  color: #ffe2a7;
  background: rgba(240, 198, 91, 0.18);
}

.status-pill[data-status="قيد العمل"] {
  color: #c7e8ff;
  background: rgba(114, 184, 241, 0.18);
}

.control-panel {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  min-width: 0;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow), 0 0 30px rgba(0, 0, 0, 0.16), 0 0 24px var(--brand-glow);
  backdrop-filter: blur(16px);
  padding: 22px;
}

.panel-head {
  justify-content: space-between;
  align-items: flex-start;
}

.panel-head h2 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

.stat {
  min-height: 88px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(7, 24, 34, 0.82);
  padding: 12px;
  display: grid;
  align-content: space-between;
}

.stat strong {
  font-size: 21px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.path-box {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.checksum-box {
  margin-top: 14px;
  display: grid;
  gap: 7px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(5, 18, 27, 0.78);
  padding: 12px;
}

.checksum-box span {
  color: var(--muted);
  font-size: 12px;
}

.checksum-box code {
  direction: ltr;
  text-align: left;
  color: #eafcff;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.checksum-box a {
  width: fit-content;
  color: var(--brand-a);
  font-size: 12px;
  text-decoration: none;
}

.path-box div {
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(5, 18, 27, 0.86);
  padding: 6px;
}

.path-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  direction: ltr;
  text-align: left;
}

.log-box {
  margin-top: 18px;
  min-height: 132px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(3, 13, 20, 0.9);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.log-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 9px;
  color: #dff5f2;
  font-size: 13px;
}

.library-dock {
  position: relative;
  z-index: 3;
  margin: 0 clamp(18px, 4vw, 54px) 28px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(4, 16, 24, 0.78);
  backdrop-filter: blur(16px);
  padding: 14px;
  box-shadow: var(--shadow), 0 0 26px var(--brand-glow);
}

.dock-head {
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-box {
  min-height: 44px;
  min-width: min(520px, 100%);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(7, 24, 34, 0.88);
  padding: 0 12px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(7, 24, 34, 0.88);
  overflow-x: auto;
}

.segmented button {
  padding: 0 12px;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--brand-ink);
  background: linear-gradient(180deg, var(--brand-b), var(--brand-a));
  border-color: transparent;
}

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

.game-card {
  position: relative;
  overflow: hidden;
  min-height: 176px;
  border: 1px solid rgba(236, 250, 246, 0.16);
  border-radius: 8px;
  background-image: linear-gradient(90deg, rgba(2, 10, 16, 0.88), rgba(2, 10, 16, 0.35)), var(--card-bg);
  background-size: cover;
  background-position: center;
  text-align: right;
  color: var(--text);
  cursor: pointer;
  padding: 14px;
  display: grid;
  align-content: end;
  gap: 8px;
}

.game-card:hover {
  border-color: var(--theme-line);
}

.game-card.active {
  border-color: var(--theme-line);
  box-shadow: inset 0 0 0 1px var(--theme-line), 0 0 30px var(--brand-glow);
}

.game-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.game-meta {
  flex-wrap: wrap;
  color: #d7e8e8;
  font-size: 12px;
}

.modal {
  width: min(820px, calc(100vw - 28px));
  color: var(--text);
  padding: 0;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow), 0 0 26px var(--brand-glow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(5px);
}

.modal-head {
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--theme-line);
}

.modal-head h2 {
  margin: 0;
}

.install-layout {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 18px;
  line-height: 1.8;
}

.install-layout ol {
  margin: 0;
  padding-inline-start: 24px;
}

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

.patch-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.patch-form .wide {
  grid-column: 1 / -1;
}

.patch-form input,
.patch-form select,
.patch-form textarea {
  width: 100%;
  border: 1px solid var(--theme-line);
  border-radius: 8px;
  background: rgba(3, 13, 20, 0.9);
  color: var(--text);
  outline: 0;
  padding: 11px 12px;
}

.patch-form textarea {
  resize: vertical;
}

.toast {
  position: fixed;
  z-index: 10;
  inset-inline: 24px auto;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--brand-b), var(--brand-a));
  color: var(--brand-ink);
  font-weight: 900;
  box-shadow: var(--shadow), 0 0 28px var(--brand-glow);
  transform: translateY(120px);
  transition: transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
}


@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .brand,
  .topnav,
  .top-actions {
    justify-self: stretch;
  }

  .topnav,
  .top-actions {
    overflow-x: auto;
  }

  .stage {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-copy,
  .control-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .launcher,
  .stage,
  .hero-copy,
  .control-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .library-dock {
    width: auto;
    max-width: none;
    overflow-x: hidden;
  }

  .stage {
    padding-top: 18px;
  }

  .hero-copy {
    padding-bottom: 10px;
    justify-self: stretch;
    text-align: right;
  }

  .game-identity img {
    height: 180px;
  }

  .control-panel,
  .library-dock {
    padding: 12px;
  }

  .topnav,
  .top-actions,
  .hero-actions,
  .meta-row {
    flex-wrap: wrap;
  }

  .topnav {
    width: 100%;
  }

  .topnav .ghost {
    flex: 1 1 30%;
    padding-inline: 8px;
  }

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

  .hero-actions .large {
    flex: 1 1 100%;
  }

  .stat-grid,
  .patch-form,
  .install-layout {
    grid-template-columns: 1fr;
  }

  .game-rail {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: 100%;
    font-size: 28px;
    line-height: 1.18;
  }

  .hero-desc {
    font-size: 14px;
  }
}
