:root {
  --rose: #f6c9cc;
  --rose-deep: #e79aa6;
  --serenity: #92a8d1;
  --serenity-deep: #6a83b5;
  --plum: #2a2033;
  --plum-soft: #4a3f56;
  --cream: #fffaf7;
  --cream-2: #fdf1ee;
  --gold: #d9b26a;
  --ink: #2b2333;
  --muted: #7a6b84;
  --line: rgba(42, 32, 51, 0.1);
  --shadow: 0 18px 44px -22px rgba(42, 32, 51, 0.45);
  --radius: 20px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 8% -8%, #fde7e9 0%, rgba(253, 231, 233, 0) 62%),
    radial-gradient(900px 560px at 96% 4%, #e3eaf8 0%, rgba(227, 234, 248, 0) 60%),
    linear-gradient(180deg, var(--cream) 0%, #fbf6f8 48%, #f4f5fb 100%);
  background-attachment: fixed;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0; }

button { font-family: inherit; cursor: pointer; }

a { color: var(--serenity-deep); }

.wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255, 250, 247, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 22px; letter-spacing: 0.06em; }
.brand em { font-style: normal; color: var(--muted); font-size: 15px; letter-spacing: 0.22em; text-transform: uppercase; }
.brand .diamond {
  width: 22px; height: 22px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--rose), var(--serenity));
  border-radius: 4px;
  box-shadow: 0 0 0 4px rgba(246, 201, 204, 0.25);
}

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav button {
  border: 0; background: transparent; padding: 9px 15px; border-radius: 999px;
  font-size: 14px; color: var(--plum-soft); letter-spacing: 0.03em; transition: background .18s, color .18s;
}
.nav button:hover { background: rgba(146, 168, 209, 0.14); }
.nav button.active { background: var(--plum); color: #fff; }

.user-area { display: flex; align-items: center; gap: 12px; }

.coin-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 999px;
  background: linear-gradient(135deg, #fff3d9, #f7e2ba);
  border: 1px solid rgba(217, 178, 106, 0.5);
  font-weight: 650; font-size: 14px; color: #6b5220;
  white-space: nowrap;
}
.coin-dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 32% 30%, #ffe9a8, #d9a93f); box-shadow: inset 0 0 0 1px rgba(140, 100, 20, 0.35); }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: var(--shadow); }
.avatar-fallback {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--rose), var(--serenity)); color: #fff; font-size: 13px; font-weight: 700;
}

.btn {
  border: 0; border-radius: 999px; padding: 11px 22px; font-size: 14px; font-weight: 600;
  background: var(--plum); color: #fff; transition: transform .16s, box-shadow .16s, opacity .16s;
  letter-spacing: 0.02em;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -16px rgba(42, 32, 51, 0.8); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--plum); border: 1px solid rgba(42, 32, 51, 0.2); }
.btn.ghost:hover { background: rgba(42, 32, 51, 0.05); }
.btn.rose { background: linear-gradient(135deg, #f19aa6, #e07a8c); }
.btn.serenity { background: linear-gradient(135deg, #8fa5d0, #6d87b8); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { background: transparent; border: 1px solid rgba(190, 80, 100, 0.35); color: #a83f57; }

/* ---------------------------------------------------------------- layout */

main { padding: 34px 0 80px; }

.view { display: none; }
.view.active { display: block; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 36px); }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 62ch; line-height: 1.6; }

.card-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 30px);
  backdrop-filter: blur(8px);
}

/* ---------------------------------------------------------------- auth */

