:root {
  --bg: #e6edf6;
  --bg-soft: #ffffff;
  --bg-elevated: #f4f8fd;
  --ink: #10203a;
  --muted: #4d607d;
  --accent: #1868db;
  --accent-dark: #0f4c81;
  --line: rgba(9, 30, 66, 0.24);
  --success: #1f845a;
  --error: #c9372c;
  --warning: #9a6700;
  --card-shadow: 0 16px 36px rgba(9, 30, 66, 0.12);
  --card-shadow-strong: 0 22px 56px rgba(9, 30, 66, 0.18);
  --focus-ring: 0 0 0 3px rgba(24, 104, 219, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Aptos, "Segoe UI Variable Text", "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(24, 104, 219, 0.12), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #dfe8f2 100%);
  line-height: 1.5;
}

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

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

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(241, 246, 253, 1));
  box-shadow: var(--card-shadow-strong);
}

.hero-copy {
  min-width: 0;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: #52627a;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(9, 30, 66, 0.1);
  background: rgba(24, 104, 219, 0.08);
  color: #154ea5;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1,
.card h2,
.section-card h3 {
  font-family: Aptos Display, Aptos, "Segoe UI Variable Text", "IBM Plex Sans", "Segoe UI", sans-serif;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  letter-spacing: 0;
}

.subtitle {
  max-width: 70ch;
  margin: 12px 0 0;
  color: var(--muted);
}

.hero-nav,
.actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-side {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(9, 30, 66, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: #324968;
  font-weight: 800;
  text-align: center;
}

.admin-tab.active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: var(--card-shadow);
}

.logout-form {
  margin: 0;
}

.main-grid,
.section-grid {
  display: grid;
  gap: 20px;
}

.main-grid {
  grid-template-columns: 1.2fr 0.8fr;
  margin-bottom: 20px;
}

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

.section-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(243, 247, 252, 1));
  box-shadow: var(--card-shadow);
}

.intro-card {
  padding: 16px 18px;
}

.intro-card h2 {
  margin: 0 0 10px;
}

.intro-card p {
  margin: 0;
}

.banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
  transition: opacity 220ms ease, transform 220ms ease;
}

.banner:last-child {
  margin-bottom: 0;
}

.banner.is-dismissing {
  opacity: 0;
  transform: translateY(-6px);
}

.banner.success {
  color: var(--success);
  background: rgba(31, 132, 90, 0.14);
  border: 1px solid rgba(31, 132, 90, 0.24);
}

.banner.error {
  color: var(--error);
  background: rgba(201, 55, 44, 0.12);
  border: 1px solid rgba(201, 55, 44, 0.22);
}

.banner.warning {
  color: var(--warning);
  background: rgba(230, 160, 13, 0.16);
  border: 1px solid rgba(230, 160, 13, 0.24);
}

.dashboard-flash-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.dashboard-flash {
  margin-bottom: 0;
}

.stats {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.stats-hero {
  margin-top: 0;
  justify-content: flex-end;
}

.stats div {
  display: grid;
  gap: 4px;
  min-width: 96px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #edf4fc;
  border: 1px solid rgba(9, 30, 66, 0.2);
}

.stats strong {
  font-size: 1.45rem;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

label span {
  font-size: 0.95rem;
}

.field-help {
  display: block;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  font-weight: 500;
}

.field-help code {
  color: #154ea5;
  background: rgba(24, 104, 219, 0.08);
  padding: 1px 6px;
  border-radius: 999px;
}

.translation-stack {
  display: grid;
  gap: 14px;
}

.translation-tabs {
  display: grid;
  gap: 14px;
}

.translation-tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.translation-tab {
  display: grid;
  justify-items: start;
  gap: 10px;
  min-height: 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.08);
  background: #f8fafc;
  color: var(--ink);
}

.translation-tab:hover {
  border-color: rgba(24, 104, 219, 0.24);
  background: #f2f7ff;
}

.translation-tab.is-active {
  border-color: rgba(24, 104, 219, 0.32);
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.98), rgba(247, 250, 255, 0.98));
  box-shadow: inset 0 0 0 1px rgba(24, 104, 219, 0.08);
}

