/* Encapsulated Q-mode skin: blush palette, chibi animals, basket, edge companions. */
body.q-mode {
  --canvas: #fbecef;
  --primary: #c45c7a;
  --primary-hover: #b14e6c;
  --success: #c45c7a;
  --success-bg: #f8e6ec;
  --success-border: #ecc3d0;
  --danger: #b56a62;
  --danger-bg: #f7ece8;
  --danger-border: #ebcfc8;
  --warning: #c4895a;
  --warning-bg: #f8efe4;
  --card-bg: #fff8fa;
  --border: #f0d5de;
  --text: #5a3944;
  --text-secondary: #8a5d6a;
  --text-muted: #b38895;
  --shadow-sm: 0 1px 2px rgba(180, 88, 110, .08);
  --shadow-md: 0 10px 28px rgba(180, 88, 110, .12);
  background:
    radial-gradient(1000px 480px at 6% -10%, rgba(244, 176, 196, .35), transparent 56%),
    radial-gradient(860px 420px at 110% 0%, rgba(255, 214, 186, .32), transparent 54%),
    var(--canvas);
}
body.q-mode .topbar { z-index: 50; }
body.q-mode main { padding-bottom: 240px; }
body.q-mode .sentence-grid { gap: 28px 16px; padding-top: 10px; overflow: visible; }
body.q-mode .sentence-container { padding-top: 28px; }
body.q-mode .sentence-container.q-collected {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card-bg);
  flex: 0 0 auto;
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-btn.is-active {
  background: var(--primary);
  color: #fff;
}
.mode-btn:not(.is-active):hover { background: rgba(196, 92, 122, .08); }

.q-perch {
  position: absolute;
  top: -22px;
  left: 16px;
  z-index: 3;
  pointer-events: none;
}
.q-perch-empty {
  width: 40px;
  height: 16px;
  border-radius: 999px;
  background: rgba(196, 92, 122, .12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}

.q-chibi {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 2px 2px rgba(120, 60, 80, .14));
}
.q-perch-pet { pointer-events: none; animation: q-bob 2.4s ease-in-out infinite; }
.q-chibi-head {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  z-index: 1;
}

.q-dock {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 40;
  width: min(920px, calc(100vw - 32px));
  background: rgba(255, 248, 250, .94);
  border: 1px solid var(--border, #f0d5de);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgba(180, 88, 110, .16);
  padding: 12px 14px 14px;
  gap: 8px;
  flex-direction: column;
  pointer-events: none;
  overflow: visible;
}
body.q-mode .q-dock { display: flex; }
.q-basket-wrap,
.q-basket,
.q-release,
.q-basket .q-chibi {
  pointer-events: auto;
}
.q-hint {
  min-height: 1.2em;
  margin: 0;
  font-size: .8rem;
  color: var(--text-secondary, #8a5d6a);
  pointer-events: none;
}
.q-basket-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.q-basket-label {
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 700;
  color: var(--primary, #c45c7a);
  white-space: nowrap;
}
#q-cap {
  display: block;
  margin-top: 2px;
  font-weight: 600;
  color: var(--text-muted, #b38895);
}
.q-basket {
  flex: 1;
  min-height: 96px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 14px 12px;
  border-radius: 18px;
  background:
    linear-gradient(#fff6f8, #fff6f8) padding-box,
    linear-gradient(180deg, #f4c4d0, #e8a8b8) border-box;
  border: 2px solid transparent;
}
.q-basket::before {
  content: "";
}
.q-release {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--primary, #c45c7a);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.q-release:hover { background: var(--primary-hover, #b14e6c); }
.q-hint-pop { animation: q-hint-pop .45s ease; }

.q-edges { pointer-events: none; }
body.q-mode .q-edges { pointer-events: auto; }
.q-companion { pointer-events: auto; animation: q-bob 2.8s ease-in-out infinite; }

.q-bubble {
  position: fixed;
  transform: translate(-50%, -100%);
  background: #fff;
  color: #7a4454;
  border: 1px solid #f0d5de;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  z-index: 96;
  pointer-events: none;
  box-shadow: 0 6px 14px rgba(180, 88, 110, .16);
}
.q-match-burst {
  position: fixed;
  transform: translate(-50%, -100%);
  z-index: 97;
  pointer-events: none;
  font-size: 18px;
  font-weight: 800;
  color: #c45c7a;
  text-shadow: 0 2px 0 #fff;
  animation: q-match-burst .7s ease-out forwards;
}
.q-chibi.q-clearing {
  animation: q-clear .5s cubic-bezier(.16,.84,.32,1) forwards;
  pointer-events: none;
}
.q-lose {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(90, 40, 55, .28);
}
.q-lose-card {
  width: min(380px, calc(100vw - 40px));
  background: #fff8fa;
  border: 1px solid #f0d5de;
  border-radius: 20px;
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(180, 88, 110, .2);
}
.q-lose-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #c45c7a;
  margin-bottom: 8px;
}
.q-lose-copy {
  font-size: .88rem;
  color: #8a5d6a;
  line-height: 1.5;
  margin-bottom: 16px;
}
#q-retry {
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: #c45c7a;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
#q-retry:hover { background: #b14e6c; }

.q-spark {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  font-size: 14px;
  color: #d46a8a;
  animation: q-spark .55s ease-out forwards;
}

.q-flying { pointer-events: none; }
.q-arrive { animation: q-land .45s cubic-bezier(.16,.9,.32,1); }
.q-hop { animation: q-hop .5s ease; }
.q-spin { animation: q-spin .55s ease; }
.q-nuzzle { animation: q-nuzzle .5s ease; }
.q-wiggle { animation: q-wiggle .45s ease; }

@keyframes q-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes q-land {
  from { transform: translateY(-10px) scale(.7); opacity: .4; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes q-hop {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-14px) rotate(-8deg); }
  70% { transform: translateY(-2px) rotate(6deg); }
}
@keyframes q-spin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}
@keyframes q-nuzzle {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.18) rotate(-8deg); }
}
@keyframes q-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
@keyframes q-spark {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(.4); }
}
@keyframes q-clear {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  35% { transform: scale(1.35) rotate(-18deg); }
  100% { transform: scale(0) rotate(40deg) translateY(-18px); opacity: 0; }
}
@keyframes q-match-burst {
  from { opacity: 1; transform: translate(-50%, -100%) scale(.7); }
  40% { opacity: 1; transform: translate(-50%, -130%) scale(1.15); }
  to { opacity: 0; transform: translate(-50%, -170%) scale(.9); }
}

@media (prefers-reduced-motion: reduce) {
  .q-perch-pet, .q-companion, .q-arrive, .q-hop, .q-spin, .q-nuzzle, .q-wiggle, .q-spark, .q-hint-pop, .q-clearing, .q-match-burst {
    animation: none;
  }
}