.auth-screen { display: grid; place-items: center; min-height: 62vh; }
.auth-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #fff;
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 34px;
  backdrop-filter: blur(10px);
}
.auth-card h1 { font-size: 32px; line-height: 1.15; }
.auth-card .tagline { color: var(--muted); font-size: 14px; line-height: 1.65; margin: 10px 0 24px; }
.auth-tabs { display: flex; gap: 6px; background: rgba(42, 32, 51, 0.06); padding: 5px; border-radius: 999px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-tabs button.active { background: #fff; color: var(--plum); box-shadow: 0 6px 16px -12px rgba(42, 32, 51, 0.7); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(42, 32, 51, 0.16);
  background: #fff; font-size: 15px; font-family: inherit; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--serenity); box-shadow: 0 0 0 3px rgba(146, 168, 209, 0.22); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; margin: 20px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border-radius: 12px; border: 1px solid rgba(42, 32, 51, 0.16); background: #fff;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.google-btn:hover { background: #fdfbfa; }
.google-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.google-btn svg { width: 18px; height: 18px; }

.auth-note { margin-top: 18px; font-size: 12px; line-height: 1.6; color: var(--muted); background: rgba(146, 168, 209, 0.1); padding: 12px 14px; border-radius: 12px; }

/* ---------------------------------------------------------------- study */

.study-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 22px; }
@media (max-width: 900px) { .study-grid { grid-template-columns: 1fr; } }

.timer-panel { display: grid; place-items: center; gap: 22px; text-align: center; padding: 30px 20px 26px; }
.mode-switch { display: inline-flex; gap: 4px; background: rgba(42, 32, 51, 0.06); padding: 5px; border-radius: 999px; }
.mode-switch button { border: 0; background: transparent; padding: 8px 20px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mode-switch button.active { background: #fff; color: var(--plum); box-shadow: 0 6px 16px -12px rgba(42, 32, 51, 0.7); }

.ring-wrap { position: relative; width: min(320px, 74vw); aspect-ratio: 1; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: rgba(42, 32, 51, 0.07); }
.ring-progress { stroke: url(#ringGradient); stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; }
.ring-time { font-family: var(--serif); font-size: clamp(44px, 9vw, 62px); line-height: 1; font-variant-numeric: tabular-nums; }
.ring-label { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.ring-sub { font-size: 13px; color: var(--plum-soft); }

.timer-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.timer-foot { font-size: 12.5px; color: var(--muted); max-width: 42ch; line-height: 1.6; }

.stat-list { display: grid; gap: 14px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(253, 241, 238, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.9);
}
.stat .icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: rgba(146, 168, 209, 0.16); flex: none; }
.stat .k { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--serif); font-size: 24px; line-height: 1.2; }
.stat small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.earn-note { margin-top: 16px; font-size: 12.5px; line-height: 1.7; color: var(--plum-soft); background: rgba(217, 178, 106, 0.12); border: 1px solid rgba(217, 178, 106, 0.3); border-radius: 14px; padding: 14px 16px; }

/* ---------------------------------------------------------------- collection */

.collect-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.progress-shell { flex: 1; min-width: 220px; }
.progress-bar { height: 10px; border-radius: 999px; background: rgba(42, 32, 51, 0.08); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--rose-deep), var(--serenity)); transition: width .5s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; letter-spacing: 0.06em; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 16px; margin-top: 24px; }
.pc {
  position: relative; border-radius: 16px; overflow: hidden; cursor: pointer;
  background: #2b2334; box-shadow: 0 12px 28px -20px rgba(42, 32, 51, 0.9);
  transition: transform .2s ease, box-shadow .2s ease;
  aspect-ratio: 400 / 560;
}
.pc:hover { transform: translateY(-5px) scale(1.015); box-shadow: 0 22px 40px -22px rgba(42, 32, 51, 0.75); }
.pc img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc .pc-meta {
  position: absolute; inset: auto 0 0 0; padding: 26px 10px 10px; color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(24, 16, 30, 0.85));
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em;
}
.pc .pc-meta span { display: block; font-weight: 400; font-size: 10.5px; opacity: 0.75; letter-spacing: 0.1em; text-transform: uppercase; }
.pc.locked .pc-meta { background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(24, 16, 30, 0.55)); }
.pc .rarity-chip {
  position: absolute; top: 9px; right: 9px; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.88); color: #4a3f56; font-weight: 700;
}
.pc .rarity-chip.Legendary { background: linear-gradient(135deg, #f8e3ab, #d9b26a); color: #5c4410; }
.pc.collected::after {
  content: ""; position: absolute; inset: 0; border-radius: 16px; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

/* ---------------------------------------------------------------- packs */

.pack-stage { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 26px; align-items: start; }
@media (max-width: 880px) { .pack-stage { grid-template-columns: 1fr; } }

.pack-visual {
  position: relative; border-radius: 22px; padding: 30px; color: #fff; overflow: hidden;
  background: linear-gradient(150deg, #3b2f47 0%, #5a4a6b 45%, #7a8db4 100%);
  box-shadow: var(--shadow); min-height: 300px; display: grid; place-content: center; gap: 14px; text-align: center;
}
.pack-visual::before {
  content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, rgba(255,255,255,0.14), transparent 30%, rgba(255,255,255,0.1) 60%, transparent 80%);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pack-visual > * { position: relative; }
.pack-visual h3 { font-size: 26px; }
.pack-visual .pack-diamond { width: 74px; height: 74px; margin: 6px auto; transform: rotate(45deg); border-radius: 12px; background: linear-gradient(135deg, var(--rose), var(--serenity)); box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.08); }
.pack-visual p { font-size: 13px; opacity: 0.82; line-height: 1.6; margin: 0; }

.reveal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
@media (max-width: 560px) { .reveal-grid { grid-template-columns: repeat(2, 1fr); } }
.reveal-grid .pc { animation: pop .5s cubic-bezier(.2, .8, .3, 1.2) both; }
.reveal-grid .pc:nth-child(2) { animation-delay: .12s; }
.reveal-grid .pc:nth-child(3) { animation-delay: .24s; }
@keyframes pop { from { opacity: 0; transform: scale(0.82) rotate(-3deg); } to { opacity: 1; transform: none; } }

.pack-log { margin-top: 20px; display: grid; gap: 8px; max-height: 220px; overflow: auto; }
.pack-log-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); padding: 9px 12px; border-radius: 10px; background: rgba(42, 32, 51, 0.04); }

/* ---------------------------------------------------------------- studio */

.studio-lock { max-width: 460px; margin: 0 auto; text-align: center; }
.studio-lock .lock-icon { font-size: 40px; }
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-top: 22px; }
.studio-item { background: rgba(255,255,255,0.9); border-radius: 16px; padding: 14px; border: 1px solid var(--line); display: grid; gap: 10px; }
.studio-item .thumb { border-radius: 12px; overflow: hidden; aspect-ratio: 400/560; background: #efe7f2; }
.studio-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio-item .row { display: flex; gap: 6px; }
.studio-item input[type="text"] {
  width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid rgba(42,32,51,0.15); font-size: 13px; font-family: inherit;
}
.studio-item select { padding: 8px 10px; border-radius: 9px; border: 1px solid rgba(42,32,51,0.15); font-size: 12px; font-family: inherit; background: #fff; }
.studio-item .upload-label {
  display: block; text-align: center; padding: 9px; border-radius: 9px; font-size: 12.5px; font-weight: 600;
  background: rgba(146, 168, 209, 0.16); color: var(--serenity-deep); cursor: pointer;
}
.studio-item .upload-label:hover { background: rgba(146, 168, 209, 0.26); }
.studio-item input[type="file"] { display: none; }
.studio-note { font-size: 12.5px; line-height: 1.7; color: var(--muted); background: rgba(146,168,209,0.1); padding: 14px 16px; border-radius: 12px; margin-top: 16px; }

/* ---------------------------------------------------------------- settings */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 820px) { .settings-grid { grid-template-columns: 1fr; } }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 1px solid rgba(42, 32, 51, 0.16); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 12.5px; color: var(--plum-soft); }
.chip:hover { border-color: var(--serenity); color: var(--serenity-deep); }