.translation-tab-main,
.translation-tab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.translation-tab-main {
  font-weight: 700;
}

.translation-tab-locale {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(24, 104, 219, 0.1);
  color: #154ea5;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.translation-tab-badge,
.translation-tab-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.translation-tab-badge.required {
  color: #154ea5;
  background: rgba(24, 104, 219, 0.1);
}

.translation-tab-badge.optional {
  color: var(--muted);
  background: rgba(9, 30, 66, 0.05);
}

.translation-tab-state.is-complete {
  color: var(--success);
  background: rgba(31, 132, 90, 0.1);
}

.translation-tab-state.is-empty {
  color: var(--muted);
  background: rgba(9, 30, 66, 0.04);
}

.translation-intro h3 {
  margin: 0 0 8px;
  color: #101828;
}

.translation-intro p {
  margin: 0;
}

.translation-card {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: #f6faff;
}

.translation-panel[hidden] {
  display: none;
}

.translation-panel-header {
  margin-bottom: 14px;
}

.translation-panel-header strong {
  display: inline-block;
  margin-bottom: 4px;
  color: #101828;
}

.translation-panel-header p {
  margin: 0;
}

.translation-card legend {
  padding: 0 8px;
  color: #154ea5;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.label-with-tooltip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-tooltip {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: rgba(24, 104, 219, 0.06);
  color: #154ea5;
  font-size: 0.75rem;
  line-height: 1;
  cursor: help;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ink);
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(9, 30, 66, 0.03);
}

input:focus,
select:focus,
textarea:focus,
button:focus,
.secondary-button:focus,
.ghost:focus,
.danger-button:focus,
summary:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: rgba(24, 104, 219, 0.5);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(207, 190, 161, 0.72);
}

textarea {
  resize: vertical;
}

.rich-text-editor {
  display: grid;
  gap: 8px;
}

.rich-text-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rich-text-button {
  min-height: 34px;
  padding: 7px 10px;
}

.rich-text-button.is-active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.rich-text-color {
  display: inline-flex;
  width: auto;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.rich-text-color input {
  width: 132px;
  padding: 7px 9px;
}

button,
.secondary-button,
.ghost,
.danger-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}

button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}

.secondary-button,
.ghost {
  color: var(--ink);
  border-color: rgba(9, 30, 66, 0.12);
  background: #ffffff;
}

.danger-button {
  color: var(--error);
  border-color: rgba(201, 55, 44, 0.2);
  background: rgba(201, 55, 44, 0.06);
}

.admin-modal {
  width: min(1040px, calc(100% - 28px));
  max-height: min(86vh, 920px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: transparent;
  box-shadow: var(--card-shadow-strong);
}

.admin-modal::backdrop {
  background: rgba(8, 20, 38, 0.56);
  backdrop-filter: blur(3px);
}

.admin-modal-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(86vh, 920px);
  overflow: hidden;
  border: 1px solid rgba(9, 30, 66, 0.18);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f4f8fd);
}

.admin-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(9, 30, 66, 0.14);
}

