:root {
  --bg: #0d0d0f;
  --panel: #141416;
  --panel-soft: #19191c;
  --field: #101012;
  --border: #2b2b30;
  --border-strong: #3b3b42;
  --text: #f4f1f1;
  --text-soft: #aaa5a7;
  --text-muted: #777276;
  --red: #e84b55;
  --red-dark: #b92e3c;
  --green: #53b987;
  --amber: #d6a956;
  --header-height: 64px;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
}

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

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

a {
  color: inherit;
}

.admin-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 13, 15, 0.96);
  backdrop-filter: blur(16px);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.admin-brand img {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.admin-brand span {
  display: flex;
  flex-direction: column;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

.admin-brand strong {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.header-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.button {
  padding: 0 15px;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--border);
  background: var(--panel-soft);
  color: var(--text-soft);
  font-size: 18px;
}

.button-quiet {
  border-color: var(--border);
  background: var(--panel-soft);
  color: var(--text-soft);
}

.button-quiet:hover,
.icon-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.button-primary {
  border-color: #ef626a;
  background: var(--red);
  color: #fff;
}

.button-primary:hover {
  background: #f15a63;
}

.button-danger {
  border-color: rgba(232, 75, 85, 0.35);
  background: rgba(232, 75, 85, 0.09);
  color: #ff7c84;
}

.button-danger:hover {
  background: rgba(232, 75, 85, 0.16);
}

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

.admin-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  padding-top: var(--header-height);
}

.game-sidebar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  width: 300px;
  padding: 18px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: #111113;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-heading > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.sidebar-heading span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.sidebar-heading strong {
  color: var(--text-muted);
  font-size: 12px;
}

.search-field {
  display: block;
  margin: 16px 0 12px;
}

.search-field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  background: var(--field);
}

.search-field input:focus {
  border-color: var(--red);
}

.game-list {
  display: grid;
  gap: 5px;
}

.game-list-empty {
  padding: 34px 10px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.game-list-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.game-list-item:hover,
.game-list-item.active {
  border-color: var(--border);
  background: var(--panel-soft);
}

.game-list-item.active {
  border-color: rgba(232, 75, 85, 0.4);
}

.game-list-item img {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: cover;
}

.game-list-copy {
  min-width: 0;
}

.game-list-copy strong,
.game-list-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-list-copy strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.game-list-copy span {
  color: var(--text-muted);
  font-size: 10px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.published {
  background: var(--green);
}

.editor-panel {
  grid-column: 2;
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 34px 38px 120px;
}

.editor-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
}

.editor-heading p {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
}

.editor-heading h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 0;
}

.form-section {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 30px;
  padding: 30px 0;
  border-top: 1px solid var(--border);
}

.form-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.form-section-heading > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid rgba(232, 75, 85, 0.35);
  border-radius: 6px;
  background: rgba(232, 75, 85, 0.08);
  color: #f0757c;
  font-size: 10px;
  font-weight: 800;
}

.form-section-heading h2,
.form-section-heading p {
  margin: 0;
}

.form-section-heading h2 {
  margin-top: 2px;
  font-size: 15px;
}

.form-section-heading p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

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

.field {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.field em {
  color: var(--red);
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  background: var(--field);
  color: var(--text);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field input,
.field select {
  height: 42px;
  padding: 0 12px;
}

.field textarea {
  min-height: 90px;
  padding: 11px 12px;
  line-height: 1.65;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232, 75, 85, 0.09);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #5f5b5e;
}

.field input[type="file"] {
  height: auto;
  min-height: 42px;
  padding: 8px;
  color: var(--text-muted);
}

.field input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.field small {
  align-self: flex-end;
  margin-top: -2px;
  color: var(--text-muted);
  font-size: 10px;
}

.field small b {
  color: var(--text-soft);
  font-weight: 600;
}

.span-2 {
  grid-column: span 2;
}

.slug-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--field);
}

.slug-field:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232, 75, 85, 0.09);
}

.slug-field span {
  padding: 0 9px;
  color: var(--text-muted);
  font-size: 11px;
}

.slug-field input {
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
}

.media-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
}

.cover-preview-wrap {
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #17171a 25%, transparent 25%),
    linear-gradient(-45deg, #17171a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #17171a 75%),
    linear-gradient(-45deg, transparent 75%, #17171a 75%),
    #111113;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.cover-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-fields {
  align-content: start;
}

.collection-editor {
  min-width: 0;
}

.collection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.collection-toolbar strong,
.collection-toolbar span {
  display: block;
}

.collection-toolbar strong {
  color: var(--text-soft);
  font-size: 12px;
}

.collection-toolbar span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.collection-list {
  display: grid;
  gap: 10px;
}

.collection-empty {
  display: grid;
  min-height: 74px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 11px;
}

.collection-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.018);
}

.collection-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.collection-item-header strong {
  color: var(--text-soft);
  font-size: 11px;
}

.remove-collection-item {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  place-items: center;
}

.remove-collection-item:hover {
  border-color: rgba(232, 75, 85, 0.4);
  color: #ff7c84;
}

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

.collection-item-grid.three-columns {
  grid-template-columns: 0.7fr 1fr 1.6fr;
}

.collection-span-all {
  grid-column: 1 / -1;
}

.collection-item .field {
  gap: 5px;
}

.collection-item .field > span {
  font-size: 10px;
}

.collection-item .field input,
.collection-item .field select {
  height: 38px;
  font-size: 12px;
}

.collection-item .field textarea {
  min-height: 78px;
  font-size: 12px;
}

.seo-section {
  padding-bottom: 42px;
}

.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.save-bar strong,
.save-bar span {
  display: block;
}

.save-bar strong {
  font-size: 12px;
}

.save-bar span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.login-dialog {
  width: min(92vw, 390px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}

.login-dialog::backdrop {
  background: rgba(7, 7, 8, 0.84);
  backdrop-filter: blur(8px);
}

.login-dialog form {
  display: flex;
  flex-direction: column;
  padding: 34px;
}

.login-dialog img {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.login-dialog p {
  margin: 18px 0 3px;
  color: var(--red);
  font-size: 9px;
  font-weight: 800;
}

.login-dialog h2 {
  margin: 0 0 22px;
  font-size: 22px;
}

.login-dialog .login-error {
  min-height: 18px;
  margin: 8px 0;
  color: #ff7b83;
  font-size: 11px;
  font-weight: 500;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #222226;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

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

.toast.error {
  border-color: rgba(232, 75, 85, 0.5);
}

.is-hidden {
  display: none !important;
}

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

:focus-visible {
  outline: 2px solid #ff747c;
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .admin-layout {
    display: block;
  }

  .game-sidebar {
    position: static;
    width: auto;
    max-height: 330px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .editor-panel {
    width: 100%;
    padding-inline: 24px;
  }
}

@media (max-width: 680px) {
  .admin-header {
    padding-inline: 12px;
  }

  .header-actions .button-quiet:first-child,
  #generateAllButton {
    display: none;
  }

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

  .editor-panel {
    padding: 25px 16px 100px;
  }

  .editor-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .media-layout {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .media-fields {
    display: flex;
    flex-direction: column;
  }

  .collection-item-grid,
  .collection-item-grid.three-columns {
    grid-template-columns: 1fr;
  }

  .save-bar {
    bottom: 8px;
  }

  .save-bar > div {
    display: none;
  }

  .save-bar .button {
    width: 100%;
  }
}

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

  .cover-preview-wrap {
    width: 140px;
  }
}
