/* ============================================================
   Word Play / Shabdon ka Khel — custom styles
   ============================================================ */

:root {
  --ink: #2b2140;
  --muted: #6b6285;
  --violet: #7c3aed;
  --violet-deep: #5b21b6;
  --pink: #ec4899;
  --pink-deep: #be185d;
  --yellow: #fbbf24;
  --teal: #14b8a6;
  --sky: #38bdf8;
  --soft: #f7f3ff;
  --line: #e9e2ff;
  --shadow: 0 22px 50px -28px rgba(76, 41, 145, 0.55);
  --shadow-soft: 0 10px 24px -16px rgba(76, 41, 145, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Fredoka', 'Baloo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background-color: #fdf8ff;
  background-image:
    radial-gradient(900px 460px at 8% -6%, #ffe6f4 0%, rgba(255, 230, 244, 0) 70%),
    radial-gradient(760px 420px at 96% 4%, #e2f7ff 0%, rgba(226, 247, 255, 0) 72%),
    radial-gradient(900px 520px at 50% 108%, #fff3d6 0%, rgba(255, 243, 214, 0) 72%),
    linear-gradient(180deg, #fffaf2 0%, #f7f1ff 46%, #eefcff 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.lang-hi {
  font-family: 'Baloo 2', 'Fredoka', system-ui, sans-serif;
}

/* ---------- Font families ---------- */
.font-fredoka { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; }
.font-comic { font-family: 'Comic Neue', 'Baloo 2', cursive; }
.font-pacifico { font-family: 'Pacifico', 'Baloo 2', cursive; }
.font-bubble { font-family: 'Rubik Bubbles', 'Baloo 2', cursive; }
.font-baloo { font-family: 'Baloo 2', 'Fredoka', system-ui, sans-serif; }

/* ---------- Background doodles ---------- */
.bg-doodles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.doodle {
  position: absolute;
  display: block;
  filter: blur(2px);
  opacity: 0.55;
  animation: floaty 14s ease-in-out infinite;
}
.doodle-1 {
  width: 190px; height: 190px; top: 8%; left: -70px; border-radius: 46% 54% 62% 38%;
  background: radial-gradient(circle at 35% 30%, #ffd1f0, #e9d5ff);
}
.doodle-2 {
  width: 150px; height: 150px; top: 30%; right: -50px; border-radius: 58% 42% 40% 60%;
  background: radial-gradient(circle at 60% 35%, #c9f2ff, #bfdbfe);
  animation-delay: -3s;
}
.doodle-3 {
  width: 120px; height: 120px; bottom: 14%; left: 4%; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #fef3c7, #fde68a);
  animation-delay: -6s;
}
.doodle-4 {
  width: 210px; height: 210px; bottom: -90px; right: 6%; border-radius: 40% 60% 55% 45%;
  background: radial-gradient(circle at 45% 35%, #d9fbe9, #a7f3d0);
  animation-delay: -9s;
}
.doodle-5, .doodle-6 {
  font-size: 2.4rem;
  filter: none;
  opacity: 0.5;
}
.doodle-5 { top: 18%; left: 6%; transform: rotate(-14deg); }
.doodle-6 { top: 62%; right: 5%; transform: rotate(12deg); animation-delay: -4s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-22px) rotate(6deg); }
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(120deg, rgba(124, 58, 237, 0.97), rgba(219, 39, 119, 0.95) 55%, rgba(249, 115, 22, 0.93));
  box-shadow: 0 14px 34px -20px rgba(76, 41, 145, 0.85);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 26px;
  border-bottom-right-radius: 26px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0 0.7rem;
}

.logo-badge {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  font-size: 1.6rem;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 0 -1px rgba(55, 20, 110, 0.35);
  transform: rotate(-6deg);
  animation: wiggle 5s ease-in-out infinite;
}

.brand-title {
  margin: 0;
  font-family: 'Rubik Bubbles', 'Baloo 2', cursive;
  font-size: clamp(1.35rem, 4.4vw, 1.85rem);
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 2px 0 rgba(76, 29, 149, 0.45);
}

.brand-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  max-width: 34ch;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
}

.lang-btn {
  border: 0;
  cursor: pointer;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lang-btn.is-active {
  background: #fff;
  color: var(--violet-deep);
  box-shadow: 0 4px 12px -4px rgba(40, 10, 90, 0.5);
}

/* ---------- Module nav ---------- */
.module-nav {
  background: rgba(255, 255, 255, 0.16);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}
.module-nav-inner {
  display: flex;
  gap: 0.45rem;
  padding-top: 0.55rem;
  padding-bottom: 0.65rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.module-nav-inner::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.tab-btn:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.tab-btn.is-active {
  background: #fff;
  color: var(--violet-deep);
  box-shadow: 0 8px 18px -10px rgba(30, 0, 70, 0.8);
  transform: translateY(-1px);
}
.tab-icon { font-size: 1.05rem; line-height: 1; }
.tab-btn.is-active .tab-icon { animation: pop 0.45s ease; }

/* ============================================================
   PANELS + CARDS
   ============================================================ */
main { position: relative; z-index: 1; }

.module-panel { animation: panel-in 0.38s ease both; }
.module-panel[hidden] { display: none !important; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid #fff;
  border-radius: 30px;
  padding: clamp(1.1rem, 3.5vw, 2rem);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
}

.emoji-bubble {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.7rem;
  border-radius: 20px;
  background: linear-gradient(150deg, #f3e8ff, #ffe4f1);
  border: 2px solid #fff;
  box-shadow: 0 8px 18px -12px rgba(124, 58, 237, 0.8);
  transform: rotate(-4deg);
}

.module-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--violet);
  background: #f1e9ff;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  margin-bottom: 0.3rem;
}

.module-title {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  line-height: 1.15;
  color: var(--ink);
}

.module-desc {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 58ch;
}

.sub-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.field { margin-top: 0.4rem; }

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #5a5073;
  margin-bottom: 0.45rem;
}
.field-label.mb-0 { margin-bottom: 0; }

.input,
.textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--soft);
  border: 2.5px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.input::placeholder,
.textarea::placeholder { color: #a79ec2; }
.input:focus,
.textarea:focus {
  border-color: #c4b5fd;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
}
.input:focus-visible,
.textarea:focus-visible,
button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.textarea { resize: vertical; min-height: 6rem; line-height: 1.6; }
.textarea-code {
  font-family: 'Comic Neue', 'Baloo 2', monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #f2fbf8;
  border-color: #c9f2e6;
  word-break: break-word;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.35rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  box-shadow: 0 5px 0 0 rgba(0, 0, 0, 0.16), 0 12px 22px -14px rgba(60, 20, 120, 0.8);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.16); }
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.btn-primary { background: linear-gradient(140deg, #8b5cf6, #d946ef 60%, #ec4899); }
.btn-teal { background: linear-gradient(140deg, #2dd4bf, #14b8a6 55%, #0d9488); }
.btn-yellow {
  background: linear-gradient(140deg, #fcd34d, #fbbf24 55%, #f59e0b);
  color: #4a2c00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-light {
  background: #fff;
  color: var(--violet-deep);
  border: 2.5px solid #ece4ff;
  box-shadow: 0 4px 0 0 #ece4ff, 0 10px 18px -14px rgba(60, 20, 120, 0.5);
}
.btn-light:active:not(:disabled) { box-shadow: 0 1px 0 0 #ece4ff; }
.btn-light:disabled { opacity: 0.6; }

.btn-ghost,
.btn-ghost-dark {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--violet);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.btn-ghost:hover:not(:disabled) { background: #f3ebff; }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost-dark {
  background: rgba(255, 255, 255, 0.9);
  color: var(--violet-deep);
  border: 2px solid #f0e7ff;
  box-shadow: 0 4px 12px -8px rgba(60, 20, 120, 0.6);
}
.btn-ghost-dark:hover:not(:disabled) { background: #fff; }
.btn-ghost-dark:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   MODULE 1 — output + fonts + history
   ============================================================ */
.output-card {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: clamp(1.1rem, 4vw, 1.8rem);
  background:
    radial-gradient(600px 220px at 12% 0%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%),
    linear-gradient(135deg, #7c3aed 0%, #c026d3 55%, #ec4899 100%);
  color: #fff;
  text-align: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22), 0 22px 40px -26px rgba(124, 58, 237, 0.9);
}
.output-card::after {
  content: '✨';
  position: absolute;
  top: 0.5rem;
  right: 0.9rem;
  font-size: 1.3rem;
  opacity: 0.75;
  animation: twinkle 3s ease-in-out infinite;
}
.output-card-light {
  background: linear-gradient(140deg, #f5f0ff, #fff1f8 60%, #eefcff);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 0 0 2.5px #efe7ff, var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.output-card-light::after { content: none; }
.output-card-light:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 2.5px #e6dbff, 0 18px 30px -22px rgba(60, 20, 120, 0.7); }
.output-card-light:active { transform: translateY(1px); }

.output-label {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
}
.output-label-dark { color: var(--muted); opacity: 1; }

.output-text {
  font-size: clamp(2rem, 8vw, 3.6rem);
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 1.2em;
  padding: 0.15rem 0;
  text-shadow: 0 3px 0 rgba(66, 20, 120, 0.25);
}
.output-text.is-placeholder {
  font-size: clamp(1rem, 3.2vw, 1.15rem);
  font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
  font-weight: 500;
  opacity: 0.8;
  text-shadow: none;
}
.output-text.pop { animation: pop 0.4s ease; }

.font-picker { text-align: left; }
.font-picker-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.font-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.font-chip {
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.45rem 0.9rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}
.font-chip:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.font-chip.is-active {
  background: #fff;
  color: var(--violet-deep);
  border-color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -10px rgba(40, 10, 80, 0.9);
}

/* ---------- History ---------- */
.history-block {
  margin-top: 1.6rem;
  padding-top: 1.3rem;
  border-top: 2px dashed #eee6ff;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.history-item {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}
.history-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  background: #faf7ff;
  border: 2px solid #f0e9ff;
  border-radius: 16px;
  padding: 0.6rem 0.9rem;
  font-family: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.history-main:hover { background: #f4edff; border-color: #e2d4ff; transform: translateX(2px); }
.history-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-orig {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
.history-del {
  flex: 0 0 auto;
  width: 2.4rem;
  border: 2px solid #ffe1ea;
  background: #fff5f8;
  color: #be185d;
  border-radius: 14px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.16s ease, transform 0.16s ease;
}
.history-del:hover { background: #ffe4ec; transform: scale(1.04); }

.empty-note {
  margin: 0.2rem 0 0;
  padding: 1.1rem;
  text-align: center;
  font-size: 0.92rem;
  color: var(--muted);
  background: #faf8ff;
  border: 2px dashed #e7dfff;
  border-radius: 18px;
}

/* ============================================================
   SEGMENTED CONTROLS
   ============================================================ */
.seg {
  display: inline-flex;
  padding: 0.25rem;
  gap: 0.25rem;
  background: #f3edff;
  border-radius: 999px;
  border: 2px solid #ece3ff;
  flex-wrap: wrap;
}
.seg-btn {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b5f8c;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.seg-btn:hover { color: var(--violet-deep); }
.seg-btn.is-active {
  background: var(--violet);
  color: #fff;
  box-shadow: 0 6px 14px -8px rgba(124, 58, 237, 0.9);
}
.seg-sky .seg-btn.is-active {
  background: linear-gradient(140deg, #38bdf8, #0ea5e9);
  box-shadow: 0 6px 14px -8px rgba(14, 165, 233, 0.9);
}
.seg .seg-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   MODULE 2
   ============================================================ */
.difficulty-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.scramble-panel {
  text-align: center;
  border-radius: 26px;
  padding: 1.5rem 1rem;
  background:
    radial-gradient(500px 200px at 85% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 70%),
    linear-gradient(150deg, #eef7ff, #f7f0ff 55%, #fff2f9);
  border: 2.5px solid #fff;
  box-shadow: inset 0 0 0 2px #eef0ff, var(--shadow-soft);
}
.scramble-panel .output-label { color: var(--muted); opacity: 1; }

.scramble-word {
  font-family: 'Rubik Bubbles', 'Baloo 2', cursive;
  font-size: clamp(1.9rem, 8vw, 3.2rem);
  line-height: 1.25;
  letter-spacing: 0.12em;
  color: var(--violet-deep);
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0.35rem 0 0;
  text-shadow: 0 3px 0 #e7dbff;
}
.scramble-word.shuffle { animation: pop 0.45s ease; }

.hint-text {
  display: inline-block;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7c5c00;
  background: #fff6d6;
  border: 2px solid #ffe9a3;
  border-radius: 14px;
  padding: 0.45rem 0.85rem;
  letter-spacing: 0.05em;
}

.feedback {
  min-height: 1.6rem;
  margin: 0.9rem 0 0;
  font-size: 0.98rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}
.feedback.is-ok { color: #0f766e; animation: pop 0.4s ease; }
.feedback.is-warn { color: #b91c1c; }
.feedback.shake { animation: shake 0.45s ease; }

.score-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  background: #f1fbf8;
  border: 2px solid #d3f4ec;
  border-radius: 16px;
  padding: 0.5rem 0.95rem;
}
.score-pill-alt { background: #fff8e8; border-color: #ffe8b0; }
.score-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f766e;
}
.score-pill-alt .score-num { color: #b45309; }
.score-label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   MODULE 3
   ============================================================ */
.controls-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.control-block { display: grid; gap: 0.45rem; align-content: start; }

.shift-box {
  margin-top: 1rem;
  padding: 1rem;
  background: #faf7ff;
  border: 2.5px solid #f0e8ff;
  border-radius: 20px;
  transition: opacity 0.18s ease, filter 0.18s ease;
}
.shift-box.is-disabled { opacity: 0.5; filter: grayscale(0.4); }
.shift-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.shift-val {
  font-family: 'Rubik Bubbles', 'Baloo 2', cursive;
  font-size: 1.15rem;
  color: #fff;
  background: var(--violet);
  border-radius: 10px;
  padding: 0.1rem 0.65rem;
  min-width: 2.6rem;
  text-align: center;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c4b5fd, #f0abfc, #fbcfe8);
  outline: none;
  cursor: pointer;
}
.slider:disabled { cursor: not-allowed; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #c4b5fd 70%);
  border: 3px solid #7c3aed;
  box-shadow: 0 4px 10px -4px rgba(76, 29, 149, 0.8);
  transition: transform 0.15s ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.08); }
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #7c3aed;
  box-shadow: 0 4px 10px -4px rgba(76, 29, 149, 0.8);
}
.slider::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c4b5fd, #f0abfc, #fbcfe8);
}

.info-note {
  margin: 0.85rem 0 0;
  font-size: 0.86rem;
  color: #5b6b7c;
  background: #f0f9ff;
  border: 2px solid #dbeafe;
  border-radius: 14px;
  padding: 0.6rem 0.9rem;
  line-height: 1.5;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #0f766e;
  background: #ecfdf5;
  border: 1.5px solid #bbf7d0;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  margin-bottom: 0.45rem;
}
.live-dot .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ============================================================
   MODULE 4
   ============================================================ */
.dice-zone {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.dice-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.words-panel {
  background: linear-gradient(150deg, #fff9ec, #fff4f9);
  border: 2.5px solid #fff;
  border-radius: 22px;
  padding: 1rem;
  box-shadow: inset 0 0 0 2px #ffefd6;
}
.words-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.words-progress {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a16207;
  background: #fff5d6;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.word-chip-row { display: flex; flex-wrap: wrap; gap: 0.55rem; }

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #7c2d12;
  background: #fff;
  border: 2.5px solid #fde68a;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.word-chip::before {
  content: '☆';
  font-size: 0.95rem;
  color: #f59e0b;
  line-height: 1;
}
.word-chip.is-used {
  background: linear-gradient(140deg, #34d399, #10b981);
  border-color: #059669;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 18px -12px rgba(5, 150, 105, 0.9);
}
.word-chip.is-used::before { content: '✓'; color: #fff; }
.word-chip.roll-in { animation: chip-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

@keyframes chip-in {
  0% { opacity: 0; transform: translateY(10px) scale(0.7) rotate(-6deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

.story-list { display: grid; gap: 0.75rem; }
.story-card {
  background: #fbf9ff;
  border: 2.5px solid #f0e9ff;
  border-radius: 20px;
  padding: 0.9rem 1rem;
  animation: panel-in 0.3s ease both;
}
.story-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.story-date {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}
.story-words { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.story-word-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: #7c3aed;
  background: #f1e9ff;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}
.story-text {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.65;
  color: #40365c;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.story-del {
  border: 2px solid #ffe1ea;
  background: #fff5f8;
  color: #be185d;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease;
}
.story-del:hover { background: #ffe4ec; }

/* ============================================================
   MODULE 5
   ============================================================ */
.transform-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.transform-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-start;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: #4c3f6b;
  background: #fff;
  border: 2.5px solid #ece4ff;
  border-radius: 16px;
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.transform-btn:hover { transform: translateY(-2px); border-color: #d8c7ff; box-shadow: 0 8px 16px -12px rgba(76, 41, 145, 0.7); }
.transform-btn.is-active {
  background: linear-gradient(140deg, #f5edff, #ffeaf6);
  border-color: #c4b5fd;
  color: var(--violet-deep);
  box-shadow: inset 0 0 0 1.5px #fff, 0 8px 18px -14px rgba(76, 41, 145, 0.8);
}
.tb-emoji { font-size: 1.05rem; line-height: 1; }

.tap-hint {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #9a8fb8;
  text-transform: uppercase;
}

.m5-output {
  margin-top: 0.55rem;
  font-size: clamp(1.15rem, 3.6vw, 1.6rem);
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 2.6em;
  white-space: pre-wrap;
}
.m5-output.is-placeholder {
  font-size: 0.95rem;
  font-weight: 500;
  color: #a79ec2;
  white-space: normal;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  margin-top: 2rem;
  background: linear-gradient(140deg, #2b2140, #3b1f52 55%, #1f2b45);
  color: #fff;
  border-top-left-radius: 34px;
  border-top-right-radius: 34px;
  box-shadow: 0 -18px 40px -30px rgba(30, 10, 60, 0.9);
}
.footer-credit {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.9;
  color: #f1ecff;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.footer-link {
  color: #fde68a;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px dotted rgba(253, 230, 138, 0.6);
  padding-bottom: 1px;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.footer-link:hover {
  color: #fff;
  border-bottom-color: #fff;
}
.oss-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.9rem 0 0;
  padding: 0.35rem 0.95rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #d9f7ea;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
.oss-badge::before { content: '🌐'; font-size: 0.85rem; }

.flag-counter {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  padding: 0.5rem 1rem 1.25rem;
  background: #1f2b45;
}
.flag-counter a { display: inline-flex; }
.flag-counter img {
  height: 24px;
  width: auto;
  max-width: 100%;
  border-radius: 6px;
  opacity: 0.9;
}

/* ============================================================
   CONFETTI + TOAST
   ============================================================ */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -14px;
  border-radius: 3px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.3, 0.7, 0.6, 1);
  animation-fill-mode: forwards;
  will-change: transform, opacity;
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, -10px, 0) rotate(var(--rot, 0deg)); opacity: 1; }
  100% { transform: translate3d(var(--drift, 20px), 105vh, 0) rotate(calc(var(--rot, 0deg) + 540deg)); opacity: 0.9; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 24px);
  z-index: 70;
  max-width: min(92vw, 26rem);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: #2b2140;
  box-shadow: 0 18px 34px -18px rgba(20, 5, 45, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: linear-gradient(140deg, #0f766e, #059669); }
.toast-warn { background: linear-gradient(140deg, #b91c1c, #dc2626); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pop {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(5deg); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.9) rotate(-6deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(6deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes dice-roll {
  0% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(200deg) scale(1.18); }
  70% { transform: rotate(340deg) scale(0.94); }
  100% { transform: rotate(360deg) scale(1); }
}
.dice-rolling { display: inline-block; animation: dice-roll 0.6s ease-in-out; }

/* ============================================================
   RESPONSIVE + MOTION PREFERENCES
   ============================================================ */
@media (max-width: 640px) {
  .header-top { align-items: flex-start; }
  .brand-subtitle { display: none; }
  .logo-badge { width: 2.5rem; height: 2.5rem; font-size: 1.3rem; border-radius: 14px; }
  .lang-btn { padding: 0.4rem 0.6rem; font-size: 0.78rem; }
  .card { border-radius: 24px; }
  .output-card { border-radius: 22px; }
  .history-orig { display: none; }
  .site-footer { border-top-left-radius: 26px; border-top-right-radius: 26px; }
}

@media (max-width: 380px) {
  .tab-label { font-size: 0.8rem; }
  .tab-btn { padding: 0.45rem 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .doodle { animation: none; }
}
