:root {
  --bg: #101214;
  --panel: #14171b;
  --panel-2: #1a1f26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #b9c1cf;
  --track: #20242b;
  --blue: #4f8cff;
  --green: #72d6a3;
  --amber: #ffcf76;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans KR", sans-serif;
}

.topbar {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 20px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar-left,
.topbar-right,
.footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.brand-pill,
.soft-pill {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f1216;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}

.brand-pill {
  background: #0d1014;
}

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

.level-select {
  min-width: 140px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: #0f1216;
  color: var(--text);
  padding: 0 38px 0 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, #8f9aab 50%),
    linear-gradient(135deg, #8f9aab 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 12px) 17px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.level-select:disabled {
  color: var(--muted);
  cursor: wait;
}

.team-field input {
  min-width: 180px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.button {
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 700;
}

.button-dark {
  background: white;
  color: #101214;
}

.button-light {
  background: #0f1216;
  color: var(--text);
  border: 1px solid var(--border);
}

.button-validate {
  background: white;
  color: #101214;
  min-width: 98px;
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page {
  padding: 28px 20px 40px;
}

.game-card {
  max-width: 980px;
  margin: 0 auto;
  background: transparent;
}

.level-tag {
  width: fit-content;
  margin: 0 auto 20px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #11161d;
  border: 1px solid var(--border);
  color: #d7deea;
  font-size: 13px;
  font-weight: 700;
}

.goal-title {
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.45;
  font-weight: 700;
}

.goal-subtitle {
  max-width: 720px;
  margin: 14px auto 0;
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}

.progress-block {
  max-width: 860px;
  margin: 34px auto 0;
}

.level-illustration {
  max-width: 860px;
  margin: 28px auto 0;
}

.level-illustration-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top, rgba(255, 189, 112, 0.16), transparent 38%),
    linear-gradient(180deg, #171a21 0%, #0d1014 100%);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 180ms ease;
}

.reply-label {
  max-width: 860px;
  margin: 26px auto 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.guardian-prompt,
.guardian-reply,
.status-message {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

.guardian-prompt {
  margin-top: 22px;
  font-size: 22px;
  font-weight: 600;
}

.prompt-form {
  max-width: 860px;
  margin: 18px auto 0;
  position: relative;
}

.prompt-form textarea,
.validate-row input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #090b0f;
  color: var(--text);
  font: inherit;
  outline: none;
}

.prompt-form textarea {
  min-height: 132px;
  padding: 18px 58px 18px 18px;
  resize: vertical;
  line-height: 1.65;
}

.icon-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #1a1f26;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: white;
  font-weight: 700;
}

.guardian-reply {
  min-height: 32px;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.55;
}

.validate-row {
  max-width: 860px;
  margin: 24px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.validate-row input {
  height: 48px;
  padding: 0 14px;
}

.status-message {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.footer-actions {
  max-width: 860px;
  margin: 18px auto 0;
  justify-content: center;
}

.text-button {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.74);
  backdrop-filter: blur(8px);
}

.result-modal-card {
  min-width: min(320px, 100%);
  padding: 28px 24px 22px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, #171b22 0%, #0d1014 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.result-modal-card strong {
  display: block;
  margin-bottom: 18px;
  font-size: 28px;
  line-height: 1.3;
}

.result-modal-copy {
  margin: -2px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.result-modal-image {
  display: block;
  width: min(100%, 560px);
  margin: 0 auto 20px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #151922 0%, #0c1015 100%);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.api-key-modal-card {
  max-width: 520px;
  text-align: left;
}

.api-key-copy {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.api-key-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f1216;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.api-key-link:hover {
  border-color: rgba(79, 140, 255, 0.5);
}

.api-key-input {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #090b0f;
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  outline: none;
}

.api-key-status {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.api-key-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.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;
}

body[data-accent="ember"] .level-tag {
  background: rgba(234, 67, 53, 0.14);
}

body[data-accent="gold"] .level-tag {
  background: rgba(251, 188, 4, 0.14);
}

body[data-accent="mint"] .level-tag {
  background: rgba(52, 168, 83, 0.14);
}

body[data-accent="sky"] .level-tag {
  background: rgba(66, 133, 244, 0.18);
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-right {
    justify-content: stretch;
  }

  .team-field,
  .team-field input,
  .level-select,
  .button {
    width: 100%;
  }

  .guardian-prompt,
  .guardian-reply {
    font-size: 18px;
  }

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