@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --blush: #FFB3C8;
  --peach: #FFCBA4;
  --yellow: #FFF0BA;
  --mint: #C8F0C8;
  --sky: #C8E6FF;
  --lavender: #E8C8FF;
  --white: #FFFFFF;
  --soft-pink: #FFD6E0;
  --deep-pink: #FF85A1;
  --text: #5C4B6B;
  --subtext: #9B8AAB;
  --chat-blue: #CDE7FF;
  --chat-blue-border: #A9D4FF;
  --chat-grey: #ECE9F1;
  --chat-grey-border: #D9D2E6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: 'Nunito', sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: repeating-linear-gradient(
    135deg,
    var(--blush) 0px,
    var(--blush) 80px,
    var(--peach) 80px,
    var(--peach) 160px,
    var(--yellow) 160px,
    var(--yellow) 240px,
    var(--mint) 240px,
    var(--mint) 320px,
    var(--sky) 320px,
    var(--sky) 400px,
    var(--lavender) 400px,
    var(--lavender) 480px
  );
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(180, 150, 210, 0.4);
  border-radius: 3px;
}

/* ============ content area ============ */

#content {
  width: 100%;
  max-width: 400px;
  flex: 1;
  padding: 24px 16px 96px;
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.page.slide-up {
  animation: slideUp 0.22s ease forwards;
}

.page.slide-out {
  animation: slideOut 0.18s ease forwards;
}

/* ============ buttons ============ */

button {
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  border: none;
}

.btn {
  color: white;
  border-radius: 16px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 800;
  background: var(--deep-pink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:disabled {
  background: #C8C0D0;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:hover:not(:disabled) {
  transform: scale(1.04) translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* ============ home page ============ */

.home-title {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  background: linear-gradient(135deg, var(--blush), var(--lavender), var(--sky));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: bounce 2s ease-in-out infinite;
}

.home-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--subtext);
  text-align: center;
}

.stats-card {
  display: flex;
  gap: 28px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 20px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.stat-group {
  display: flex;
  align-items: stretch;
  gap: 28px;
}

.stat {
  text-align: center;
}

.stat-val {
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--subtext);
}

.stat-divider {
  width: 1px;
  background: rgba(0, 0, 0, 0.08);
}

.panel {
  width: 100%;
  max-width: 340px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 20px;
}

.panel-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 12px;
}

.char-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.char-thumb {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid;
  overflow: hidden;
  transition: transform 0.15s;
}

.char-thumb:hover {
  transform: scale(1.15);
}

.char-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.tip {
  font-size: 13px;
  color: var(--subtext);
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 12px 20px;
}

/* ============ gacha page ============ */

.coin-counter {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 12px 28px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.gacha-machine {
  width: 220px;
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10);
  animation: floatOrb 3s ease-in-out infinite;
}

.orb {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: conic-gradient(var(--blush), var(--peach), var(--yellow), var(--mint), var(--sky), var(--lavender));
}

.orb-machine {
  width: 132px;
  height: 132px;
  font-size: 54px;
  animation: orbGlow 2s ease-in-out infinite;
}

.orb-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--subtext);
}

.pull-wrap.shake {
  animation: shakeX 0.5s ease;
}

.coin-note {
  font-size: 13px;
  color: var(--subtext);
  text-align: center;
}

.recent-wrap {
  width: 100%;
  max-width: 340px;
}

.recent-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.recent-thumb {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 2px solid;
  overflow: hidden;
}

.recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============ gacha reveal overlay ============ */

.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(80, 50, 100, 0.88);
  backdrop-filter: blur(10px);
}

.reveal-overlay.playing {
  animation: fadeIn 0.3s ease;
}

.reveal-orb {
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--blush), var(--peach), var(--yellow), var(--mint), var(--sky), var(--lavender));
}

.reveal-orb.phase-orb {
  animation: orbPulse 0.6s ease-in-out infinite;
}

.reveal-orb.phase-crack {
  animation: crack 0.75s ease-in forwards;
}

.reveal-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.reveal-card-wrap.playing {
  animation: cardReveal 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reveal-card {
  width: 240px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  border-radius: 28px;
  padding: 0 0 24px;
}

.reveal-card.done {
  animation: cardFloat 3s ease-in-out infinite;
}

.reveal-shimmer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 28px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.65) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}

.reveal-img-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  position: relative;
  border-radius: 24px 24px 0 0;
  overflow: hidden;
}

.reveal-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 22px 22px 0 0;
}

.reveal-rarity-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 3px 10px;
}

.reveal-name {
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
  padding: 16px 20px 0;
}

