﻿:root {
  --bg: #fbfcff;
  --bg-warm: #fff7e8;
  --surface: #ffffff;
  --surface-soft: #f4f8ff;
  --ink: #142033;
  --muted: #657287;
  --line: #dfe7f1;
  --coral: #ff6b5f;
  --mint: #22c7a9;
  --sky: #4f9cf9;
  --violet: #8a6cff;
  --sun: #ffd166;
  --lime: #a9e75b;
  --danger: #d8463b;
  --shadow: 0 18px 55px rgba(28, 43, 68, .12);
  --shadow-soft: 0 10px 28px rgba(28, 43, 68, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, var(--bg-warm) 0, #f4fbff 31%, var(--bg) 68%, #ffffff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid rgba(223, 231, 241, .86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
  font-size: 1.08rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--coral), var(--violet));
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 107, 95, .25);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--muted);
  font-size: .94rem;
  font-weight: 760;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

h1, h2, h3 { margin: 0; line-height: 1.06; letter-spacing: 0; }
h1 { max-width: 780px; font-size: clamp(3rem, 7vw, 5.9rem); }
h2 { font-size: clamp(1.65rem, 3.2vw, 2.65rem); }
h3 { font-size: 1.08rem; }
p { margin: 0; }

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(34, 199, 169, .26);
  border-radius: var(--radius);
  padding: 4px 9px;
  background: rgba(34, 199, 169, .1);
  color: #087c6d;
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.lead {
  max-width: 660px;
  color: var(--muted);
  font-size: 1.06rem;
}

.page-hero,
.create-hero,
.profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr);
  gap: clamp(20px, 4vw, 40px);
  align-items: stretch;
  margin-bottom: 34px;
}

.hero-text,
.create-copy,
.profile-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 360px;
}

.hero-actions,
.toolbar,
.row-actions,
.game-actions,
.choice-actions,
.mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 15px;
  background: var(--ink);
  color: #fff;
  font-weight: 820;
  text-decoration: none;
  box-shadow: 0 8px 16px rgba(20, 32, 51, .12);
}

.btn:hover { transform: translateY(-1px); }
.btn.secondary { border-color: var(--line); background: #fff; color: var(--ink); box-shadow: var(--shadow-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { border-color: var(--danger); background: var(--danger); }
.btn.compact { min-height: 36px; padding: 7px 10px; font-size: .88rem; }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }

.hero-preview,
.mini-stat,
.creation-preview,
.profile-card,
.panel,
.list-card,
.mode-card,
.stat,
.summary-row,
.rank-row,
.duel-card,
.auth-card,
.empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-soft);
}

.hero-preview {
  min-height: 360px;
  display: grid;
  gap: 14px;
  align-content: center;
  padding: clamp(16px, 3vw, 26px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, .24), rgba(79, 156, 249, .16)),
    #ffffff;
}

.preview-topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.preview-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
}

.preview-card.coral { background: linear-gradient(135deg, var(--coral), #ff9470); }
.preview-card.mint { background: linear-gradient(135deg, var(--mint), #58d68d); }
.preview-card.sky { background: linear-gradient(135deg, var(--sky), var(--violet)); }
.preview-card strong { font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.05; }
.preview-card span { color: rgba(255,255,255,.82); font-weight: 720; }

.vs-badge {
  display: grid;
  width: 52px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.preview-list {
  display: grid;
  gap: 8px;
}

.preview-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: #fff;
}

.preview-rank,
.rank-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.preview-meter {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint));
}

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

.mini-stat,
.stat {
  padding: 16px;
}

.mini-stat strong,
.stat strong {
  display: block;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1;
}

.mini-stat span,
.stat span { color: var(--muted); font-weight: 680; }

.mode-grid,
.grid,
.list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.mode-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  overflow: hidden;
}

.mode-card .mode-label {
  width: fit-content;
  min-height: 28px;
  border-radius: var(--radius);
  padding: 4px 9px;
  color: #fff;
  font-size: .78rem;
  font-weight: 850;
}

.mode-card.coral .mode-label { background: var(--coral); }
.mode-card.mint .mode-label { background: var(--mint); }
.mode-card.sky .mode-label { background: var(--sky); }
.mode-card p { margin: 10px 0 18px; color: var(--muted); }

.section { margin-top: 36px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.section-head p { max-width: 650px; margin-top: 8px; color: var(--muted); }

.panel { padding: clamp(16px, 3vw, 22px); }
.panel.soft { background: linear-gradient(135deg, #ffffff, var(--surface-soft)); }

.quick-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: linear-gradient(135deg, rgba(255, 209, 102, .22), rgba(34, 199, 169, .15)), #fff;
}
.quick-create p { color: var(--muted); margin-top: 6px; }

.list-card {
  display: flex;
  min-height: 292px;
  flex-direction: column;
  overflow: hidden;
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 116px;
  background: #edf3fb;
}
.thumb-strip img { width: 100%; height: 116px; object-fit: cover; }

.list-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px;
}
.list-body p { margin: 9px 0 16px; color: var(--muted); font-size: .94rem; }
.list-body .row-actions { margin-top: auto; }

.meta-line { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 8px;
  background: #eef3fa;
  color: #42506a;
  font-size: .78rem;
  font-weight: 820;
}
.badge.official { background: #fff0d1; color: #865900; }
.badge.community { background: #ddf9f3; color: #087c6d; }
.badge.ai { background: #efe9ff; color: #6446c7; }

.create-hero { margin-bottom: 22px; }
.creation-preview { padding: 18px; background: #fff; }
.step-list { display: grid; gap: 10px; }
.step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}
.step span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 900;
}
.step strong { display: block; }
.step p { color: var(--muted); font-size: .92rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label, .check { color: #334155; font-size: .9rem; font-weight: 820; }
.field input, .field textarea, .field select, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus, select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, .15);
}
.field textarea { min-height: 118px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--mint); }

.prompt-panel {
  display: grid;
  gap: 16px;
}
.prompt-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.status-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}
.status-tile strong { display: block; }
.status-tile span { color: var(--muted); font-size: .9rem; }

.notice {
  border: 1px solid #ffe2a8;
  border-left: 5px solid var(--sun);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fff9e8;
  color: #6b5524;
}
.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  border-style: dashed;
  box-shadow: none;
}

.editor-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}
.editor-header p { color: var(--muted); margin-top: 6px; }
.editor-actions { justify-content: flex-end; }
.table-wrap { overflow-x: auto; }
.editor-table, .data-table { width: 100%; border-collapse: collapse; }
.editor-table th, .editor-table td, .data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}
.editor-table th, .data-table th {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  text-transform: uppercase;
}
.editor-table input, .editor-table textarea {
  width: 100%;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
}
.editor-table textarea { min-height: 70px; resize: vertical; }

