:root {
  --bg: #0f0b1a;
  --bg-alt: #1a1330;
  --card: #221a3d;
  --gold: #d4af6a;
  --gold-soft: #e8cd9a;
  --text: #f3ecdd;
  --text-dim: #b8aecb;
  --danger: #e2795a;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 50% -10%, #2a1f4d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 32px 20px 40px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeIn .35s ease;
}
.view.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 시작 화면 */
.brand {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 36px;
}
.brand-glyph {
  font-size: 56px;
  filter: drop-shadow(0 0 18px rgba(212,175,106,.5));
}
.brand h1 {
  font-size: 30px;
  margin: 12px 0 6px;
  letter-spacing: 2px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { color: var(--text-dim); font-size: 14px; margin: 0; }

.hand-select {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 24px;
  border: 1px solid rgba(212,175,106,.15);
}
.hand-select-label {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}
.hand-select-buttons {
  display: flex;
  gap: 8px;
}
.hand-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: 12px;
  border: 1px solid rgba(212,175,106,.3);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
}
.hand-btn.selected {
  background: var(--gold);
  color: #241a0d;
  border-color: var(--gold);
  font-weight: 700;
}
.pin-input {
  width: 100%;
  max-width: 220px;
  margin: 4px auto 6px;
  display: block;
  text-align: center;
  font-size: 28px;
  letter-spacing: 20px;
  padding: 12px 0 12px 20px;
  border-radius: 12px;
  border: 1px solid rgba(212,175,106,.3);
  background: transparent;
  color: var(--text);
  font-family: inherit;
}
.pin-input:focus { outline: none; border-color: var(--gold); }
.pin-error {
  color: var(--danger);
  font-size: 12.5px;
  text-align: center;
  margin: 4px 0 0;
}

.hand-select-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #241a0d;
  border: none;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(212,175,106,.25);
}
.btn-primary:active { transform: scale(.98); }

.hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 14px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
}
/* 미리보기 */
.preview-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/4;
  background: #000;
  margin-top: 8px;
}
#preview-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.preview-controls .btn-ghost { flex: 1; }
.preview-controls .btn-primary { flex: 2; }

/* 로딩 */
#view-loading { align-items: center; justify-content: center; text-align: center; }
.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(212,175,106,.2);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.loading-sub { font-size: 13px; color: var(--text-dim); margin: 0; }

/* 결과 */
.result-header { text-align: center; margin-top: 8px; margin-bottom: 6px; }
.result-header h2 { margin: 0 0 6px; font-size: 22px; color: var(--gold-soft); }
.result-hand-tag { color: var(--text-dim); font-size: 13px; margin: 0; }

.quality-warning {
  background: rgba(226,121,90,.12);
  border: 1px solid rgba(226,121,90,.4);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin: 14px 0;
}

.result-summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid rgba(212,175,106,.2);
}

.result-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-card {
  background: var(--bg-alt);
  border-radius: 14px;
  padding: 14px 16px;
  border-left: 3px solid var(--gold);
}
.section-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--gold-soft);
}
.section-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
}

.disclaimer {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
  margin: 20px 0 18px;
  line-height: 1.6;
}

#btn-restart { margin-top: auto; }

.error-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #2a0f08;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