.reveal-caption {
  font-size: 12px;
  font-style: italic;
  color: var(--subtext);
  text-align: center;
  margin-top: 4px;
  padding: 0 20px;
}

.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
}

.sparkle.playing {
  animation: sparkle 0.8s ease-out forwards;
}

/* ============ collection page ============ */

.collection-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

/* player level bar */
.coll-player-level {
  width: 100%;
  max-width: 340px;
  background: rgba(255,255,255,0.7);
  border-radius: 20px;
  padding: 14px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coll-pl-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.coll-pl-val {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

.coll-pl-xpbar {
  width: 100%;
  height: 8px;
  background: rgba(180,160,200,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.coll-pl-xpfill {
  height: 100%;
  background: linear-gradient(90deg, var(--blush), var(--lavender));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.coll-pl-xptext {
  font-size: 11px;
  font-weight: 700;
  color: var(--subtext);
  text-align: right;
}

.empty-state {
  font-size: 15px;
  color: var(--subtext);
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 32px 24px;
}

.coll-grid {
  width: 100%;
  max-width: 340px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.coll-card {
  border: 2px solid;
  border-radius: 20px;
  overflow: hidden;
  transition: all 0.2s;
}

.coll-card.unowned {
  opacity: 0.45;
}

.coll-img-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  position: relative;
}

.coll-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.coll-img-wrap img.gray {
  filter: grayscale(1);
}

.coll-count {
  position: absolute;
  top: 6px;
  right: 6px;
  color: white;
  font-size: 11px;
  font-weight: 900;
  border-radius: 8px;
  padding: 2px 7px;
}

.coll-level-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  color: white;
  font-size: 10px;
  font-weight: 900;
  border-radius: 7px;
  padding: 2px 6px;
  letter-spacing: 0.5px;
}

.coll-info {
  text-align: center;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.coll-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.coll-rarity {
  font-size: 11px;
  letter-spacing: 1px;
}

/* per-character XP bar */
.coll-xp-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.coll-xp-bar {
  width: 100%;
  height: 5px;
  background: rgba(180,160,200,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.coll-xp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.35s ease;
  min-width: 0;
}

.coll-xp-text {
  font-size: 9px;
  font-weight: 700;
  color: var(--subtext);
  text-align: right;
}

/* merge button */
.coll-merge-btn {
  width: 100%;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 900;
  color: white;
  background: var(--merge-color, var(--deep-pink));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  font-family: 'Nunito', sans-serif;
}

.coll-merge-btn:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.coll-merge-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

/* ============ chat list page ============ */

.chat-list {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  border: none;
  border-radius: 20px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  font-family: 'Nunito', sans-serif;
}

.chat-row:hover:not(.locked) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
}

.chat-row:active:not(.locked) {
  transform: scale(0.98);
}

.chat-row.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-row-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 2px solid;
  overflow: hidden;
}

.chat-row-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-row.locked .chat-row-avatar img {
  filter: grayscale(1);
}

.chat-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-row-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.chat-row-preview {
  font-size: 12px;
  font-weight: 600;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row.locked .chat-row-preview {
  display: none;
}

.chat-row.locked .chat-row-info::after {
  content: "locked — pull to unlock";
  font-size: 12px;
  font-weight: 600;
  color: var(--subtext);
}

.chat-row-arrow {
  font-size: 20px;
  font-weight: 800;
  color: var(--subtext);
  flex-shrink: 0;
}

/* ============ chat fullscreen overlay ============ */

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 16px;
}

.chat-back-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.chat-back-btn:hover {
  transform: scale(1.08);
}

.chat-back-btn:active {
  transform: scale(0.92);
}

.chat-topbar-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 2px solid;
  overflow: hidden;
}

.chat-topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-topbar-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.chat-thread {
  flex: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.35);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}

.chat-history-divider {
  align-self: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--subtext);
  opacity: 0.7;
  margin: 2px 0 6px;
}

.chat-bubble {
  max-width: 72%;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  word-wrap: break-word;
  opacity: 0;
}

.chat-bubble-char {
  align-self: flex-start;
  background: var(--chat-grey);
  border: 1.5px solid var(--chat-grey-border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.chat-bubble-player {
  align-self: flex-end;
  background: var(--chat-blue);
  border: 1.5px solid var(--chat-blue-border);
  color: var(--text);
  border-bottom-right-radius: 6px;
}

.chat-bubble-fly-in {
  animation: chatBubbleFlyIn 0.32s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
}

.chat-options-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  padding-top: 8px;
}

.chat-option-btn {
  align-self: flex-end;
  max-width: 80%;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--deep-pink);
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid var(--blush);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.chat-option-btn:hover {
  transform: translateY(-2px);
  background: var(--soft-pink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
}

.chat-option-btn:active {
  transform: scale(0.96);
}

/* ============ level-up toast ============ */

.levelup-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.levelup-toast.levelup-in {
  animation: levelupPop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.levelup-toast.levelup-out {
  animation: levelupFade 0.4s ease forwards;
}

.levelup-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 14px 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  border: 2px solid var(--blush);
  white-space: nowrap;
}

.levelup-sparkle {
  font-size: 24px;
  animation: bounce 0.8s ease-in-out infinite;
}

.levelup-text {
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--deep-pink), var(--lavender));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.levelup-char {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.levelup-new {
  font-size: 12px;
  font-weight: 700;
  color: var(--subtext);
}

/* ============ tab bar ============ */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 16px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(200, 180, 220, 0.3);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border-radius: 16px;
  padding: 8px 14px;
  transform: scale(1);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--soft-pink);
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(255, 150, 180, 0.3);
}

.tab-icon {
  font-size: 22px;
}

.tab-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--subtext);
}