.admin-modal-head h2 {
  margin: 4px 0 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.admin-modal-close {
  flex: 0 0 auto;
}

.admin-modal-body {
  min-height: 0;
  padding: 18px 20px 20px;
  overflow: auto;
}

.diagnostics-modal-body {
  display: grid;
  gap: 18px;
}

.diagnostics-modal .runtime-diagnostic-card,
.diagnostics-modal .preset-sync-card {
  margin-bottom: 0;
}

.json-preview {
  margin: 0;
  min-height: 360px;
  max-height: 64vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(9, 30, 66, 0.12);
  border-radius: 14px;
  color: #16325c;
  background: #f8fbff;
  font: 0.9rem/1.55 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.section-top {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

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

.section-heading h3 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  line-height: 1.1;
}

.section-description {
  margin: 0;
  max-width: none;
}

.section-count {
  flex: 0 0 auto;
  align-self: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(24, 104, 219, 0.12);
  color: #123f84;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

.riddle-list {
  display: grid;
  gap: 12px;
}

.riddle-row {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(238, 244, 251, 1));
  border: 1px solid rgba(9, 30, 66, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.riddle-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 12px;
}

.riddle-main {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(9, 30, 66, 0.12);
}

.riddle-headline {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.riddle-headline strong {
  font-size: 1.05rem;
  line-height: 1.25;
}

.riddle-pills,
.riddle-description,
.tags {
  margin: 0;
}

.riddle-pills,
.riddle-description {
  line-height: 1.35;
}

.riddle-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.riddle-pills::-webkit-scrollbar {
  display: none;
}

.riddle-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.muted,
.empty {
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.tags span {
  background: rgba(24, 104, 219, 0.12);
  color: #123f84;
}

.pill {
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid transparent;
  min-height: 18px;
  padding: 0 6px;
  font-size: 0.66rem;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.pill.draft {
  color: #7a4f01;
  background: rgba(230, 160, 13, 0.18);
  border-color: rgba(154, 103, 0, 0.16);
}

.pill.published {
  color: var(--success);
  background: rgba(31, 132, 90, 0.14);
  border-color: rgba(31, 132, 90, 0.18);
}

.pill.warning {
  color: var(--warning);
  background: rgba(230, 160, 13, 0.18);
  border-color: rgba(154, 103, 0, 0.16);
}

.pill.neutral {
  color: #415875;
  background: rgba(9, 30, 66, 0.08);
  border-color: rgba(9, 30, 66, 0.12);
}

.pill.featured {
  color: #154ea5;
  background: rgba(24, 104, 219, 0.14);
  border-color: rgba(24, 104, 219, 0.16);
}

.pill.new {
  color: #8f2f16;
  background: rgba(210, 76, 32, 0.16);
  border-color: rgba(143, 47, 22, 0.16);
  text-transform: uppercase;
}

.pill.tag-pill {
  color: #154ea5;
  background: rgba(24, 104, 219, 0.12);
  border-color: rgba(24, 104, 219, 0.16);
}

.checkbox-row {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 600;
}

.checkbox-card {
  align-self: end;
  min-height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: #ffffff;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.section-card > .create-riddle {
  margin-top: 18px;
}

.create-riddle-actions {
  justify-content: center;
}

.editor-wrap {
  display: grid;
  gap: 18px;
}

.editor-card {
  width: min(760px, 100%);
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.72fr);
  gap: 20px;
  align-items: start;
}

.editor-main-card,
.editor-sidebar-card {
  min-width: 0;
}

.editor-titlebar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.editor-titlebar h2,
.editor-sidebar-head h3,
.editor-section-head h3 {
  margin: 0;
}

.editor-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent-dark);
}

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

.media-upload-card {
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  border-radius: 20px;
  background: rgba(243, 248, 253, 0.96);
}

.media-upload-head {
  display: grid;
  gap: 6px;
}

.media-preview {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.08);
  background:
    linear-gradient(135deg, rgba(24, 104, 219, 0.08), rgba(15, 23, 42, 0.02)),
    #fff;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-preview-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.audio-preview-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.08);
  background:
    linear-gradient(135deg, rgba(24, 104, 219, 0.08), rgba(15, 23, 42, 0.02)),
    #fff;
}

.audio-preview-card audio {
  width: 100%;
}

.audio-preview-link {
  justify-self: start;
}

.audio-preview-empty {
  min-height: 96px;
}

.preset-pdf-import-card {
  margin-bottom: 16px;
}

.preset-page-toolbar {
  display: grid;
  gap: 10px;
}

.preset-page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-page-tab {
  min-width: 42px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
}

.preset-page-tab.is-active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}

.preset-page-card {
  display: grid;
  gap: 14px;
}

.map-content-slot-card {
  display: grid;
  gap: 12px;
}

.map-content-slot-head {
  margin-bottom: 0;
}

.map-content-slot-head .section-heading {
  align-items: center;
}

.map-content-slot-head h4 {
  margin: 0;
}

.map-content-coordinate-row {
  max-width: 420px;
}

.map-content-upload-card input[type="file"] {
  max-width: 100%;
}

.preset-page-card[hidden],
.map-content-slot-card[hidden] {
  display: none;
}

.preset-page-preview {
  display: block;
  max-width: 280px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.08);
  background:
    linear-gradient(135deg, rgba(24, 104, 219, 0.08), rgba(15, 23, 42, 0.02)),
    #fff;
}

