:root {
  --bg: #0c1016;
  --bg-elevated: #111826;
  --bg-panel: #0f1722;
  --bg-soft: rgba(148, 163, 184, 0.08);
  --line: rgba(148, 163, 184, 0.18);
  --text: #ecf2ff;
  --text-muted: #9aa8c7;
  --primary: #4fd1c5;
  --primary-strong: #2ea89d;
  --danger: #f97373;
  --danger-strong: #dc4d4d;
  --warning: #f5c15d;
  --success: #4ade80;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans KR", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(79, 209, 197, 0.14), transparent 30%),
    linear-gradient(180deg, #0a0f15 0%, #0f1723 50%, #0a1017 100%);
}

img {
  display: block;
  max-width: 100%;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 20px;
  background: rgba(10, 16, 24, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(79, 209, 197, 0.22), rgba(249, 115, 115, 0.22));
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}

.site-header__title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.site-header__subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-panel {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.user-panel__summary {
  text-align: right;
}

.user-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card {
  background: linear-gradient(180deg, rgba(17, 24, 38, 0.95), rgba(11, 17, 27, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 32px;
  margin-bottom: 24px;
}

.eyebrow,
.section-header__eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1,
.section-header h2,
.page-title h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.1;
}

.hero__description,
.page-title p,
.mini-card p,
.battle-item__story,
.empty-state p,
.character-card p,
.helper-text {
  color: var(--text-muted);
}

.hero__actions,
.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #041316;
  font-weight: 700;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease,
    border-color 0.18s ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(79, 209, 197, 0.22);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.button--secondary {
  background: linear-gradient(135deg, #d9e2f2, #92a5c6);
  color: #101827;
}

.button--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.button--nav {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  color: var(--text-muted);
  border-color: rgba(148, 163, 184, 0.14);
}

.button--nav.is-active {
  color: var(--text);
  background: rgba(79, 209, 197, 0.12);
  border-color: rgba(79, 209, 197, 0.28);
}

.button--danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-strong));
  color: white;
}

.text-link {
  color: var(--primary);
  font-weight: 600;
}

.hero__panel,
.intro-grid,
.stats-grid,
.grid,
.character-grid {
  display: grid;
  gap: 16px;
}

.hero__panel {
  align-content: start;
}

.stat-box,
.mini-card,
.status-banner,
.battle-item,
.character-card,
.empty-state,
.form-panel,
.story-panel {
  background: var(--bg-soft);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-md);
}

.stat-box {
  padding: 18px;
}

.stat-box__label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.stat-box strong {
  font-size: 1.7rem;
  font-family: "Space Grotesk", sans-serif;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
}

.content-card,
.page-card {
  padding: 24px;
}

.section-header,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.intro-grid,
.stats-grid,
.character-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-card,
.battle-item,
.character-card,
.empty-state,
.form-panel,
.story-panel {
  padding: 18px;
}

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

.battle-item__meta,
.character-card__meta,
.character-card__footer,
.battle-item__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(79, 209, 197, 0.12);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 600;
}

.pill--warning {
  color: #f8d277;
  background: rgba(245, 193, 93, 0.12);
}

.pill--danger {
  color: #ff9b9b;
  background: rgba(249, 115, 115, 0.14);
}

.status-banner {
  padding: 14px 16px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.status-banner--info {
  color: #c7d6f5;
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.1);
}

.status-banner--success {
  color: #cbffd5;
  border-color: rgba(74, 222, 128, 0.28);
  background: rgba(74, 222, 128, 0.1);
}

.status-banner--error {
  color: #ffd1d1;
  border-color: rgba(249, 115, 115, 0.3);
  background: rgba(249, 115, 115, 0.1);
}

.global-error {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: min(420px, calc(100% - 32px));
  padding: 14px 16px;
  border: 1px solid rgba(249, 115, 115, 0.32);
  border-radius: var(--radius-sm);
  background: rgba(26, 9, 9, 0.94);
  color: #ffd4d4;
  box-shadow: var(--shadow);
}

.page-title {
  margin-bottom: 24px;
}

.page-title p {
  margin-top: 10px;
  max-width: 720px;
}

.form-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 24px;
}

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

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  font-weight: 600;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(9, 14, 22, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: rgba(79, 209, 197, 0.7);
  box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.14);
}

.form-field textarea {
  min-height: 140px;
  resize: vertical;
}

.form-field textarea[name="skills"] {
  min-height: 100px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.preview-box {
  overflow: hidden;
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: linear-gradient(135deg, rgba(79, 209, 197, 0.18), rgba(148, 163, 184, 0.12));
}

.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.helper-list {
  padding-left: 18px;
  color: var(--text-muted);
}

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

.character-card__image {
  overflow: hidden;
  margin-bottom: 14px;
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  background: rgba(79, 209, 197, 0.08);
}

.character-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-card h3,
.battle-item h3,
.mini-card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.character-card__footer,
.battle-item__footer {
  margin-top: 14px;
  justify-content: space-between;
}

.metric {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.story-toggle {
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  font-weight: 700;
}

.battle-item__story {
  margin: 14px 0 0;
  line-height: 1.7;
  white-space: pre-wrap;
}

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

.meta-box {
  padding: 12px;
  background: rgba(7, 12, 18, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
}

.meta-box strong {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
}

.empty-state {
  text-align: center;
}

.empty-state h3 {
  margin-top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hero,
  .main-grid,
  .form-layout {
    grid-template-columns: 1fr;
  }

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

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

  .hero,
  .content-card,
  .page-card {
    padding: 20px;
  }

  .section-header,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav,
  .hero__actions,
  .page-nav {
    flex-direction: column;
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .two-column-meta {
    grid-template-columns: 1fr;
  }

  .user-panel,
  .user-panel__summary {
    width: 100%;
    justify-items: stretch;
    text-align: left;
  }

  .user-panel__actions {
    flex-direction: column;
  }
}