.item-img {
  width: 72px;
  height: 56px;
  border-radius: var(--radius);
  object-fit: cover;
  background: #edf3fb;
}

.table-toolbar,
.game-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.rank-list, .summary { display: grid; gap: 10px; }
.rank-row, .summary-row {
  display: grid;
  grid-template-columns: 42px 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}
.rank-row[draggable="true"] { cursor: grab; }
.rank-row.dragging { opacity: .45; }
.rank-row div, .summary-row div { min-width: 0; }
.rank-row div div, .summary-row div div { color: var(--muted); }

.duel-layout { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }
.duel-card { overflow: hidden; }
.duel-card button {
  display: grid;
  grid-template-rows: 230px auto;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.duel-card img { width: 100%; height: 230px; object-fit: cover; }
.duel-copy { display: grid; gap: 8px; padding: 16px; }
.duel-copy p { color: var(--muted); }
.vs-pill {
  display: grid;
  width: 54px;
  align-self: center;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-weight: 950;
  box-shadow: var(--shadow-soft);
}

.profile-card { padding: 20px; background: linear-gradient(135deg, rgba(138,108,255,.13), rgba(34,199,169,.13)), #fff; }
.profile-avatar {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--sky), var(--violet));
  color: #fff;
  font-size: 2rem;
  font-weight: 950;
}
.profile-card h2 { margin-top: 14px; }
.profile-card p { margin-top: 8px; color: var(--muted); }
.profile-meta { display: grid; gap: 8px; margin-top: 18px; }
.profile-meta span { color: var(--muted); }

.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.auth-card { display: grid; align-content: start; gap: 10px; padding: 16px; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; }
.auth-status { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.auth-status p { margin-top: 6px; color: var(--muted); }

.source-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.source-list a { text-decoration: none; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(18px);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 940px) {
  .page-hero, .create-hero, .profile-hero, .duel-layout { grid-template-columns: 1fr; }
  .hero-text, .create-copy, .profile-copy { min-height: auto; }
  .mode-grid, .grid, .list-grid, .metrics, .stats, .form-grid, .prompt-status, .auth-grid { grid-template-columns: 1fr; }
  .table-toolbar, .game-toolbar { grid-template-columns: 1fr; }
  .quick-create { grid-template-columns: 1fr; }
  .vs-pill { width: 100%; height: 42px; aspect-ratio: auto; border-radius: var(--radius); }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; width: 100%; }
  .nav a { flex: 1 1 auto; justify-content: center; }
  .app { width: min(100% - 22px, 1180px); padding-top: 22px; }
  h1 { font-size: clamp(2.6rem, 16vw, 4rem); }
  .preview-topline { grid-template-columns: 1fr; }
  .vs-badge { width: 100%; height: 38px; aspect-ratio: auto; border-radius: var(--radius); }
  .section-head, .editor-header, .auth-status { align-items: flex-start; flex-direction: column; display: flex; }
  .rank-row, .summary-row { grid-template-columns: 38px 58px minmax(0, 1fr); }
  .rank-row .row-actions, .summary-row .badge { grid-column: 1 / -1; }
  .duel-card button { grid-template-rows: 190px auto; }
  .duel-card img { height: 190px; }
}