.preset-page-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.editor-section {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.editor-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.editor-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.editor-section-head p,
.editor-sidebar-head p {
  margin: 6px 0 0;
}

.editor-inline-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(24, 104, 219, 0.08);
  color: #154ea5;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.editor-disclosure {
  padding: 0;
  border: 1px solid rgba(9, 30, 66, 0.14);
  border-radius: 20px;
  background: rgba(246, 249, 253, 0.98);
  overflow: hidden;
}

.editor-disclosure summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 700;
}

.editor-disclosure summary::after {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.editor-disclosure[open] summary::after {
  transform: rotate(225deg);
}

.editor-disclosure summary::-webkit-details-marker {
  display: none;
}

.editor-disclosure summary .muted {
  margin: 0;
  font-weight: 500;
}

.editor-disclosure-body {
  padding: 0 18px 18px;
}

.coordinate-panel .editor-disclosure-body {
  padding: 18px;
}

.editor-riddle-section > .editor-disclosure-body {
  border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.editor-riddle-section .coordinate-panel,
.editor-riddle-section .game-area-section {
  margin-top: 0;
}

.editor-riddle-section .coordinate-panel {
  display: grid;
  gap: 16px;
}

.editor-advanced-section {
  margin-top: 18px;
  border-top: 0;
}

.editor-advanced-section > .editor-disclosure-body {
  border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.editor-sidebar {
  display: grid;
  gap: 16px;
  align-self: start;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.editor-sidebar-card {
  gap: 14px;
}

.editor-sidebar-sticky {
  align-self: start;
}

.editor-sidebar-disclosure summary {
  padding: 14px 16px;
}

.editor-sidebar-disclosure .editor-disclosure-body {
  padding-top: 16px;
  border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.editor-actions-sticky {
  margin-top: 20px;
}

.preset-refresh-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.preset-refresh-actions form,
.inline-actions form {
  margin: 0;
}

.preset-pdf-import-feedback {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(9, 30, 66, 0.1);
  background: rgba(9, 30, 66, 0.03);
  color: var(--muted);
  font-size: 0.9rem;
}

.preset-pdf-import-feedback[data-state="ready"] {
  color: #154ea5;
  border-color: rgba(24, 104, 219, 0.18);
  background: rgba(24, 104, 219, 0.06);
}

.preset-pdf-import-actions {
  align-items: center;
}

.preset-pdf-import-actions .muted {
  font-size: 0.9rem;
}

.preset-build-summary {
  display: grid;
  gap: 12px;
}

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

.preset-meta-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: rgba(240, 246, 252, 0.98);
}

.preset-meta-card strong {
  font-size: 0.95rem;
}

.preset-meta-card dl,
.preset-meta-card dt,
.preset-meta-card dd {
  margin: 0;
}

.preset-meta-card dl {
  display: grid;
  gap: 8px;
}

.preset-meta-card dl div {
  display: grid;
  gap: 4px;
}

.preset-meta-card dt {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preset-meta-card dd code {
  color: #154ea5;
  background: rgba(24, 104, 219, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.card h2,
.section-card h3,
.hero h1,
strong {
  color: #101828;
}

.actions form,
.actions a {
  flex-shrink: 0;
}

.actions {
  align-self: start;
  justify-content: flex-end;
  gap: 8px;
}

.riddle-top .actions {
  flex-wrap: nowrap;
  align-items: center;
}

.riddle-health-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.preset-sync-card {
  margin-bottom: 20px;
}

.preset-sync-card-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.preset-sync-stats {
  margin-top: 0;
}

.preset-sync-groups {
  display: grid;
  gap: 14px;
}

.preset-sync-group {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: rgba(241, 247, 253, 0.98);
}

.preset-sync-group-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.preset-sync-group-head p {
  margin: 4px 0 0;
}

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

.preset-sync-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(9, 30, 66, 0.08);
}

.preset-sync-item-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.preset-sync-item-copy p {
  margin: 0;
}

.runtime-diagnostic-card {
  margin-bottom: 20px;
}

.preset-sync-card summary,
.runtime-diagnostic-card summary {
  cursor: pointer;
  font-weight: 700;
}

.preset-sync-body {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.runtime-diagnostic-body {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.runtime-diagnostic-grid,
.runtime-preset-list {
  display: grid;
  gap: 12px;
  align-items: start;
}

.runtime-diagnostic-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.runtime-preset-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.runtime-diagnostic-item {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: rgba(241, 247, 253, 0.98);
}

.runtime-preset-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
}

.runtime-preset-head strong,
.runtime-diagnostic-item dd,
.runtime-diagnostic-item dl div {
  min-width: 0;
}

.runtime-preset-head .inline-actions {
  align-items: center;
  justify-self: end;
  min-width: 0;
}

.runtime-preset-stale-list {
  margin: 0;
}

.runtime-diagnostic-item dl,
.runtime-diagnostic-item dt,
.runtime-diagnostic-item dd {
  margin: 0;
}

.runtime-diagnostic-item dl {
  display: grid;
  gap: 8px;
}

.runtime-diagnostic-item dl div {
  display: grid;
  gap: 4px;
}

.runtime-diagnostic-item dt {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.runtime-diagnostic-item dd code {
  display: inline-block;
  max-width: 100%;
  color: #154ea5;
  background: rgba(24, 104, 219, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.runtime-preset-item .banner {
  margin-bottom: 0;
}

.riddle-row .actions .ghost,
.riddle-row .actions .danger-button,
.riddle-row .actions .secondary-button {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.riddle-row .actions form {
  margin: 0;
}

.ghost:hover,
.secondary-button:hover,
.danger-button:hover {
  filter: brightness(1.1);
}

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

.pile-poil-grid {
  align-items: start;
}

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

.coordinate-paste-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.game-area-section {
  gap: 18px;
}

.game-area-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.34fr) auto;
  gap: 12px;
  align-items: end;
}

.game-area-search-button {
  min-height: 46px;
}

.game-area-feedback {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.game-area-feedback[data-state="ready"] {
  color: var(--success);
}

.game-area-feedback[data-state="error"] {
  color: var(--error);
}

.game-area-results {
  display: grid;
  gap: 10px;
}

.game-area-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  border-radius: 14px;
  background: #ffffff;
}

.game-area-result p {
  margin: 4px 0 0;
}

.game-area-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.game-area-result-meta span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(9, 30, 66, 0.05);
}

.game-area-preview-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
  align-items: start;
}

.game-area-map {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(9, 30, 66, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(24, 104, 219, 0.12), rgba(31, 132, 90, 0.1)),
    #eef6fb;
}

.game-area-map-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #c9d8e4;
}

.game-area-map-tiles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #c9d8e4;
}

.game-area-map-tiles img {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.game-area-map-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(9, 30, 66, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(9, 30, 66, 0.12) 1px, transparent 1px);
  background-size: 25% 25%, 25% 25%;
}

.game-area-map-geometry {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.game-area-map-geometry path {
  fill: rgba(24, 104, 219, 0.12);
  stroke: #ff5a3d;
  stroke-width: 2;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.game-area-map-bbox {
  position: absolute;
  pointer-events: none;
  min-width: 8px;
  min-height: 8px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(24, 104, 219, 0.18);
  box-shadow:
    0 0 0 999px rgba(16, 32, 58, 0.08),
    0 3px 12px rgba(9, 30, 66, 0.2);
  z-index: 2;
}

.game-area-map-bbox[hidden] {
  display: none;
}

.game-area-map-attribution {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 4;
  padding: 2px 6px;
  border-radius: 999px;
  color: #1f3149;
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.7rem;
  font-weight: 700;
}

.game-area-map.is-leaflet .game-area-map-tiles,
.game-area-map.is-leaflet .game-area-map-grid,
.game-area-map.is-leaflet .game-area-map-geometry,
.game-area-map.is-leaflet .game-area-map-bbox,
.game-area-map.is-leaflet .game-area-map-attribution {
  display: none;
}

.game-area-map.leaflet-container {
  background: #c9d8e4;
  color: #0b1f3a;
}

.game-area-map .leaflet-control-attribution {
  border-radius: 999px 0 0 0;
  color: #1f3149;
  font-size: 0.7rem;
  font-weight: 700;
}

.game-area-selected,
.game-area-summary {
  display: grid;
  gap: 12px;
}

.game-area-empty {
  padding: 14px;
  border: 1px dashed rgba(9, 30, 66, 0.24);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.game-area-summary {
  padding: 14px;
  border: 1px solid rgba(9, 30, 66, 0.14);
  border-radius: 14px;
  background: #ffffff;
}

.game-area-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.game-area-summary-head p {
  margin: 4px 0 0;
}

.game-area-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.game-area-meta div {
  display: grid;
  gap: 4px;
}

.game-area-meta dt,
.game-area-meta dd {
  margin: 0;
}

.game-area-meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.game-area-meta dd,
.game-area-meta code {
  overflow-wrap: anywhere;
}

.game-area-options {
  display: grid;
  gap: 10px;
}

.paste-coordinates-button {
  width: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
  color: #154ea5;
  border: 1px solid rgba(9, 30, 66, 0.14);
  background: rgba(24, 104, 219, 0.05);
}

.paste-coordinates-button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paste-coordinates-button[data-paste-state="success"] {
  color: var(--success);
  border-color: rgba(31, 132, 90, 0.24);
  background: rgba(31, 132, 90, 0.1);
}

.paste-coordinates-button[data-paste-state="error"] {
  color: var(--error);
  border-color: rgba(201, 55, 44, 0.24);
  background: rgba(201, 55, 44, 0.08);
}

.login-page {
  display: grid;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, #e6edf6 100%);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 22px;
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--card-shadow-strong);
}

.login-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.login-copy h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.login-copy p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form button {
  width: 100%;
}

.admin-users-stack {
  display: grid;
  gap: 18px;
}

.admin-disclosure {
  padding: 0;
  overflow: hidden;
}

.admin-disclosure-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
}

.admin-disclosure-summary::-webkit-details-marker {
  display: none;
}

.admin-disclosure-summary::after {
  content: "+";
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(9, 30, 66, 0.12);
  background: rgba(24, 104, 219, 0.08);
  color: #154ea5;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
}

.admin-disclosure[open] .admin-disclosure-summary::after {
  content: "-";
}

.admin-disclosure-summary h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.admin-disclosure-summary p {
  margin: 6px 0 0;
}

.admin-disclosure-body {
  display: grid;
  gap: 16px;
  padding: 18px 22px 22px;
  border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.admin-user-create {
  display: grid;
  gap: 16px;
}

.app-update-upload-form {
  display: grid;
  gap: 16px;
}

.app-update-preset-install-form {
  grid-template-columns: 1fr;
}

.app-update-preset-install-form button {
  white-space: nowrap;
}

.app-update-preset-upload-field {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.app-update-preset-upload-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.app-update-preset-upload-copy input {
  width: 100%;
}

.app-update-preset-upload-field .actions {
  align-self: center;
  justify-content: flex-end;
}

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

.app-update-current-version {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.app-update-upload-field,
.app-update-file-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.app-update-file-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.app-update-preset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.app-update-preset-card-head form {
  flex: 0 0 auto;
  margin: 0;
}

.app-update-preset-card-head .secondary-button {
  min-height: 40px;
  padding: 8px 14px;
  white-space: nowrap;
}

.app-update-file-card:has(.app-update-preset-card-head form) {
  border-color: rgba(154, 103, 0, 0.52);
  background: linear-gradient(180deg, #fffaf0 0%, #ffffff 72%);
  box-shadow:
    0 0 0 3px rgba(230, 160, 13, 0.14),
    0 18px 42px rgba(154, 103, 0, 0.18);
}

.app-update-file-card:has(.app-update-preset-card-head form) .app-update-preset-card-head::before {
  content: "Action requise";
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(154, 103, 0, 0.24);
  border-radius: 999px;
  background: rgba(230, 160, 13, 0.2);
  color: var(--warning);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.app-update-file-card:has(.app-update-preset-card-head form) .app-update-preset-card-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.app-update-file-card:has(.app-update-preset-card-head form) .app-update-preset-card-head::before {
  grid-column: 1 / -1;
}

.app-update-file-card:has(.app-update-preset-card-head form) > p.muted {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(154, 103, 0, 0.18);
  border-radius: 12px;
  background: rgba(230, 160, 13, 0.12);
  color: #6f4700;
  font-weight: 800;
}

.app-update-file-card:has(.app-update-preset-card-head form) .app-update-preset-card-head .secondary-button {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #b45309, #f59e0b);
  box-shadow: 0 10px 24px rgba(154, 103, 0, 0.25);
}

.app-update-file-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.app-update-file-card dt {
  color: var(--muted);
  font-weight: 700;
}

.app-update-file-card dd {
  margin: 0;
  text-align: right;
}

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

.admin-user-stack {
  display: grid;
  gap: 14px;
}

.admin-user-editor {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.admin-user-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.admin-user-summary strong {
  font-size: 1.05rem;
}

.admin-user-summary p {
  margin: 4px 0 0;
}

.admin-user-pills,
.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-user-pills {
  justify-content: flex-end;
}

.admin-user-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.stat-card {
  display: grid;
  gap: 6px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--card-shadow);
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
  color: var(--accent-dark);
}

.stat-card span {
  font-weight: 800;
}

.stat-card p {
  margin: 0;
}

@media (max-width: 900px) {
  .hero,
  .section-top,
  .riddle-row,
  .main-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero {
    gap: 18px;
  }

  .riddle-top {
    grid-template-columns: 1fr;
  }

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

  .hero-side {
    justify-items: stretch;
  }

  .stats-hero {
    justify-content: flex-start;
  }

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

  .editor-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .editor-sidebar-sticky {
    position: static;
  }

  .media-upload-grid {
    grid-template-columns: 1fr;
  }

  .editor-titlebar,
  .editor-section-head,
  .editor-disclosure summary,
  .preset-sync-card-head,
  .preset-sync-group-head,
  .preset-sync-item,
  .runtime-preset-head,
  .game-area-search-row,
  .game-area-result,
  .game-area-preview-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .admin-disclosure-summary,
  .admin-user-summary {
    display: grid;
  }

  .admin-user-pills {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .admin-modal {
    width: min(100% - 16px, 1040px);
    max-height: 92vh;
  }

  .admin-modal-shell {
    max-height: 92vh;
  }

  .admin-modal-head {
    display: grid;
    padding: 16px;
  }

  .admin-modal-close {
    width: 100%;
  }

  .admin-modal-body {
    padding: 16px;
  }

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

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

  .coordinate-paste-row {
    grid-template-columns: 1fr;
  }

  .editor-actions > * {
    width: 100%;
  }

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

  .translation-tab {
    padding: 12px 14px;
  }

  .admin-tabs,
  .admin-user-form-grid,
  .app-update-upload-grid,
  .app-update-file-grid {
    grid-template-columns: 1fr;
  }

  .app-update-preset-upload-field {
    grid-template-columns: 1fr;
  }

  .app-update-preset-upload-field .actions {
    justify-content: flex-start;
  }

  .app-update-preset-card-head {
    display: grid;
  }

  .login-panel {
    padding: 22px;
  }

  .admin-disclosure-summary,
  .admin-disclosure-body {
    padding-left: 16px;
    padding-right: 16px;
  }
}
