:root {
  color-scheme: light;
  --bg: #fff3f7;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --surface-soft: #fff0f5;
  --ink: #171217;
  --muted: #7f6874;
  --primary: #f25583;
  --primary-strong: #db2f68;
  --primary-soft: #ffdbe6;
  --accent: #ff9cb8;
  --success: #39b96d;
  --success-soft: #dff7e5;
  --warning: #f0a532;
  --warning-soft: #fff0d8;
  --danger: #d64768;
  --line: #f3d8df;
  --shadow: 0 18px 46px rgba(180, 79, 111, 0.14);
  --soft-shadow: 0 9px 24px rgba(132, 62, 86, 0.08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #fff7fa;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 207, 220, 0.7), transparent 24rem),
    radial-gradient(circle at 86% 76%, rgba(255, 214, 226, 0.65), transparent 22rem),
    #fff8fa;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  position: relative;
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 18px calc(92px + var(--safe-bottom));
  overflow: visible;
  background:
    radial-gradient(ellipse 17px 11px at 24px 40px, rgba(242, 85, 131, 0.08) 0 58%, transparent 61%),
    radial-gradient(ellipse 12px 9px at 70px 20px, rgba(242, 85, 131, 0.07) 0 56%, transparent 60%),
    radial-gradient(ellipse 19px 12px at 98% 94%, rgba(242, 85, 131, 0.09) 0 58%, transparent 61%),
    radial-gradient(ellipse 13px 9px at 92% 91%, rgba(242, 85, 131, 0.08) 0 58%, transparent 61%),
    linear-gradient(165deg, #fffafa 0%, #fff7f9 46%, #fff1f6 100%);
}

.app-shell::before {
  display: none;
  content: none;
}

.app-shell::after {
  display: none;
  content: none;
}

.login-shell {
  min-height: calc(100vh - 128px);
  display: grid;
  align-content: center;
  max-width: 460px;
  margin: 0 auto;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid rgba(242, 85, 131, 0.18);
  border-radius: 22px;
  background:
    radial-gradient(circle at 86% 12%, rgba(255, 255, 255, 0.94) 0 14px, transparent 15px),
    linear-gradient(135deg, #fff, #ffeaf1 62%, #ffd9e5);
  box-shadow: var(--shadow);
}

.hero-card::before,
.pattern-band {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.58;
  background-image:
    radial-gradient(ellipse 15px 10px at 22px 26px, rgba(242, 85, 131, 0.18) 0 56%, transparent 60%),
    radial-gradient(ellipse 10px 8px at 66px 15px, rgba(224, 57, 106, 0.14) 0 56%, transparent 60%),
    radial-gradient(ellipse 16px 10px at 112px 55px, rgba(242, 85, 131, 0.15) 0 58%, transparent 61%),
    radial-gradient(ellipse 11px 8px at 40px 82px, rgba(224, 57, 106, 0.13) 0 56%, transparent 60%);
  background-size: 132px 96px;
}

.hero-card > * {
  position: relative;
}

.brand-logo {
  margin: 12px 0 4px;
  color: var(--primary);
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 3.05rem;
  line-height: 0.9;
  font-weight: 500;
}

.brand-heart {
  width: 132px;
  height: 118px;
  margin: 26px auto 18px;
  position: relative;
  filter: drop-shadow(0 14px 18px rgba(219, 47, 104, 0.18));
}

.brand-heart::before {
  content: "";
  position: absolute;
  inset: 14px 18px 8px;
  border: 3px solid #e29142;
  border-radius: 50% 50% 46% 46%;
  transform: rotate(45deg);
  background:
    radial-gradient(ellipse 13px 9px at 25px 22px, rgba(242, 85, 131, 0.42) 0 58%, transparent 61%),
    radial-gradient(ellipse 10px 8px at 55px 44px, rgba(242, 85, 131, 0.38) 0 58%, transparent 61%),
    radial-gradient(ellipse 16px 10px at 68px 18px, rgba(242, 85, 131, 0.35) 0 58%, transparent 61%),
    radial-gradient(ellipse 12px 8px at 35px 65px, rgba(242, 85, 131, 0.34) 0 58%, transparent 61%),
    #ffd6e2;
}

.brand-heart::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 2px;
  width: 40px;
  height: 58px;
  border: 3px solid #e29142;
  border-left: 0;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  transform: rotate(33deg);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-strong);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 2.6rem;
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.38rem;
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

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

.small {
  font-size: 0.78rem;
}

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

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

.wrap {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.card {
  border: 1px solid rgba(230, 185, 198, 0.82);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(12px);
}

.pad {
  padding: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  margin: -18px -18px 18px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(240, 208, 217, 0.74);
  background: rgba(255, 250, 251, 0.78);
  backdrop-filter: blur(18px);
}

.topbar-title {
  display: grid;
  gap: 1px;
}

.topbar-title span {
  display: none;
}

.topbar-title strong {
  font-size: 1.08rem;
}

.icon-button,
.ghost-button,
.primary-button,
.soft-button,
.danger-button {
  min-height: 42px;
  border-radius: 999px;
  font-weight: 850;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.icon-button:active,
.ghost-button:active,
.primary-button:active,
.soft-button:active,
.danger-button:active,
.answer-button:active {
  transform: scale(0.98);
}

.icon-button {
  min-width: 42px;
  padding: 0 12px;
  color: var(--primary-strong);
  background: #fff;
  box-shadow: 0 8px 16px rgba(128, 55, 91, 0.08);
}

.primary-button {
  width: 100%;
  padding: 13px 18px;
  color: white;
  background: linear-gradient(135deg, #ff6f98 0%, #f24880 100%);
  box-shadow: 0 12px 22px rgba(242, 85, 131, 0.27);
}

.soft-button {
  width: 100%;
  padding: 12px 14px;
  color: var(--primary-strong);
  background: linear-gradient(135deg, #ffe4ec, #ffd5e2);
}

.ghost-button {
  padding: 10px 14px;
  color: var(--primary-strong);
  background: #fff;
  border: 1px solid var(--line);
}

.danger-button {
  padding: 10px 14px;
  color: white;
  background: var(--danger);
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 82px;
  padding: 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(240, 210, 218, 0.9);
  box-shadow: var(--soft-shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.25rem;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ffdce7;
}

.progress > span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f64f83, #ff8eac);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: #ffe5ed;
  font-size: 0.72rem;
  font-weight: 850;
}

.pill.success {
  color: #187545;
  background: var(--success-soft);
}

.pill.warning {
  color: #af6b00;
  background: var(--warning-soft);
}

.pill.danger {
  color: var(--danger);
  background: #ffe3eb;
}

.chapter-list,
.question-list {
  display: grid;
  gap: 11px;
}

.reward-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.chapter-card,
.reward-card,
.question-card,
.redemption-card {
  padding: 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(240, 210, 218, 0.92);
  box-shadow: var(--soft-shadow);
}

.chapter-card {
  min-height: 70px;
}

.reward-card {
  min-height: 100px;
  align-content: space-between;
}

.reward-card h3 {
  font-size: 0.82rem;
  line-height: 1.25;
}

.reward-card .muted {
  display: none;
}

.reward-card.time-card .muted {
  display: block;
  font-size: 0.78rem;
}

.reward-card .row {
  display: grid;
  gap: 8px;
}

.reward-card .pill {
  width: max-content;
  background: transparent;
  padding: 0;
  color: var(--ink);
}

.reward-card button {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 0.72rem;
}

.nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.nav-inner {
  width: min(100%, 1120px);
  display: grid;
  gap: 4px;
  padding: 9px 14px calc(10px + var(--safe-bottom));
  border-top: 1px solid rgba(240, 208, 217, 0.78);
  background: rgba(255, 250, 251, 0.92);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.player-nav {
  grid-template-columns: repeat(5, 1fr);
}

.admin-nav {
  grid-template-columns: repeat(4, 1fr);
}

.nav button {
  min-height: 50px;
  border-radius: 16px;
  color: #78636d;
  background: transparent;
  font-size: 0.68rem;
  font-weight: 850;
}

.nav button.active {
  color: var(--primary-strong);
  background: transparent;
  box-shadow: none;
}

.player-nav button:nth-child(3)::before {
  content: "♡";
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: -26px auto 1px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #ff8aa8, #f04f82);
  box-shadow: 0 12px 24px rgba(242, 85, 131, 0.34);
  font-size: 1.5rem;
}

.player-nav button:nth-child(3) {
  color: var(--primary-strong);
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(242, 85, 131, 0.12);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
}

.password-toggle:active,
.password-toggle[aria-pressed="true"] {
  color: var(--primary-strong);
  background: rgba(242, 85, 131, 0.1);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.answer-button {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
  box-shadow: var(--soft-shadow);
}

.answer-letter {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--primary-strong);
  background: #fff0f5;
  font-weight: 900;
}

.answer-button.selected {
  border-color: var(--primary);
  background: #fff0f6;
}

.answer-button.correct {
  border-color: rgba(57, 185, 109, 0.5);
  background: #dff6e3;
}

.answer-button.correct .answer-letter {
  color: #187545;
  background: #c8efd2;
}

.answer-button.wrong {
  border-color: rgba(214, 71, 104, 0.35);
  background: #ffe8ee;
}

.quiz-footer {
  position: sticky;
  bottom: calc(76px + var(--safe-bottom));
  padding-top: 10px;
  background: linear-gradient(180deg, transparent, rgba(255, 247, 250, 0.95) 30%);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(92px + var(--safe-bottom));
  left: 16px;
  z-index: 50;
  width: min(calc(100% - 32px), 358px);
  margin: 0 auto;
  padding: 13px 16px;
  border-radius: 16px;
  color: #fff;
  background: rgba(56, 35, 49, 0.94);
  box-shadow: var(--shadow);
  animation: pop 0.18s ease;
}

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

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
  text-align: center;
}

.tutor-chat {
  padding-top: 4px;
}

.tutor-messages {
  display: grid;
  gap: 8px;
}

.tutor-message {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.tutor-message.from-user {
  justify-self: end;
  color: #fff;
  background: linear-gradient(135deg, #ff6f98, #f24880);
}

.tutor-message.from-ai {
  justify-self: start;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.tutor-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.admin-tabs button {
  min-height: 42px;
  border-radius: 14px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 850;
}

.admin-tabs button.active {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.login-hint {
  padding: 12px;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.login-welcome {
  text-align: center;
}

.julia-script {
  display: block;
  margin-top: 4px;
  color: var(--primary);
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 2.2rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 9px;
}

.quick-grid button {
  min-height: 70px;
  border-radius: 14px;
  padding: 8px 4px;
  font-size: 0.68rem;
}

.status-new {
  color: var(--primary-strong);
}

.status-learning {
  color: var(--warning);
}

.status-done {
  color: var(--success);
}

.flip-card {
  min-height: 330px;
  perspective: 1200px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  min-height: 330px;
  transition: transform 0.42s ease;
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.flip-card-front {
  text-align: center;
}

.flip-card-front h2 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}

.flip-card-back {
  transform: rotateY(180deg);
}

.flip-card-back p {
  font-size: 1rem;
  line-height: 1.6;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 24px 28px calc(96px + var(--safe-bottom));
  }

  .topbar {
    margin: -24px -28px 22px;
    padding: 18px 28px 14px;
  }

  .hero-card,
  .card {
    border-radius: 20px;
  }

  .chapter-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-list {
    max-width: 760px;
  }

  .quiz-footer {
    max-width: 760px;
  }
}

@media (min-width: 1020px) {
  .reward-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