.tab-btn.active .tab-label {
  font-weight: 800;
  color: var(--deep-pink);
}

/* ============ minigame hub (home tab) ============ */

#mg-hub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.mg-hub-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.mg-hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.mg-hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(200, 180, 220, 0.4);
  border-radius: 22px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}

.mg-hub-card:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.mg-hub-card:active {
  transform: scale(0.97);
}

.mg-hub-icon {
  font-size: 36px;
}

.mg-hub-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.mg-hub-desc {
  font-size: 11px;
  color: var(--subtext);
  text-align: center;
  line-height: 1.4;
}

/* ============ overlay hub row (inside game overlay, idle state only) ============ */
/* Acts as a "go back / switch game" control. Hidden once a round actually starts. */

.overlay-hub-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 18px;
}

.overlay-hub-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(200, 180, 220, 0.4);
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}

.overlay-hub-card .mg-hub-icon {
  font-size: 22px;
}

.overlay-hub-card .mg-hub-name {
  font-size: 12px;
}

.overlay-hub-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.overlay-hub-card:active {
  transform: scale(0.97);
}

.overlay-hub-card.active {
  background: var(--soft-pink);
  border-color: var(--blush);
  box-shadow: 0 2px 10px rgba(255, 150, 180, 0.3);
}

/* When a round is actively in progress, the overlay goes "game only":
   hub row and topbar title hide, leaving just the stats row + board/letters. */

.game-overlay.in-game .overlay-hub-row,
.game-overlay.in-game .game-title-row {
  display: none;
}

/* ============ game fullscreen overlay ============ */

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: repeating-linear-gradient(
    135deg,
    var(--blush) 0px,
    var(--blush) 80px,
    var(--peach) 80px,
    var(--peach) 160px,
    var(--yellow) 160px,
    var(--yellow) 240px,
    var(--mint) 240px,
    var(--mint) 320px,
    var(--sky) 320px,
    var(--sky) 400px,
    var(--lavender) 400px,
    var(--lavender) 480px
  );
  padding: 48px 20px 100px;
  overflow-y: auto;
  gap: 0;
}

.game-overlay.enter {
  animation: slideUp 0.22s ease forwards;
}

/* top bar: title + stats row */
.game-topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 20px;
}

.game-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.game-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}

.game-stats-row {
  display: flex;
  gap: 20px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  padding: 8px 24px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

.game-timer.low {
  color: var(--deep-pink);
}

.game-mult {
  color: var(--subtext);
}

/* idle / result panel shown on top of the overlay background */
.game-idle-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  padding: 28px 32px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.10);
  max-width: 340px;
  width: 100%;
  text-align: center;
  backdrop-filter: blur(10px);
}

.game-idle-panel .mg-desc {
  font-size: 14px;
  color: var(--subtext);
  max-width: 260px;
}

.game-idle-panel .bonus {
  font-size: 12px;
  color: var(--lavender);
}

.game-message {
  font-size: 15px;
  font-weight: 800;
  color: var(--deep-pink);
  text-align: center;
}

/* ============ match 3 board (used inside overlay) ============ */

.mg-board-wrap {
  position: relative;
}

.mg-board {
  display: grid;
  grid-template-columns: repeat(7, 42px);
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  user-select: none;
  touch-action: none;
  cursor: grab;
  backdrop-filter: blur(6px);
}

.candy {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s, opacity 0.15s;
}

