:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel2: #0f1620;
  --text: #e6edf3;
  --muted: #8b949e;
  --line: #30363d;
  --accent: #58a6ff;
  --accent2: #1f6feb;
  --ok: #238636;
  --err: #da3633;
  --warn: #9e6a03;
  --shadow: 0 24px 80px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(88,166,255,.12), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(163,113,247,.10), transparent 36%),
    var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.page { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }
.login-shell { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.login-card, .card, .topbar {
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.login-card { width: min(430px, 100%); padding: 34px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 24px; margin-bottom: 20px; }
.card { padding: 22px; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-card { margin-top: 20px; }

h1, h2 { margin: 0 0 8px; line-height: 1.1; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: 21px; }
p { margin: 0 0 16px; }
.muted { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #c9d1d9;
  background: rgba(88,166,255,.12);
  border: 1px solid rgba(88,166,255,.28);
  border-radius: 999px;
  padding: 6px 10px;
  margin-bottom: 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.form { display: grid; gap: 14px; }
.form.compact { gap: 12px; }
label { display: grid; gap: 7px; color: #c9d1d9; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel2);
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(88,166,255,.12); }
textarea {
  min-height: 520px;
  resize: vertical;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text);
  background: #30363d;
  cursor: pointer;
  font-weight: 700;
  transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn.primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: white; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: linear-gradient(135deg, #8b1d1d, var(--err)); color: white; }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.checkbox { display: flex; grid-template-columns: auto 1fr; flex-direction: row; align-items: center; font-weight: 500; color: var(--muted); }
.checkbox input { width: auto; }
.protect-check { color: #e6edf3; background: rgba(88,166,255,.08); border: 1px solid rgba(88,166,255,.20); padding: 12px; border-radius: 14px; }
.protect-options { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.025); }
.hidden { display: none !important; }
.hint-box {
  background: rgba(88,166,255,.08);
  border: 1px solid rgba(88,166,255,.18);
  border-radius: 14px;
  padding: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.danger-card { border-color: rgba(218,54,51,.25); }

.codebox {
  max-height: 420px;
  overflow: auto;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.empty, .small-box {
  background: rgba(255,255,255,.04);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 12px;
  color: var(--muted);
}
.small-box { margin-top: 18px; }
code { color: #a5d6ff; }

.alerts { display: grid; gap: 10px; margin-bottom: 18px; }
.alert {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow-wrap: anywhere;
}
.alert-success { border-color: rgba(46,160,67,.55); background: rgba(46,160,67,.13); }
.alert-error { border-color: rgba(218,54,51,.55); background: rgba(218,54,51,.13); }

@media (max-width: 900px) {
  .grid.two { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

.protect-card { margin-bottom: 20px; }
.form-row.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.protection-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}
.inline-protect-check {
  min-height: 46px;
  margin: 0;
}
.protection-buttons {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.update-protection-btn,
.delete-protection-btn {
  min-width: 150px;
  white-space: nowrap;
}
.delete-protection-btn {
  min-width: 190px;
}

@media (max-width: 720px) {
  .form-row.two-cols,
  .protection-row {
    grid-template-columns: 1fr;
  }
  .protection-buttons {
    flex-direction: column;
  }
  .update-protection-btn,
  .delete-protection-btn {
    width: 100%;
  }
}

.subsection {
  margin-top: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.022);
}
.subsection h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.big-update-btn {
  width: 100%;
  min-height: 58px;
  font-size: 17px;
  border-radius: 18px;
  margin-top: 4px;
}
.single-action-row {
  grid-template-columns: 1fr auto;
}

@media (max-width: 720px) {
  .single-action-row {
    grid-template-columns: 1fr;
  }
  .delete-protection-btn {
    width: 100%;
  }
}

.login-shell-wide {
  grid-template-columns: minmax(360px, 430px) minmax(420px, 1fr);
  gap: 20px;
  align-items: stretch;
  place-items: initial;
}
.login-card-main,
.login-info-card {
  width: 100%;
}
.login-info-card {
  padding: 28px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.login-info-error {
  margin-bottom: 14px;
}
.login-info-label {
  margin-top: 12px;
}
.login-info-textarea {
  min-height: 520px;
  max-height: 72vh;
  white-space: pre;
}
@media (max-width: 980px) {
  .login-shell-wide {
    grid-template-columns: 1fr;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
}

.json-editor-wrap {
  position: relative;
}

.json-helper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.022);
}

.chip {
  border: 1px solid rgba(88,166,255,.24);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(88,166,255,.08);
  color: #c9d1d9;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.chip:hover {
  border-color: var(--accent);
  background: rgba(88,166,255,.14);
}

.json-suggest {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: min(320px, calc(100% - 28px));
  max-height: 240px;
  overflow: auto;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1620;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  padding: 6px;
}

.json-suggest-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: Consolas, Monaco, monospace;
}
.json-suggest-item:hover,
.json-suggest-item.active {
  background: rgba(88,166,255,.14);
}

.game-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr) auto;
  gap: 14px;
  align-items: end;
}
.delete-game-box {
  display: grid;
  gap: 7px;
  align-self: end;
}
.field-spacer {
  display: block;
  height: 1.2em;
  color: transparent;
}
.delete-game-btn {
  min-width: 130px;
  white-space: nowrap;
}
.json-save-note {
  margin-top: 12px;
}
.bottom-update-btn {
  margin-top: 20px;
  margin-bottom: 0;
  font-size: 20px;
  min-height: 68px;
  box-shadow: 0 18px 50px rgba(31,111,235,.28);
}
@media (max-width: 900px) {
  .game-row {
    grid-template-columns: 1fr;
  }
  .field-spacer {
    display: none;
  }
  .delete-game-btn {
    width: 100%;
  }
}

.translate-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 38px;
}
.translate-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
#google_translate_element,
#google_translate_element select {
  max-width: 260px;
}
.user-topbar {
  padding: 16px 20px;
  margin-bottom: 20px;
}
.logged-user {
  font-size: 16px;
  color: var(--text);
}
.logout-form {
  margin: 0;
}
.notranslate input,
.notranslate textarea,
.notranslate select {
  translate: no;
}

@media (max-width: 720px) {
  .translate-bar {
    justify-content: stretch;
    align-items: flex-start;
    flex-direction: column;
  }
  .user-topbar {
    flex-direction: row;
    align-items: center;
  }
}

.upload-progress-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #c9d1d9;
  font-weight: 700;
}
.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  transition: width .15s ease;
}
.upload-details {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.small-btn {
  padding: 8px 11px;
  border-radius: 11px;
  font-size: 12px;
}
.btn.disabled,
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

/* Gdy APK/XAPK/APKS dopiero wgrywa się na serwer, przycisk Aktualizuj ma być szary.
   Po zakończeniu uploadu JS usuwa disabled/disabled-class i wraca normalny niebieski gradient. */
.btn.primary.disabled,
.btn.primary:disabled,
.big-update-btn.disabled,
.big-update-btn:disabled {
  background: linear-gradient(135deg, #30363d, #484f58) !important;
  color: #8b949e !important;
  border: 1px solid #484f58;
  box-shadow: none !important;
}

/* Twardy stan uploadu APK/XAPK/APKS. Klasa jest dodawana przez JS,
   a inline style w JS dodatkowo omija cache CSS na serwerze. */
.btn.primary.uploading-lock,
.big-update-btn.uploading-lock,
#mainUpdateBtn.uploading-lock {
  background: linear-gradient(135deg, #30363d, #484f58) !important;
  color: #8b949e !important;
  border: 1px solid #484f58 !important;
  box-shadow: none !important;
  opacity: .72 !important;
  cursor: not-allowed !important;
}
