:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #101827;
  --panel: #1c2538;
  --panel-2: #28344f;
  --text: #f7f1da;
  --muted: #b5c1d6;
  --accent: #ffe28a;
  --border: #51617f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 226, 138, 0.15), transparent 34rem),
    linear-gradient(180deg, #0b1020 0%, var(--bg) 100%);
  color: var(--text);
}

.shell {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

p { line-height: 1.7; }

.game-card {
  display: grid;
  grid-template-columns: minmax(0, 640px) 1fr;
  gap: 18px;
  align-items: stretch;
}

canvas {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 4 / 3;
  background: #060914;
  border: 3px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  image-rendering: pixelated;
  touch-action: none;
}

.controls {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-height: 100%;
}

.controls p {
  margin: 10px 0;
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0.12em 0.45em;
  border: 1px solid #70809f;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #111827;
  color: #fff7d1;
  text-align: center;
  font-weight: 700;
}

.hint {
  margin-top: 18px !important;
  color: var(--accent) !important;
}

footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 860px) {
  .game-card {
    grid-template-columns: 1fr;
  }
}


.touch-controls {
  display: none;
  margin-top: 18px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.touch-controls h2 {
  margin-bottom: 14px;
}

.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(56px, 86px));
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 10px;
}

.touch-controls button {
  min-height: 48px;
  border: 1px solid #70809f;
  border-bottom-width: 4px;
  border-radius: 12px;
  background: #111827;
  color: #fff7d1;
  font-weight: 800;
  font-size: 1rem;
  touch-action: manipulation;
}

.touch-controls button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.touch-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (pointer: coarse), (max-width: 860px) {
  .touch-controls {
    display: block;
  }
}


.admin-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.admin-link:hover {
  filter: brightness(1.18);
}

/* QUEST_RPG_TUTORIAL_V5_DEPLOY_READY admin UI */
.admin-page {
  background:
    radial-gradient(circle at top right, rgba(126, 224, 129, 0.12), transparent 28rem),
    radial-gradient(circle at top left, rgba(255, 226, 138, 0.15), transparent 34rem),
    linear-gradient(180deg, #0b1020 0%, var(--bg) 100%);
}

.admin-shell {
  width: min(1240px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.admin-hero {
  margin-bottom: 16px;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.admin-nav a,
.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(17, 24, 39, 0.72);
  text-decoration: none;
  font-weight: 700;
}

.admin-toolbar,
.admin-panel {
  margin-top: 18px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.24);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.admin-toolbar button,
.placement-actions button,
.editor-card button,
.json-actions button,
.placement-form button {
  min-height: 40px;
  border: 1px solid #70809f;
  border-bottom-width: 4px;
  border-radius: 10px;
  background: #111827;
  color: #fff7d1;
  font-weight: 800;
  cursor: pointer;
}

.admin-toolbar button,
.json-actions button,
.placement-actions button,
.placement-form button {
  padding: 0 14px;
}

.admin-toolbar button:active,
.placement-actions button:active,
.editor-card button:active,
.json-actions button:active,
.placement-form button:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.admin-status {
  flex-basis: 100%;
  margin: 4px 0 0;
  color: var(--muted);
}

.admin-status[data-kind="ok"] { color: #a7f3d0; }
.admin-status[data-kind="error"] { color: #ffb4b4; }

.token-field {
  min-width: min(420px, 100%);
}

.admin-page label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.admin-page input,
.admin-page select,
.admin-page textarea {
  width: 100%;
  border: 1px solid #70809f;
  border-radius: 10px;
  background: #111827;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

.admin-page textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.45;
}

.admin-page textarea.invalid,
.admin-page input.invalid {
  border-color: #ff7070;
  box-shadow: 0 0 0 2px rgba(255, 112, 112, 0.18);
}

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

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

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.summary-cards article {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(17, 24, 39, 0.58);
}

.summary-cards span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-cards strong {
  display: block;
  margin-top: 5px;
  color: var(--accent);
  font-size: 1.2rem;
}

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

.editor-card {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(17, 24, 39, 0.48);
}

.editor-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.editor-card h3,
.editor-card h4 {
  margin: 0;
  color: var(--accent);
}

.enemy-table {
  display: grid;
  gap: 10px;
}

.enemy-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) repeat(5, minmax(74px, 0.7fr)) minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.boss-card .enemy-row {
  grid-template-columns: minmax(150px, 1.5fr) repeat(5, minmax(74px, 0.7fr)) minmax(110px, 1fr);
}

.map-toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1.2fr) minmax(180px, 1fr) minmax(160px, 0.8fr) minmax(120px, 0.6fr);
  gap: 12px;
  margin-bottom: 14px;
}

.map-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

.map-grid {
  display: grid;
  gap: 1px;
  overflow: auto;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
}

.map-cell {
  width: 20px;
  height: 20px;
  border: 0;
  padding: 0;
  line-height: 20px;
  font-size: 11px;
  color: #111827;
  cursor: pointer;
}

.map-cell.selected {
  outline: 2px solid #ff7070;
  outline-offset: -2px;
}

.map-cell.grass { background: #4a9b57; }
.map-cell.flower { background: #67bb6a; }
.map-cell.path { background: #c5a05b; }
.map-cell.tree { background: #315f3d; }
.map-cell.water { background: #3576ad; }
.map-cell.roof { background: #8b3f38; }
.map-cell.house { background: #d8b06e; }
.map-cell.door { background: #5f3b2f; }
.map-cell.mountain { background: #6b6f7b; }
.map-cell.gate { background: #24212c; color: #fff; }
.map-cell.floor { background: #5b5360; }
.map-cell.wall { background: #2d2933; color: #fff; }
.map-cell.rock { background: #44404a; }
.map-cell.unknown { background: #111827; }

.placement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.object-sidebar {
  min-width: 0;
}

.placement-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.placement-item {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.7);
  color: var(--text);
  padding: 10px;
  cursor: pointer;
}

.placement-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 226, 138, 0.14);
}

.placement-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

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

.placement-form .wide,
.placement-form button {
  grid-column: 1 / -1;
}

.json-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.json-box {
  width: 100%;
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

@media (max-width: 980px) {
  .enemy-row,
  .boss-card .enemy-row,
  .map-toolbar,
  .map-editor-layout {
    grid-template-columns: 1fr;
  }

  .map-grid {
    max-height: 70vh;
  }
}


.form-section-title {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 1rem;
}
.tile-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 10px 0 12px;
}
.tile-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}
.check-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px !important;
  min-height: 38px;
}
.map-cell.has-portal {
  outline: 2px solid rgba(255, 226, 138, 0.95);
  outline-offset: -3px;
  font-size: 13px;
  font-weight: 800;
}
.placement-form select,
.form-grid select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
}