.candy.flash {
  transform: scale(0);
  opacity: 0;
}

.combo-pop {
  position: absolute;
  font-weight: 900;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  -webkit-text-stroke: 1px rgba(100, 70, 120, 0.3);
}

.combo-pop.playing {
  animation: comboFloat 1s ease-out forwards;
}

/* ============ word scramble (used inside overlay) ============ */

.ws-game-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

.ws-char-card {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 22px;
  overflow: hidden;
  border: 3px solid rgba(200, 180, 220, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
}

.ws-char-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ws-char-rarity {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
}

/* transparent grid behind scramble area */
.ws-grid-bg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  padding: 20px 20px 18px;
  width: 100%;
  max-width: 340px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}

/* answer slots row */
.ws-answer-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 52px;
}

.ws-slot {
  width: 40px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(200, 180, 220, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
  cursor: pointer;
}

.ws-slot:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-2px);
}

.ws-slot.filled {
  background: var(--soft-pink);
  border-color: var(--blush);
}

.ws-slot.correct {
  background: #C8F0C8;
  border-color: #A0D8A0;
  animation: wsCorrect 0.4s ease forwards;
}

.ws-slot.wrong {
  animation: wsWrong 0.4s ease forwards;
}

/* drag-over highlight for empty slots accepting a dragged tile */
.ws-slot.drag-over {
  background: var(--mint);
  border-color: #A0D8A0;
  box-shadow: 0 0 0 3px rgba(160, 216, 160, 0.4);
  transform: translateY(-2px) scale(1.05);
}

/* scrambled letter tiles */
.ws-letters {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 300px;
}

.ws-tile {
  width: 44px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  cursor: grab;
  border: 2px solid rgba(200, 180, 220, 0.4);
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  animation: wsTilePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ws-tile:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.13);
}

.ws-tile:active {
  transform: scale(0.93);
  cursor: grabbing;
}

.ws-tile.used {
  opacity: 0.25;
  pointer-events: none;
  transform: scale(0.9);
}

.ws-tile.dragging {
  opacity: 0.35;
}

.ws-clear-btn {
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(200, 180, 220, 0.4);
  border-radius: 12px;
  padding: 7px 22px;
  font-size: 13px;
  font-weight: 800;
  color: var(--subtext);
  cursor: pointer;
  transition: all 0.15s;
}

.ws-clear-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

/* ============ keyframes ============ */

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

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-16px);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes sparkle {
  0% {
    transform: scale(0) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1.6) translateY(-32px);
    opacity: 0;
  }
}

@keyframes comboFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--rot, 0deg));
  }
  60% {
    opacity: 1;
    transform: translateY(-24px) scale(1.15) rotate(var(--rot, 0deg));
  }
  100% {
    opacity: 0;
    transform: translateY(-48px) scale(0.9) rotate(var(--rot, 0deg));
  }
}

@keyframes shakeX {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}

@keyframes floatOrb {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes orbGlow {
  0%, 100% {
    box-shadow: 0 0 40px 10px rgba(200, 180, 255, 0.45);
  }
  50% {
    box-shadow: 0 0 80px 30px rgba(200, 180, 255, 0.8);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes orbPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.13);
  }
}

@keyframes crack {
  0% {
    transform: scale(1.12) rotate(0deg);
    opacity: 1;
  }
  25% {
    transform: scale(1.22) rotate(-4deg);
  }
  55% {
    transform: scale(0.85) rotate(6deg);
    opacity: 0.5;
  }
  100% {
    transform: scale(0) rotate(12deg);
    opacity: 0;
  }
}