/* ---------------------------------------------------------------- modal + toast */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px;
  background: rgba(30, 22, 38, 0.62); backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(760px, 100%); max-height: 88vh; overflow: auto; border-radius: 22px; background: var(--cream);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.6); display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 0;
}
@media (max-width: 700px) { .modal { grid-template-columns: 1fr; } }
.modal .modal-art { background: #241c2c; }
.modal .modal-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal .modal-body { padding: 26px; display: grid; align-content: start; gap: 10px; }
.modal .modal-body h3 { font-size: 30px; }
.modal .modal-body .sub { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }
.modal .kv { display: flex; justify-content: space-between; font-size: 13px; padding: 9px 0; border-bottom: 1px dashed var(--line); color: var(--plum-soft); }
.modal .close-x { justify-self: end; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: grid; gap: 10px; }
.toast {
  min-width: 240px; max-width: 340px; padding: 13px 16px; border-radius: 13px; font-size: 13.5px; line-height: 1.5;
  background: var(--plum); color: #fff; box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  animation: toastIn .3s ease both;
}
.toast.good { background: linear-gradient(135deg, #4d7a63, #3d6350); }
.toast.bad { background: linear-gradient(135deg, #9c3f52, #7d3040); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

.skeleton { border-radius: 16px; background: linear-gradient(90deg, rgba(42,32,51,0.06), rgba(42,32,51,0.02), rgba(42,32,51,0.06)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

[hidden] { display: none !important; }

.footer-note { text-align: center; font-size: 11.5px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 44px; }
