@font-face {
  font-family: "IMTYC Birthday";
  src: url("./fonts/IMTYC-Birthday-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IMTYC Birthday";
  src: url("./fonts/IMTYC-Birthday-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "IMTYC Birthday";
  src: url("./fonts/IMTYC-Birthday-Thin.ttf") format("truetype");
  font-weight: 300;
  font-display: swap;
}

:root {
  --sky-deep: #141a42;
  --sky: #1c2456;
  --sky-light: #2a3372;
  --orange: #f5a623;
  --orange-light: #ffb94d;
  --yellow: #fcd34d;
  --cream: #fef6e4;
  --ink: #fef6e4;
  --ink-dim: #c5c8e8;
  --ink-muted: #8b8fb8;
  --cloud: #ffffff;
  --pink: #f9b4c9;
  --card-border: rgba(252, 211, 77, 0.4);
  --shadow-card: 0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.4);
  --glow-yellow: 0 0 24px rgba(252, 211, 77, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  font-family: "IMTYC Birthday", "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background: var(--sky-deep);
  overflow-x: hidden;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ========== Starry sky background ========== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 12% 14%, #fff, transparent 50%),
    radial-gradient(1px 1px at 27% 8%, #fff, transparent 50%),
    radial-gradient(2px 2px at 42% 22%, #fff, transparent 50%),
    radial-gradient(1px 1px at 55% 15%, #fff, transparent 50%),
    radial-gradient(1.5px 1.5px at 68% 28%, #fff, transparent 50%),
    radial-gradient(1px 1px at 83% 12%, #fff, transparent 50%),
    radial-gradient(1.8px 1.8px at 91% 33%, #fff, transparent 50%),
    radial-gradient(1px 1px at 8% 42%, #fff, transparent 50%),
    radial-gradient(1.3px 1.3px at 22% 55%, #fff, transparent 50%),
    radial-gradient(1px 1px at 38% 48%, #fff, transparent 50%),
    radial-gradient(2px 2px at 60% 58%, #fff, transparent 50%),
    radial-gradient(1px 1px at 78% 52%, #fff, transparent 50%),
    radial-gradient(1.5px 1.5px at 93% 65%, #fff, transparent 50%),
    radial-gradient(1px 1px at 15% 75%, #fff, transparent 50%),
    radial-gradient(1.5px 1.5px at 30% 84%, #fff, transparent 50%),
    radial-gradient(1px 1px at 48% 72%, #fff, transparent 50%),
    radial-gradient(2px 2px at 66% 88%, #fff, transparent 50%),
    radial-gradient(1.3px 1.3px at 82% 78%, #fff, transparent 50%),
    linear-gradient(180deg, var(--sky-deep) 0%, var(--sky) 50%, var(--sky-light) 100%);
  background-size: 100% 100%;
  z-index: 0;
  pointer-events: none;
  animation: twinkle 6s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* Decorative sparkles */
.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  opacity: 0.9;
  animation: spark 3s ease-in-out infinite;
}

.sparkle.s1 {
  top: 18%;
  left: 6%;
  animation-delay: 0s;
}
.sparkle.s2 {
  top: 34%;
  right: 8%;
  animation-delay: 1s;
}
.sparkle.s3 {
  bottom: 28%;
  left: 10%;
  animation-delay: 2s;
}
.sparkle.s4 {
  bottom: 42%;
  right: 6%;
  animation-delay: 0.5s;
}

@keyframes spark {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.9; }
  50% { transform: scale(1.25) rotate(20deg); opacity: 1; }
}

/* Shooting stars */
.shooting-star {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
}

.shooting-star.left {
  top: 26%;
  left: 2%;
}
.shooting-star.right {
  top: 38%;
  right: 2%;
  transform: scaleX(-1);
}

/* Cloud decorations at the bottom */
.cloud {
  position: fixed;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
}

.cloud.left {
  left: -30px;
  width: 240px;
}

.cloud.right {
  right: -30px;
  width: 280px;
}

/* ========== A vs B Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 30, 0.72);
  backdrop-filter: blur(6px);
  padding: 20px;
  animation: fadeInUp 260ms ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(42, 51, 114, 0.95), rgba(20, 26, 66, 0.98));
  border: 1.5px solid rgba(252, 211, 77, 0.35);
  border-radius: 22px;
  padding: 26px 24px;
  box-shadow: var(--shadow-lift), 0 0 40px rgba(252, 211, 77, 0.15);
}

.modal-card h3 {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-card > p {
  margin: 0 0 18px;
  color: var(--ink-dim);
  font-size: 0.92rem;
  font-weight: 300;
  line-height: 1.6;
}

.modal-card label {
  display: block;
  margin-bottom: 14px;
}

.modal-card label span {
  display: block;
  margin-bottom: 6px;
  color: var(--yellow);
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.modal-card input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(252, 211, 77, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: var(--cream);
  font-family: inherit;
  font-size: 0.98rem;
  transition: border-color 200ms ease, background 200ms ease;
}

.modal-card input:focus {
  outline: none;
  border-color: var(--yellow);
  background: rgba(255, 255, 255, 0.08);
}

.modal-card input::placeholder {
  color: var(--ink-muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .ghost-btn {
  flex: 0 0 auto;
  width: auto;
  padding: 12px 20px;
}

.modal-actions .primary-btn {
  flex: 1;
  width: auto;
}

/* ========== Floating history button ========== */
.floating-history {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 13px;
  border-radius: 999px;
  border: 1.5px solid rgba(252, 211, 77, 0.4);
  background: rgba(20, 26, 66, 0.75);
  color: var(--yellow);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 400;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: all 220ms ease;
}

.floating-history:hover {
  border-color: var(--yellow);
  color: var(--cream);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5), 0 0 14px rgba(252, 211, 77, 0.3);
}

.floating-history svg {
  opacity: 0.95;
}

/* ========== App shell ========== */
.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 36px 18px 140px;
  position: relative;
  z-index: 2;
}

/* ========== Header ========== */
.app-header {
  text-align: center;
  margin-bottom: 32px;
  animation: fadeInUp 700ms ease;
}

.header-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.badge {
  margin: 0;
  color: var(--yellow);
  letter-spacing: 0.42em;
  font-size: 0.74rem;
  font-weight: 300;
  text-transform: uppercase;
  opacity: 0.92;
}

.badge::before,
.badge::after {
  content: "✦";
  margin: 0 12px;
  font-size: 0.75em;
  color: var(--orange);
  opacity: 0.85;
}

h1 {
  font-family: "IMTYC Birthday", serif;
  font-weight: 700;
  margin: 16px 0 10px;
  font-size: clamp(2.6rem, 7.5vw, 4rem);
  color: var(--cream);
  line-height: 1.1;
  text-shadow: 0 4px 0 rgba(245, 166, 35, 0.25), 0 0 40px rgba(252, 211, 77, 0.18);
}

h1 .accent {
  color: var(--orange);
  display: inline-block;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

h2 {
  font-family: "IMTYC Birthday", serif;
  font-weight: 700;
  margin: 0 0 18px;
  font-size: clamp(1.4rem, 4.4vw, 1.9rem);
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 14px;
}

h2::before {
  content: "✧";
  color: var(--orange);
  font-size: 0.9em;
}

.subtitle {
  margin: 0;
  color: var(--ink-dim);
  font-size: 1rem;
  font-weight: 300;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.65;
}

/* ========== Screens ========== */
.screen {
  display: none;
  position: relative;
  background: linear-gradient(180deg, rgba(42, 51, 114, 0.55), rgba(20, 26, 66, 0.75));
  border: 1.5px solid rgba(252, 211, 77, 0.22);
  border-radius: 28px;
  padding: 26px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lift), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.screen.active {
  display: block;
  animation: fadeInUp 500ms ease;
}

/* ========== Personality ========== */
.personality-box {
  margin-bottom: 22px;
  border: 1.5px solid rgba(252, 211, 77, 0.2);
  border-radius: 20px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(245, 166, 35, 0.08), rgba(255, 255, 255, 0.02));
}

.personality-box p {
  margin: 0 0 12px;
  color: var(--yellow);
  font-size: 0.94rem;
  font-weight: 300;
  letter-spacing: 0.05em;
}

.personality-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.personality-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  border: 1.5px solid rgba(252, 211, 77, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  padding: 14px 8px 12px;
  font-size: 0.96rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 200ms ease;
}

.pb-emoji {
  font-size: 1.7rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.pb-label {
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.personality-btn:hover {
  border-color: var(--yellow);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.personality-btn.active {
  border-color: var(--orange);
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  box-shadow: 0 8px 20px rgba(245, 166, 35, 0.4);
  color: #2b1605;
  font-weight: 700;
  transform: translateY(-1px);
}

/* ========== Question picker ========== */
.question-picker {
  display: grid;
  gap: 14px;
}

.question-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 2px;
}

.category-chip {
  border: 1.5px solid rgba(252, 211, 77, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 10px 18px;
  white-space: nowrap;
  font-size: 0.94rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 220ms ease;
}

.category-chip:hover {
  color: var(--yellow);
  border-color: var(--yellow);
  transform: translateY(-1px);
}

.category-chip.active {
  color: #2b1605;
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  border-color: var(--orange);
  box-shadow: 0 6px 18px rgba(245, 166, 35, 0.4);
  font-weight: 700;
}

.active-category-label {
  margin: 2px 0 0;
  color: var(--yellow);
  font-size: 0.92rem;
  font-weight: 300;
  opacity: 0.88;
}

.question-list {
  display: grid;
  gap: 10px;
}

/* ========== Buttons ========== */
.question-btn,
.primary-btn,
.ghost-btn {
  width: 100%;
  border-radius: 999px;
  border: 1.5px solid transparent;
  padding: 14px 22px;
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 240ms ease;
}

.small-btn {
  width: auto;
  padding: 10px 22px;
  font-size: 0.92rem;
}

.question-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(252, 211, 77, 0.24);
  text-align: left;
  padding: 14px 20px;
  font-size: 0.98rem;
  border-radius: 18px;
}

.question-btn:hover {
  background: linear-gradient(
    100deg,
    rgba(245, 166, 35, 0.16),
    rgba(252, 211, 77, 0.08)
  );
  border-color: var(--yellow);
  transform: translateX(4px);
}

.question-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.primary-btn {
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: #2b1605;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 22px rgba(245, 166, 35, 0.38);
  border: none;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(245, 166, 35, 0.55);
  filter: brightness(1.08);
}

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: grayscale(0.3);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(252, 211, 77, 0.4);
  color: var(--yellow);
  font-weight: 400;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--yellow);
  transform: translateY(-1px);
}

/* ========== Card pick screen ========== */
.spread-hint {
  margin: 0 0 14px;
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(245, 166, 35, 0.12), transparent);
  border-left: 3px solid var(--orange);
  border-radius: 10px;
  color: var(--yellow);
  font-size: 0.94rem;
  font-weight: 300;
}

.selected-count {
  color: var(--ink-dim);
  margin: 0 0 18px;
  font-size: 0.96rem;
  text-align: center;
}

.selected-count span {
  color: var(--yellow);
  font-weight: 700;
  font-size: 1.1em;
}

.card-grid {
  position: relative;
  width: 100%;
  border-radius: 20px;
  background: radial-gradient(
      ellipse at center,
      rgba(245, 166, 35, 0.14) 0%,
      transparent 72%
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2));
  border: 1.5px solid rgba(252, 211, 77, 0.18);
  padding: 14px;
}

.card-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.tarot-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 1.5px solid var(--card-border);
  border-radius: 7px;
  background: linear-gradient(160deg, #2a3372 0%, #1c2456 60%, #141a42 100%);
  cursor: pointer;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 240ms ease, border-color 200ms ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4),
    inset 0 0 10px rgba(0, 0, 0, 0.4);
}

.tarot-card::before {
  content: "✦";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Cinzel", serif;
  color: var(--yellow);
  font-size: 0.95rem;
  opacity: 0.62;
  text-shadow: 0 0 6px rgba(252, 211, 77, 0.5);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease, color 220ms ease;
}

.tarot-card::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(252, 211, 77, 0.24);
  border-radius: 5px;
  pointer-events: none;
}

.tarot-card:hover {
  transform: translateY(-6px) scale(1.08);
  z-index: 10;
  border-color: var(--yellow);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.55), 0 0 16px rgba(252, 211, 77, 0.4);
}

.tarot-card:hover::before {
  opacity: 1;
  transform: scale(1.2);
  color: var(--cream);
}

.tarot-card.selected {
  transform: translateY(-8px) scale(1.12);
  z-index: 20;
  border-color: var(--orange);
  background: linear-gradient(160deg, #5c2e9e 0%, #362968 60%, #1e1d4a 100%);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(245, 166, 35, 0.6);
}

.tarot-card.selected::before {
  opacity: 1;
  color: var(--orange);
  font-size: 1.2rem;
  text-shadow: 0 0 10px rgba(245, 166, 35, 0.9);
  transform: scale(1.15);
}

/* ========== Result screen ========== */
.question-result {
  margin: 0 0 18px;
  padding: 14px 18px;
  border-left: 3px solid var(--orange);
  background: rgba(245, 166, 35, 0.08);
  border-radius: 12px;
  color: var(--yellow);
  font-size: 1.02rem;
}

.screen-actions {
  margin-top: 22px;
  display: flex;
  gap: 12px;
  align-items: stretch;
}

#pickScreen .screen-actions #backBtn {
  flex: 0 0 auto;
  width: auto;
  padding: 14px 22px;
}

#pickScreen .screen-actions #revealBtn {
  flex: 1;
  width: auto;
}

#historyScreen .screen-actions {
  justify-content: space-between;
}

#clearHistoryBtn {
  color: #ff9d9d;
  border-color: rgba(255, 120, 120, 0.45);
  background: rgba(180, 50, 50, 0.1);
}

#clearHistoryBtn:hover {
  color: #ffbaba;
  border-color: #ff8080;
  background: rgba(200, 60, 60, 0.18);
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0 24px;
}

.result-card {
  perspective: 1000px;
}

.result-card-face {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  transform-style: preserve-3d;
  transition: transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-card-face.flipped {
  transform: rotateY(180deg);
}

.face,
.back {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 1.5px solid var(--card-border);
  backface-visibility: hidden;
  overflow: hidden;
}

.back {
  background: linear-gradient(160deg, #2a3372 0%, #1c2456 60%, #141a42 100%);
  display: grid;
  place-items: center;
  color: var(--yellow);
  font-size: 2rem;
  text-shadow: 0 0 14px rgba(252, 211, 77, 0.65);
}

.back::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(252, 211, 77, 0.32);
  border-radius: 10px;
}

.face {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #2a3372 0%, #141a42 100%);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 28px rgba(252, 211, 77, 0.3);
}

.face img {
  width: 100%;
  height: 62%;
  object-fit: cover;
  border-bottom: 1px solid var(--card-border);
}

.card-meta {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-meta h3 {
  margin: 0;
  font-size: 0.94rem;
  color: var(--yellow);
  font-weight: 700;
}

.card-meta p {
  margin: 4px 0 0;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 300;
}

/* ========== Loading / Reading ========== */
.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(245, 166, 35, 0.14), rgba(245, 166, 35, 0.04));
  border-radius: 14px;
  border: 1.5px solid rgba(245, 166, 35, 0.28);
}

.loading-box.hidden {
  display: none;
}

.loading-box p {
  margin: 0;
  color: var(--yellow);
  font-weight: 300;
}

.loader {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(252, 211, 77, 0.22);
  border-top-color: var(--orange);
  animation: spin 700ms linear infinite;
}

.reading-output {
  background: linear-gradient(180deg, rgba(252, 211, 77, 0.05), rgba(255, 255, 255, 0.02));
  border: 1.5px solid rgba(252, 211, 77, 0.2);
  border-radius: 16px;
  padding: 22px 24px;
  min-height: 100px;
  line-height: 1.95;
  color: var(--cream);
  font-size: 1.04rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
}

/* ========== Lock / History ========== */
.lock-box {
  margin-top: 16px;
  border: 1.5px solid rgba(252, 211, 77, 0.4);
  border-radius: 16px;
  padding: 18px;
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.12), rgba(252, 211, 77, 0.06));
}

.lock-box.hidden {
  display: none;
}

.lock-box h3 {
  margin: 0 0 8px;
  color: var(--yellow);
  font-weight: 700;
}

.lock-box p {
  margin: 0 0 14px;
  color: var(--ink-dim);
  font-size: 0.94rem;
  font-weight: 300;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1.5px solid rgba(252, 211, 77, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  transition: all 220ms ease;
}

.history-item:hover {
  border-color: var(--yellow);
  background: rgba(255, 255, 255, 0.06);
}

.history-item h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: var(--yellow);
}

.history-item p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.6;
  font-weight: 300;
}

/* ========== Responsive ========== */
@media (max-width: 767px) {
  .screen {
    padding: 20px 16px;
  }
  .reading-output {
    padding: 16px 16px;
    font-size: 0.98rem;
    line-height: 1.8;
  }
  .app-shell {
    padding: 28px 14px 160px;
  }

  .question-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .category-chip {
    padding: 8px 10px;
    font-size: 0.82rem;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
  }
  .floating-history {
    padding: 7px 13px 7px 11px;
    font-size: 0.8rem;
  }
  .floating-history span {
    display: none;
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding: 48px 28px 180px;
  }

  .screen {
    padding: 34px;
  }

  .card-grid {
    padding: 18px;
  }

  .card-row {
    grid-template-columns: repeat(13, 1fr);
    gap: 7px;
  }

  .question-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .floating-history {
    top: 28px;
    right: 28px;
    padding: 10px 20px 10px 16px;
    font-size: 0.94rem;
  }

  .result-cards {
    grid-template-columns: repeat(3, minmax(0, 190px));
    justify-content: center;
    gap: 20px;
  }

  .screen-actions {
    justify-content: center;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
  }

  .cloud.left {
    width: 320px;
  }
  .cloud.right {
    width: 360px;
  }
}

/* ========== Animations ========== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* === Auth / Credit UI === */
.top-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 20;
}
.auth-btn,
.credit-badge {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: #5b3a1a;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(91, 58, 26, 0.12);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.auth-btn:hover,
.credit-badge:hover {
  background: #fff;
  transform: translateY(-1px);
}
.credit-badge .cb-free {
  color: #16803a;
  font-weight: 600;
}
.credit-badge .cb-free.spent {
  color: #94918a;
}
.credit-badge .cb-sep {
  color: #cbb79c;
}
.credit-badge .cb-paid {
  color: #b45309;
  font-weight: 700;
}
.credit-badge .cb-label {
  color: #6b5a44;
  font-size: 12px;
}

.user-menu {
  position: fixed;
  top: 58px;
  left: 16px;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(91, 58, 26, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 25;
  max-width: 280px;
}
.user-menu.hidden {
  display: none;
}
.user-menu img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.user-menu .muted {
  font-size: 11px;
  color: #94918a;
}

/* === Package list === */
.modal-card.wide {
  max-width: 480px;
}
.package-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.package-card {
  background: #fff7ec;
  border: 2px solid #f2dcb5;
  border-radius: 12px;
  padding: 14px 8px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: all 0.2s;
}
.package-card:hover {
  border-color: #f5a623;
}
.package-card.active {
  border-color: #f5a623;
  background: #ffe9c5;
  box-shadow: 0 4px 12px rgba(245, 166, 35, 0.3);
}
.pc-credits {
  font-size: 28px;
  font-weight: 700;
  color: #b45309;
}
.pc-label {
  font-size: 11px;
  color: #6b5a44;
  margin: 2px 0 6px;
}
.pc-price {
  font-size: 16px;
  font-weight: 600;
  color: #5b3a1a;
}

.buy-step-2 {
  border-top: 1px solid #f2dcb5;
  padding-top: 14px;
  margin-top: 10px;
}
.buy-step-2 h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #5b3a1a;
}
.buy-step-2.hidden {
  display: none;
}
.qr-box {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 8px;
  min-height: 220px;
  align-items: center;
}
.slip-upload {
  display: block;
  margin-top: 10px;
  padding: 12px;
  border: 2px dashed #f2dcb5;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  color: #6b5a44;
  font-size: 13px;
}
.slip-upload input {
  display: block;
  margin: 8px auto 0;
  font-size: 12px;
}
.buy-status {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  min-height: 18px;
}

@media (max-width: 767px) {
  .top-bar {
    top: 8px;
    left: 8px;
  }
  .auth-btn,
  .credit-badge {
    font-size: 12px;
    padding: 5px 10px;
  }
  .package-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .pc-credits {
    font-size: 22px;
  }
}