@keyframes cardReveal {
  0% {
    transform: translateY(70px) scale(0.65) rotateY(90deg);
    opacity: 0;
  }
  60% {
    transform: translateY(-12px) scale(1.06) rotateY(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1) rotateY(0deg);
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

@keyframes cardFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes wsCardPop {
  0% {
    transform: scale(0.7) rotateY(90deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.05) rotateY(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
  }
}

@keyframes wsTilePop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes wsCorrect {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes wsWrong {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes wsStreakPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.4);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes levelupPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.7) translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
}

@keyframes levelupFade {
  0% {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.85) translateY(-12px);
  }
}

@keyframes chatBubbleFlyIn {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.85);
  }
  60% {
    opacity: 1;
    transform: translateY(-3px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

.hidden {
  display: none;
}

/* ============ daily login bonus overlay ============ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(80, 50, 100, 0.82);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.35s ease;
}

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

.login-box {
  background: rgba(255,255,255,0.95);
  border-radius: 32px;
  padding: 36px 32px 28px;
  max-width: 320px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  animation: cardReveal 0.55s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.login-emoji {
  font-size: 56px;
  line-height: 1;
  animation: bounce 1.6s ease-in-out infinite;
}

.login-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  text-align: center;
}

.login-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--subtext);
  text-align: center;
}

.login-reward {
  font-size: 36px;
  font-weight: 900;
  color: var(--text);
  background: linear-gradient(135deg, var(--peach), var(--yellow));
  border-radius: 20px;
  padding: 14px 32px;
  text-align: center;
}

.login-streak {
  font-size: 13px;
  font-weight: 700;
  color: var(--subtext);
}

.login-dots {
  display: flex;
  gap: 8px;
}

.login-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(180,160,200,0.2);
  border: 2px solid rgba(180,160,200,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.login-dot.filled {
  background: linear-gradient(135deg, var(--blush), var(--lavender));
  border-color: var(--blush);
}

/* ============ daily quests panel (home page) ============ */

.quest-panel {
  width: 100%;
  max-width: 340px;
  background: rgba(255,255,255,0.6);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.7);
  border-radius: 16px;
  padding: 11px 14px;
  border: 2px solid rgba(200,180,220,0.2);
  transition: all 0.2s;
}

.quest-item.done {
  opacity: 0.55;
  background: rgba(200,240,200,0.5);
  border-color: rgba(160,216,160,0.4);
}

.quest-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 34px;
  text-align: center;
}

.quest-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quest-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.quest-progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(180,160,200,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.quest-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--blush), var(--lavender));
  transition: width 0.4s ease;
}

.quest-reward {
  font-size: 12px;
  font-weight: 800;
  color: var(--subtext);
  flex-shrink: 0;
}

.quest-check {
  font-size: 18px;
  flex-shrink: 0;
}

.quest-claim-btn {
  font-size: 11px;
  font-weight: 900;
  color: white;
  background: var(--deep-pink);
  border: none;
  border-radius: 10px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.quest-claim-btn:hover { transform: scale(1.06); }
.quest-claim-btn:active { transform: scale(0.95); }

.quest-refresh {
  font-size: 11px;
  color: var(--subtext);
  text-align: center;
  font-weight: 600;
}

/* ============ pity counter on gacha page ============ */

.pity-bar-wrap {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pity-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--subtext);
}

.pity-label span:last-child {
  color: var(--text);
  font-weight: 900;
}

.pity-bar {
  width: 100%;
  height: 8px;
  background: rgba(180,160,200,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.pity-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--lavender), #FFB800);
  transition: width 0.5s ease;
}

.pity-soft {
  font-size: 11px;
  color: var(--subtext);
  text-align: center;
  font-weight: 600;
}

.pity-soft.active {
  color: #FF85A1;
  font-weight: 800;
}

/* ============ SFX coin pop ============ */

.coin-pop {
  position: fixed;
  font-size: 20px;
  font-weight: 900;
  color: #FFB800;
  pointer-events: none;
  z-index: 9999;
  animation: coinPop 0.8s ease-out forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

@keyframes coinPop {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  60%  { opacity: 1; transform: translateY(-36px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* ============ new keyframes ============ */

/* ============ lucky wheel (home page) ============ */

.wheel-panel {
  width: 100%;
  max-width: 340px;
  background: rgba(255,255,255,0.6);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.wheel-stage {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: var(--deep-pink);
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.wheel-disc {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 5px solid var(--white);
  box-shadow: 0 8px 24px rgba(150,100,160,0.25), inset 0 0 0 2px rgba(180,160,200,0.25);
  background: conic-gradient(
    var(--blush)     0deg   60deg,
    var(--yellow)    60deg  120deg,
    var(--mint)      120deg 180deg,
    var(--sky)       180deg 240deg,
    var(--lavender)  240deg 300deg,
    var(--peach)     300deg 360deg
  );
  position: relative;
  overflow: visible;
  transition: transform 3.2s cubic-bezier(0.12, 0.78, 0.13, 1);
}

.wheel-disc::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  top: 0; bottom: 0; left: 0; right: 0;
}

.wheel-label {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(255,255,255,0.6);
  transform-origin: 0 0;
  white-space: nowrap;
}

.wheel-spin-btn {
  width: 100%;
}

.wheel-cooldown {
  font-size: 12px;
  font-weight: 700;
  color: var(--subtext);
  text-align: center;
}

@keyframes wheelWinPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.wheel-disc.win-pulse {
  animation: wheelWinPulse 0.5s ease;
}
