:root {
  --page-bg: #091119;
  --panel: rgba(14, 22, 30, 0.84);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #eef6ff;
  --muted: #c7d7e9;
  --accent: #6fd4ff;
  --accent-strong: #2d8cff;
  --accent-soft: rgba(111, 212, 255, 0.18);
  --success: #8ee68c;
  --warning: #ffd27b;
  --danger: #ff9e9e;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --dungeon-image: url("assets/default-dungeon.webp");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background: var(--page-bg);
}

body {
  position: relative;
}

button,
input,
textarea {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(5, 13, 20, 0.7);
  color: var(--text);
  padding: 0.95rem 1rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(238, 246, 255, 0.52);
}

input:focus,
textarea:focus {
  border-color: rgba(111, 212, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(111, 212, 255, 0.16);
  background: rgba(9, 18, 28, 0.88);
}

textarea {
  resize: vertical;
}

button,
.button-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

button:hover:not(:disabled),
.button-link:hover {
  transform: translateY(-1px);
  border-color: rgba(111, 212, 255, 0.58);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

button.primary,
.button-link.primary {
  background: linear-gradient(180deg, rgba(72, 170, 255, 0.98), rgba(29, 110, 243, 0.98));
  border-color: transparent;
  color: white;
}

button.primary:hover:not(:disabled),
.button-link.primary:hover {
  box-shadow: 0 18px 34px rgba(29, 110, 243, 0.34);
}

button.ghost,
.button-link.ghost {
  background: rgba(255, 255, 255, 0.05);
}

button.large {
  min-height: 56px;
  font-weight: 700;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

.page-background {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 12, 18, 0.58), rgba(6, 12, 18, 0.78)),
    radial-gradient(circle at top, rgba(90, 205, 255, 0.18), transparent 48%),
    var(--dungeon-image) center / cover no-repeat;
  filter: saturate(1.02);
  transform: scale(1.03);
}

.site-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
  display: grid;
  gap: 22px;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 28px 30px;
  overflow: hidden;
}

.hero::after,
.maze-board::after,
.live-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(111, 212, 255, 0.09), transparent 42%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
}

.hero h1,
.hero h2,
.panel-heading h2 {
  margin: 0;
  line-height: 1.24;
}

.hero h1 {
  font-size: clamp(1.8rem, 2vw + 1.1rem, 2.9rem);
}

.hero-subtitle {
  margin: 16px 0 0;
  max-width: 920px;
  color: var(--muted);
  line-height: 1.84;
  font-size: 1.02rem;
}

.panel-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.panel-heading p,
.sidebar-copy,
.field small,
.summary-label,
.preview-label {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.form-panel,
.admin-panel {
  padding: 24px;
}

.field-grid {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 10px;
}

.field-lg textarea {
  min-height: 170px;
}

.field-label {
  font-weight: 700;
  line-height: 1.7;
}

.difficulty-wrap {
  display: grid;
  gap: 14px;
}

.difficulty-wrap input[type="range"] {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.difficulty-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.difficulty-inline input {
  width: 96px;
  padding: 0.5rem 0.75rem;
  text-align: right;
}

.unit {
  color: var(--muted);
  font-weight: 700;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 20px;
}

.button-row.left {
  justify-content: flex-start;
}

.button-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.button-stack.compact {
  align-self: end;
}

.status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  line-height: 1.7;
  border: 1px solid transparent;
  background: rgba(111, 212, 255, 0.08);
  color: #cdefff;
}

.status.info {
  border-color: rgba(111, 212, 255, 0.18);
}

.status.success {
  background: rgba(140, 230, 140, 0.12);
  border-color: rgba(140, 230, 140, 0.22);
  color: #d7ffd6;
}

.status.warning {
  background: rgba(255, 210, 123, 0.12);
  border-color: rgba(255, 210, 123, 0.22);
  color: #ffe3ad;
}

.status.error {
  background: rgba(255, 158, 158, 0.14);
  border-color: rgba(255, 158, 158, 0.22);
  color: #ffd6d6;
}

.hidden {
  display: none !important;
}

.maze-section {
  padding: 24px;
}

.maze-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto auto;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 20px;
}

.summary-card {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
}

.summary-text {
  margin: 8px 0 0;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.summary-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(120px, auto));
}

.summary-stats > div {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 6px;
}

.summary-stats span {
  font-size: 0.88rem;
  color: var(--muted);
}

.summary-stats strong {
  font-size: 1.14rem;
}

.maze-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 360px);
  gap: 22px;
}

.maze-board-panel {
  min-width: 0;
}

.maze-board {
  position: relative;
  min-height: 620px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(7, 14, 20, 0.24), rgba(7, 14, 20, 0.56)),
    var(--dungeon-image) center / cover no-repeat;
}

.maze-board canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.maze-sidebar {
  padding: 22px;
  border-radius: 22px;
  background: rgba(6, 12, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.maze-sidebar h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.progress-meter {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 18px;
}

.progress-value {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(111, 212, 255, 0.95), rgba(255, 211, 102, 0.98));
  transition: width 0.24s ease;
}

.stats-list {
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.stats-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.stats-list dt {
  color: var(--muted);
}

.stats-list dd {
  margin: 0;
  font-weight: 800;
}

.admin-shell {
  width: min(1240px, calc(100% - 32px));
}

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

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

.preview-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.background-preview {
  margin-top: 12px;
  aspect-ratio: 1 / 1;
  width: min(100%, 360px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(7, 14, 20, 0.14), rgba(7, 14, 20, 0.42)),
    var(--dungeon-image) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.live-preview {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border-radius: 24px;
}

.live-preview-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 14, 20, 0.35), rgba(7, 14, 20, 0.74)),
    var(--dungeon-image) center / cover no-repeat;
}

.live-preview-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 15%, rgba(111, 212, 255, 0.16), transparent 26%),
    radial-gradient(circle at 80% 85%, rgba(255, 210, 123, 0.14), transparent 24%);
}

.live-preview-content {
  position: relative;
  z-index: 1;
  padding: 34px;
  max-width: 760px;
}

.live-preview-content h2 {
  font-size: clamp(1.7rem, 2vw + 1rem, 2.5rem);
}

.live-preview-content p:last-child {
  color: var(--muted);
  line-height: 1.8;
}

@media (max-width: 980px) {
  .maze-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .maze-topbar {
    grid-template-columns: 1fr;
  }

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

  .admin-token-row {
    grid-template-columns: 1fr;
  }

  .button-stack.compact {
    align-self: stretch;
  }

  .maze-board {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .site-shell,
  .admin-shell {
    width: min(100% - 18px, 100%);
    padding-top: 18px;
    padding-bottom: 28px;
  }

  .hero,
  .form-panel,
  .maze-section,
  .admin-panel {
    padding: 18px;
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

  .maze-board {
    min-height: 420px;
  }
}
