/* MyFlipCards — one stylesheet. Colour palettes are set with <html data-palette="…">. */

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/fredoka-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/fredoka-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ palettes */
:root, [data-palette="sky"] {
  color-scheme: light;
  --bg1: #8ec5ff; --bg2: #b9a8ff; --bg3: #ffd3ec;
  --ink: #1d2340; --muted: #5d6685; --line: rgba(29, 35, 64, .12);
  --panel: rgba(255, 255, 255, .9); --panel-solid: #fff;
  --accent: #4f6dff; --accent-ink: #fff; --accent2: #ff7a59;
  --back1: #4f7cff; --back2: #8a5cff; --face: #fff; --face-ink: #1d2340;
  --match: #22c55e; --miss: #ff4d5e; --chip: #eef1ff; --chip-ink: #2b3566; --sel: #4f6dff;
  --shadow: 0 6px 22px rgba(40, 50, 120, .16);
  --radius: 22px;
}
[data-palette="candy"] {
  --bg1: #ffb3d9; --bg2: #d4b3ff; --bg3: #ffe7b8;
  --accent: #e2337f; --back1: #ff5fa8; --back2: #a45cff; --sel: #e2337f; --chip: #fff0f7; --chip-ink: #6b1f4a;
}
[data-palette="jungle"] {
  --bg1: #a8e6a1; --bg2: #79d2c0; --bg3: #fff2a8;
  --accent: #129062; --back1: #27b07a; --back2: #0f7a66; --sel: #129062; --chip: #e8f8ef; --chip-ink: #134d38;
}
[data-palette="sunset"] {
  --bg1: #ffcf8b; --bg2: #ff9b8b; --bg3: #ffd0e6;
  --accent: #f0571c; --back1: #ff8a3d; --back2: #ff4b6e; --sel: #f0571c; --chip: #fff2e9; --chip-ink: #6b2a12;
}
[data-palette="night"] {
  color-scheme: dark;
  --bg1: #141a35; --bg2: #24164d; --bg3: #0b2b3d;
  --ink: #eef1ff; --muted: #a8afd6; --line: rgba(255, 255, 255, .12);
  --panel: rgba(31, 37, 74, .9); --panel-solid: #1f254a;
  --accent: #7d9bff; --accent-ink: #0e1330; --back1: #5468ff; --back2: #ad4bff;
  --face: #262d58; --face-ink: #f1f3ff; --chip: #2b3366; --chip-ink: #e1e6ff; --sel: #7d9bff;
  --shadow: 0 6px 26px rgba(0, 0, 0, .45);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: Fredoka, Nunito, 'Trebuchet MS', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg1);
  background-image:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--bg3) 85%, transparent) 0 18%, transparent 42%),
    radial-gradient(circle at 88% 82%, color-mix(in srgb, var(--bg3) 70%, transparent) 0 14%, transparent 40%),
    linear-gradient(150deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
img { user-select: none; -webkit-user-drag: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
#app { min-height: 100dvh; }
.empty { min-height: 60dvh; display: grid; place-content: center; gap: 12px; text-align: center; padding: 24px; font-size: 1.15rem; }

/* emoji pictures */
.emo { display: block; object-fit: contain; }
.emo-native { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif; line-height: 1; display: inline-block; text-align: center; }
canvas.emo.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ------------------------------------------------------------------ buttons, chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: 14px; border: 0;
  background: var(--chip); color: var(--chip-ink); font-weight: 600;
  box-shadow: 0 3px 0 var(--line);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn.big { min-height: 52px; font-size: 1.15rem; padding: 10px 22px; border-radius: 16px; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn.danger { background: #ffe3e6; color: #a1122a; }
.btn .emo { width: 24px; height: 24px; }
.btn.big .emo { width: 28px; height: 28px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--panel); box-shadow: 0 3px 0 var(--line); font-size: 1.2rem; font-weight: 700;
}
.icon-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.icon-btn:disabled { opacity: .45; }
.icon-btn .emo { width: 26px; height: 26px; }
.icon-btn .emo-native { font-size: 22px; }
.svg-icon { display: grid; place-items: center; color: var(--ink); }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--accent2); color: #fff; font-size: 11px; line-height: 18px;
}
.round-btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--panel);
  font-size: 2rem; font-weight: 700; line-height: 1; box-shadow: var(--shadow); color: var(--ink);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: 999px; border: 2px solid transparent; background: var(--chip); color: var(--chip-ink); font-weight: 600;
  transition: transform .12s, border-color .12s, background .12s;
}
.chip .emo { width: 22px; height: 22px; }
.chip small { display: block; font-size: .72rem; font-weight: 500; opacity: .75; }
.chip.sel { border-color: var(--sel); background: color-mix(in srgb, var(--sel) 16%, var(--panel-solid)); }
.chip.dim:not(.sel) { opacity: .6; }
.chip:disabled { opacity: .35; text-decoration: line-through; }
.chip:active:not(:disabled) { transform: scale(.96); }
.seg { display: flex; gap: 6px; }

/* ------------------------------------------------------------------ boot */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 16px; font-weight: 700; font-size: 1.4rem; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.boot-cards { display: flex; gap: 10px; }
.boot-cards span { width: 40px; height: 54px; border-radius: 9px; background: linear-gradient(145deg, var(--back1), var(--back2)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .4); animation: bootFlip 1.4s ease-in-out infinite; }
.boot-cards span:nth-child(2) { animation-delay: .15s; }
.boot-cards span:nth-child(3) { animation-delay: .3s; }
@keyframes bootFlip { 0%, 60%, 100% { transform: rotateY(0); } 30% { transform: rotateY(180deg); } }

/* ------------------------------------------------------------------ home */
.home { max-width: 1240px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .14), 0 0 18px color-mix(in srgb, var(--accent) 40%, transparent); letter-spacing: .5px; }
.tagline { margin: 4px 0 0; color: #fff; font-weight: 500; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); font-size: clamp(.85rem, 2.6vw, 1rem); }
[data-palette="night"] .brand h1, [data-palette="night"] .tagline { color: var(--ink); }
.logo { position: relative; width: 56px; height: 56px; flex: none; }
.logo .lc { position: absolute; width: 36px; height: 48px; border-radius: 9px; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0, 0, 0, .2); }
.logo .lc1 { left: 0; top: 4px; background: #fff; rotate: -12deg; }
.logo .lc1 .emo { width: 26px; height: 26px; }
.logo .lc2 { right: 0; top: 2px; background: linear-gradient(145deg, var(--back1), var(--back2)); color: #fff; font-weight: 700; font-size: 1.5rem; rotate: 10deg; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45), 0 3px 8px rgba(0, 0, 0, .2); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lang-toggle { min-height: 44px; background: var(--panel); }
@media (max-width: 560px) {
  .home-top { align-items: flex-start; }
  .logo { width: 46px; height: 46px; }
  .logo .lc { width: 30px; height: 40px; }
  .logo .lc2 { font-size: 1.2rem; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 1.55rem; }
  .tagline { font-size: .8rem; max-width: 46vw; }
  .top-actions { gap: 6px; }
  .top-actions .icon-btn, .lang-toggle { width: 40px; height: 40px; min-height: 40px; padding: 0; justify-content: center; }
}

.home-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.side { display: grid; gap: 16px; align-content: start; }
@media (min-width: 1000px) {
  .home-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
}
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.modes-panel { scroll-margin-top: 12px; }
.panel h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.25rem; }
.panel h2.sub { margin-top: 18px; }
.panel h3 { margin: 14px 0 8px; font-size: .95rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .95rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px 12px; border-radius: 18px; border: 2px solid transparent; text-align: center;
  background: color-mix(in srgb, var(--c, var(--accent)) 15%, var(--panel-solid));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--c, var(--accent)) 30%, transparent);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: translateY(1px); }
.tile.sel { border-color: var(--c, var(--sel)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--sel)) 35%, transparent), 0 6px 14px rgba(0, 0, 0, .12); }
.tile.sel::after { content: '✓'; position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--c, var(--sel)); color: #fff; font-size: 13px; line-height: 22px; font-weight: 700; }
.tile-icon .emo { width: 48px; height: 48px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .15)); }
.tile.sel .tile-icon .emo { animation: wiggle .6s ease; }
.tile-name { font-weight: 600; line-height: 1.15; }
.tile-meta { font-size: .75rem; color: var(--muted); line-height: 1.2; }
.progress { width: 70%; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); overflow: hidden; margin-top: 3px; }
.progress i { display: block; height: 100%; background: var(--c, var(--accent)); border-radius: 3px; }
.theme-group + .theme-group { margin-top: 6px; }

.tiles.modes { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mode-tile { --c: var(--accent); padding: 10px 8px 12px; }
.mode-icons { display: flex; align-items: center; gap: 4px; }
.mode-icons .emo { width: 34px; height: 34px; }
.mode-icons .plus { font-weight: 700; color: var(--muted); }

.options { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 10px; }
.options summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style-position: inside; }
.opt { display: grid; gap: 6px; margin: 10px 0; }
.opt > label { font-weight: 600; font-size: .9rem; color: var(--muted); }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.names input { min-height: 40px; border-radius: 12px; border: 2px solid var(--line); padding: 6px 10px; background: var(--panel-solid); }

.play-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 16px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .1); border-radius: 22px 22px 0 0;
}
.summary { display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: none; padding: 0; text-align: left; color: var(--ink); }
.summary .emo { width: 40px; height: 40px; }
.summary b, .summary small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary small { color: var(--muted); }
.play-actions { display: flex; gap: 8px; flex: none; }
.play-btn { padding-inline: 26px; }
.home-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 12px 0 18px; margin: 0; }
@media (max-width: 640px) {
  .play-bar { flex-wrap: wrap; gap: 6px 10px; padding-top: 8px; }
  .summary { width: 100%; gap: 8px; }
  .summary .emo { width: 26px; height: 26px; }
  .summary b { display: inline; margin-right: 6px; }
  .summary small { display: inline; }
  .summary > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .play-actions { flex: 1; }
  .play-btn { flex: 1; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .tile-icon .emo { width: 40px; height: 40px; }
  .panel { padding: 12px; border-radius: 18px; }
}

/* ------------------------------------------------------------------ game */
.game { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.game-bar {
  display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
}
.game-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.gt-icon .emo { width: 36px; height: 36px; }
.gt-text { min-width: 0; }
.gt-text b, .gt-text small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-text b { font-size: 1.05rem; }
.gt-text small { color: var(--muted); font-size: .8rem; }
.game-bar .gt-text, .learn-top .gt-text { background: color-mix(in srgb, var(--panel) 75%, transparent); padding: 3px 10px; border-radius: 12px; }
.game-stats { display: flex; gap: 6px; }
.stat {
  display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px; border-radius: 12px;
  background: var(--panel); font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 3px 0 var(--line);
}
.stat .emo { width: 22px; height: 22px; }
.stat.time.warn { background: #ffe1e1; color: #b3122a; animation: pulse 1s infinite; }
.game-actions { display: flex; gap: 6px; }
@media (max-width: 720px) {
  .game-bar { flex-wrap: wrap; }
  .game-title { order: 1; flex: 1 1 calc(100% - 160px); }
  .game-actions { order: 2; }
  .game-stats { order: 3; width: 100%; justify-content: center; }
  .stat { height: 34px; }
  .gt-icon { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-bar { flex-wrap: nowrap; padding-top: 4px; }
  .game-stats { width: auto; order: 2; }
  .gt-text small { display: none; }
}

.players { display: flex; justify-content: center; gap: 8px; padding: 0 10px 4px; flex-wrap: wrap; }
.player {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px;
  background: var(--panel); border: 3px solid transparent; font-weight: 600; opacity: .7; transition: all .2s;
}
.player .emo { width: 26px; height: 26px; }
.player b { min-width: 18px; text-align: center; color: var(--pc); font-size: 1.1rem; }
.player.active { border-color: var(--pc); opacity: 1; transform: scale(1.06); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 25%, transparent); }
.pname { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board-area { flex: 1; min-height: 0; display: grid; place-items: center; padding-bottom: env(safe-area-inset-bottom); }
.board { display: grid; justify-content: center; align-content: center; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* cards */
.card {
  position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none;
  perspective: 1000px; container-type: size; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  border-radius: 14px;
}
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.34, 1.36, .5, 1); }
.card.up .card-inner, .card.matched .card-inner { transform: rotateY(180deg); }
.card-back, .card-front {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: clamp(8px, 9cqmin, 18px);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.card-back {
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--back1), var(--back2));
  box-shadow: inset 0 0 0 clamp(2px, 2.6cqmin, 5px) rgba(255, 255, 255, .38), 0 4px 0 rgba(0, 0, 0, .14), 0 7px 14px rgba(0, 0, 0, .14);
  transition: filter .15s;
}
.card-back::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .2) 14%, transparent 16%), radial-gradient(rgba(255, 255, 255, .12) 14%, transparent 16%);
  background-size: 18cqmin 18cqmin; background-position: 0 0, 9cqmin 9cqmin;
}
.emblem {
  position: relative; display: grid; place-items: center; width: 50cqmin; height: 50cqmin; border-radius: 30%;
  background: rgba(255, 255, 255, .95); box-shadow: 0 3px 0 rgba(0, 0, 0, .12); rotate: -7deg;
}
.emblem-q { font-weight: 700; font-size: 38cqmin; line-height: 1; color: var(--back2); }
.emblem .emo { width: 72%; height: 72%; }
.card:hover:not(.up):not(.matched) .card-back { filter: brightness(1.08); }
.card:active:not(.matched) .card-inner { scale: .96; }
.card-front {
  transform: rotateY(180deg); background: var(--face); color: var(--face-ink);
  box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 rgba(0, 0, 0, .1), 0 7px 14px rgba(0, 0, 0, .12);
}
.face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqmin; padding: 7cqmin; text-align: center; }
.face .pic { flex: 1 1 auto; width: 100%; min-height: 0; }
.word, .def {
  font-weight: 600; line-height: 1.12; overflow-wrap: break-word; hyphens: manual;
  font-size: min(calc(var(--fw, 20) * 1cqw), calc(var(--fh, 20) * 1cqh), 72px);
}
.def { font-weight: 500; line-height: 1.18; }
.face-def { background: color-mix(in srgb, var(--accent) 8%, var(--face)); }
.face-es { background: linear-gradient(180deg, #fff6e0, #fff); color: #8a1c12; }
[data-palette="night"] .face-es { background: linear-gradient(180deg, #3a2d1f, var(--face)); color: #ffd7a8; }
.lang-tag { position: absolute; top: 5cqmin; left: 5cqmin; padding: .5cqmin 3cqmin; border-radius: 99px; font-size: max(9px, 9cqmin); font-weight: 700; color: #fff; background: linear-gradient(180deg, #c60b1e 0 25%, #f1bf00 25% 75%, #c60b1e 75%); text-shadow: 0 1px 1px rgba(0, 0, 0, .5); }
.face-audio .speaker .emo { width: 52cqmin; height: 52cqmin; }
.card.up .face-audio .speaker { animation: speak 1s ease-in-out 2; }
.caption { display: none; font-weight: 600; font-size: clamp(10px, 12.5cqmin, 26px); line-height: 1.05; max-width: 100%; overflow-wrap: anywhere; }
.caption small { display: block; font-size: .78em; color: var(--muted); font-weight: 500; }
.cap-on .card.matched .face-pic .caption, .card.matched .face-audio .caption, .card.missed .face-audio .caption { display: block; }
.face-side .word { margin-top: auto; }
.face-side.has-pic .pic { flex: 1 1 60%; }

/* pictures inside cards (and elsewhere) */
.pic { display: flex; align-items: center; justify-content: center; gap: 3%; position: relative; }
.pic .emo { max-width: 100%; max-height: 100%; }
.pic.n1 .emo { width: auto; height: 100%; aspect-ratio: 1; filter: drop-shadow(0 2cqmin 1.5cqmin rgba(0, 0, 0, .12)); }
.pic.n1 .emo-native { font-size: 60cqmin; height: auto; }
.pic.n2 .emo { width: 47%; height: auto; aspect-ratio: 1; }
.pic.n2 .emo-native { font-size: 34cqmin; }
.pic.n3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); place-items: center; gap: 0; }
.pic.n3 > :first-child { grid-column: 1 / span 2; }
.pic.n3 .emo { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.pic.n3 .emo-native { font-size: 26cqmin; }
.pic-svg { width: 100%; height: 100%; }
.pic-svg svg { width: 100%; height: 100%; display: block; }
.pic.body .hl { animation: pulseRing 1.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.pic.frame-house {
  padding: 30% 12% 6%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M50 3 97 36H88V97H12V36H3z' fill='%23fff3e0' stroke='%23d7a46a' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M50 3 97 36H3z' fill='%23ff8a65' stroke='%23d9673f' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.pic.frame-house .emo { width: 46%; height: auto; }
/* family trees are drawn in a square box (node positions are % of it) that fits the card */
.fam-box { position: relative; flex: none; width: min(86cqw, 86cqh); aspect-ratio: 1; }
.cap-on .card.matched .fam-box { width: min(78cqw, 64cqh); }
.wr-item .fam-box, .wl-pic .fam-box, .chip-pic .fam-box { width: 100%; }
.fam-lines, .fam-lines svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.fam-node { position: absolute; width: var(--node); aspect-ratio: 1; translate: -50% -50%; display: grid; place-items: center; border-radius: 50%; }
.fam-node .emo { width: 100%; height: 100%; }
.fam-node .emo-native { font-size: 18cqmin; }
.fam-node.dim { opacity: .42; filter: grayscale(.7); }
.fam-node.hi { background: radial-gradient(circle, #fff6b0 0 55%, transparent 72%); box-shadow: 0 0 0 2px #ffb300; scale: 1.18; }
.me-badge { position: absolute; bottom: -18%; left: 50%; translate: -50% 0; padding: 0 1.6cqmin; border-radius: 99px; background: #26a69a; color: #fff; font-size: max(8px, 7cqmin); font-weight: 700; line-height: 1.35; }

/* states */
.card.matched .card-front { box-shadow: 0 0 0 clamp(2px, 2.5cqmin, 4px) var(--owner, var(--match)), 0 0 18px color-mix(in srgb, var(--owner, var(--match)) 65%, transparent); }
.card.matched .card-front::after {
  content: '✓'; position: absolute; top: 3.5cqmin; right: 3.5cqmin; width: 14cqmin; height: 14cqmin; min-width: 14px; min-height: 14px;
  display: grid; place-items: center; border-radius: 50%; background: var(--owner, var(--match)); color: #fff; font-weight: 700; font-size: max(9px, 9cqmin);
}
.card.matched .card-inner { animation: matchPop .55s ease .05s; }
.card.shake { animation: shake .45s ease; }
.card.hinted .card-back { animation: hintGlow 1.6s ease; }
.card.missed .card-front { opacity: .75; filter: grayscale(.5); }
.reveal-bar { position: absolute; left: 10%; right: 10%; bottom: 4cqmin; height: max(3px, 3.5cqmin); border-radius: 99px; background: var(--accent); opacity: 0; transform-origin: left center; }
.card.timing .reveal-bar { opacity: .8; animation: reveal var(--reveal, 3s) linear forwards; }
.board.dealing .card { opacity: 0; translate: 0 34px; scale: .5; }
.board.dealing.dealt .card { opacity: 1; translate: 0 0; scale: 1; transition: opacity .3s ease var(--d), translate .45s cubic-bezier(.3, 1.5, .6, 1) var(--d), scale .45s cubic-bezier(.3, 1.5, .6, 1) var(--d); }

@keyframes matchPop { 0% { scale: 1; } 40% { scale: 1.12; } 100% { scale: 1; } }
@keyframes shake { 15%, 55% { translate: -7px 0; } 35%, 75% { translate: 7px 0; } 100% { translate: 0 0; } }
@keyframes hintGlow { 0%, 100% { box-shadow: 0 0 0 0 #ffd54f; } 25%, 75% { box-shadow: 0 0 0 5px #ffd54f, 0 0 26px #ffd54f; } 50% { box-shadow: 0 0 0 2px #ffd54f; } }
@keyframes reveal { from { scale: 1 1; } to { scale: 0 1; } }
@keyframes speak { 50% { scale: 1.12; } }
@keyframes pulseRing { 50% { scale: 1.15; } }
@keyframes pulse { 50% { scale: 1.06; } }
@keyframes wiggle { 25% { rotate: -10deg; } 50% { rotate: 8deg; } 75% { rotate: -4deg; } }

/* ------------------------------------------------------------------ overlays, dialogs */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(12, 16, 40, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
.dialog {
  width: min(560px, 100%); max-height: min(92dvh, 900px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel-solid); color: var(--ink); border-radius: 26px; padding: 18px 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: popIn .3s cubic-bezier(.3, 1.4, .6, 1);
}
.dialog.wide { width: min(860px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -18px; background: var(--panel-solid); padding: 4px 0 8px; z-index: 1; }
.dialog-head h2 { margin: 0; }
.pause-dialog { display: grid; gap: 10px; text-align: center; width: min(360px, 100%); }
.pause-dialog h2 { margin: 4px 0 8px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; scale: .9; } }

.settings h3 { margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.set-row { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; align-items: center; gap: 8px 14px; padding: 7px 0; }
.set-row > small { grid-column: 2; color: var(--muted); }
.set-row label { font-weight: 600; }
@media (max-width: 520px) { .set-row { grid-template-columns: 1fr; } .set-row > small { grid-column: 1; } }
.switch { width: 56px; height: 32px; border-radius: 99px; border: 0; background: #c5cbe0; position: relative; transition: background .2s; }
.switch i { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: left .2s; }
.switch.on { background: var(--match); }
.switch.on i { left: 28px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.chip-pic { display: inline-flex; width: 26px; height: 26px; container-type: size; }
.chip-pic .pic { width: 26px; height: 26px; }
.chip-pic .emo-native { font-size: 20px; }
.pal-dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 2px solid rgba(255, 255, 255, .7); box-shadow: 0 0 0 1px var(--line); }
.pal-auto { background: linear-gradient(90deg, #8ec5ff 50%, #24164d 50%); }
.pal-sky { background: linear-gradient(135deg, #4f7cff, #8a5cff); }
.pal-candy { background: linear-gradient(135deg, #ff5fa8, #a45cff); }
.pal-jungle { background: linear-gradient(135deg, #27b07a, #0f7a66); }
.pal-sunset { background: linear-gradient(135deg, #ff8a3d, #ff4b6e); }
.pal-night { background: linear-gradient(135deg, #141a35, #ad4bff); }

/* about */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { border: 0; padding: 8px 14px; border-radius: 12px; background: var(--chip); color: var(--chip-ink); font-weight: 600; }
.tab.sel { background: var(--accent); color: var(--accent-ink); }
.md h2, .md h3, .md h4 { margin: 18px 0 8px; }
.md h2 { font-size: 1.3rem; }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 4px 0; }
.md ul.tasks { list-style: none; padding-left: 4px; }
.md ul.tasks li::before { content: '⬜'; margin-right: 8px; }
.md ul.tasks li.done::before { content: '✅'; }
.md ul.tasks li.doing::before { content: '🔨'; }
.md ul.tasks li.done { color: var(--muted); }
.md code { background: var(--chip); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md pre { background: var(--chip); padding: 10px 12px; border-radius: 12px; overflow-x: auto; font-size: .85rem; white-space: pre-wrap; word-break: break-all; }
.md blockquote { margin: 8px 0; padding: 6px 12px; border-left: 4px solid var(--accent); background: var(--chip); border-radius: 0 10px 10px 0; }
.md-table { overflow-x: auto; }
.md table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md hr { border: 0; border-top: 2px dashed var(--line); margin: 16px 0; }
.about-hero { display: flex; align-items: center; gap: 14px; }
.about-hero .emo { width: 64px; height: 64px; }
.about-hero h3 { margin: 0; }
.about-hero p { margin: 2px 0 0; color: var(--muted); }

/* results */
.results { text-align: center; }
.results h2 { margin: 6px 0; font-size: 1.7rem; }
.results h3 { margin: 18px 0 8px; text-align: left; }
.stars { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.star .emo { width: 64px; height: 64px; filter: grayscale(1) opacity(.25); }
.star.on .emo { filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .2)); animation: starIn .5s cubic-bezier(.3, 1.6, .6, 1) both; animation-delay: calc(.35s + var(--i) * .3s); }
.star:nth-child(2) .emo { width: 78px; height: 78px; margin-top: -10px; }
@keyframes starIn { from { scale: 0; rotate: -90deg; } }
.new-best { display: inline-block; margin: 4px 0 8px; padding: 4px 14px; border-radius: 99px; background: #fff3c4; color: #8a5a00; font-weight: 700; animation: pulse 1.2s infinite; }
.rstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.rstat { display: grid; justify-items: center; gap: 2px; padding: 8px; border-radius: 14px; background: var(--chip); }
.rstat .emo { width: 26px; height: 26px; }
.rstat span { font-size: .8rem; color: var(--muted); }
.rstat b { font-size: 1.1rem; }
.scoreboard { display: grid; gap: 6px; margin: 10px 0; }
.sb-row { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 14px; background: color-mix(in srgb, var(--pc) 14%, var(--panel-solid)); border: 2px solid var(--pc); }
.sb-row .emo { width: 30px; height: 30px; }
.sb-row b { margin-left: auto; font-size: 1.3rem; }
.sb-rank { width: 26px; font-size: 1.2rem; }
.word-review { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.wr-item { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 0; border-radius: 14px; background: var(--chip); color: var(--chip-ink); container-type: inline-size; }
.wr-item .pic { width: 56px; height: 56px; }
.wr-item .pic .emo-native { font-size: 40px; }
.wr-en { font-weight: 600; font-size: .9rem; line-height: 1.15; }
.wr-es { color: var(--muted); font-size: .75rem; }
.wr-noimg { font-size: 30px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }

/* effects */
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }
.float-text { position: fixed; z-index: 65; pointer-events: none; translate: -50% -50%; font-weight: 700; font-size: 30px; color: #fff; -webkit-text-stroke: 1px rgba(0, 0, 0, .15); text-shadow: 0 3px 0 rgba(0, 0, 0, .2), 0 0 12px var(--match); animation: floatUp 1.1s ease-out forwards; }
@keyframes floatUp { from { opacity: 1; translate: -50% -50%; } to { opacity: 0; translate: -50% -180%; } }
.banner { position: fixed; z-index: 66; left: 50%; top: 42%; translate: -50% -50%; pointer-events: none; white-space: nowrap; font-weight: 700; font-size: clamp(30px, 8vw, 70px); color: #fff; -webkit-text-stroke: 2px rgba(0, 0, 0, .12); text-shadow: 0 5px 0 rgba(0, 0, 0, .18), 0 0 30px var(--accent); animation: bannerPop 1.3s ease forwards; }
.banner.turn { font-size: clamp(24px, 6vw, 52px); top: 50%; }
@keyframes bannerPop { 0% { opacity: 0; scale: .3; } 20% { opacity: 1; scale: 1.1; } 35% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; scale: 1.05; } }
.toast { position: fixed; z-index: 80; left: 50%; top: max(14px, env(safe-area-inset-top)); translate: -50% 0; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 10px 18px; border-radius: 16px; background: #1d2340; color: #fff; font-weight: 600; box-shadow: 0 8px 26px rgba(0, 0, 0, .3); animation: toastIn .3s ease; }
@keyframes toastIn { from { opacity: 0; translate: -50% -20px; } }

/* ------------------------------------------------------------------ learn */
.learn { min-height: 100dvh; display: flex; flex-direction: column; }
.learn-top { display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 8px; }
.learn-body { flex: 1; padding: 8px 14px calc(20px + env(safe-area-inset-bottom)); }
.fc-wrap { display: grid; justify-items: center; gap: 12px; }
.fc-stage { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; }
.flashcard { position: relative; width: min(72vw, 400px, 52dvh); aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; perspective: 1200px; container-type: size; }
.fc-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.34, 1.3, .5, 1); }
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4cqh; padding: 8cqw; border-radius: 26px; background: var(--face); color: var(--face-ink); box-shadow: 0 6px 0 rgba(0, 0, 0, .1), 0 14px 30px rgba(0, 0, 0, .18); -webkit-backface-visibility: hidden; backface-visibility: hidden; text-align: center; }
.fc-front .pic { width: 100%; height: 70%; }
.fc-back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--face), color-mix(in srgb, var(--accent) 12%, var(--face))); }
.fc-back .pic { width: 40%; height: 30%; }
.fc-word { font-size: min(13cqw, 64px); font-weight: 700; line-height: 1.05; overflow-wrap: anywhere; }
.fc-es { font-size: min(8cqw, 34px); color: #b23a1d; font-weight: 600; }
[data-palette="night"] .fc-es { color: #ffc38a; }
.fc-def { font-size: min(5.6cqw, 22px); color: var(--muted); }
.fc-arrow { font-size: 8cqw; color: var(--muted); }
.fc-meta { display: flex; align-items: center; gap: 14px; font-weight: 600; }
.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; max-width: 1200px; margin: 0 auto; }
.wl-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 18px; background: var(--panel); text-align: left; box-shadow: var(--shadow); color: var(--ink); }
.wl-pic { flex: none; width: 64px; height: 64px; display: grid; place-items: center; container-type: size; }
.wl-pic .pic { width: 64px; height: 64px; }
.wl-pic .emo-native { font-size: 46px; }
.wl-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.wl-text b { font-size: 1.15rem; }
.wl-es { color: #b23a1d; font-weight: 500; }
[data-palette="night"] .wl-es { color: #ffc38a; }
.wl-text small { color: var(--muted); }
.wl-say .emo { width: 26px; height: 26px; opacity: .7; }

/* ------------------------------------------------------------------ print (Learn → Print cards) */
.print-sheet { display: none; }
@media print {
  body.printing > *:not(.print-sheet) { display: none !important; }
  body.printing { background: #fff; }
  .print-sheet { display: block; color: #000; font-family: Fredoka, sans-serif; }
  .print-sheet h1 { font-size: 14pt; margin: 0 0 8mm; }
  .print-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm; }
  .print-card { aspect-ratio: 3 / 4; border: 1.5pt dashed #888; border-radius: 4mm; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2mm; padding: 4mm; break-inside: avoid; text-align: center; container-type: size; }
  .print-card .pic { width: 80%; height: 60%; }
  .print-card .emo-native { font-size: 34pt; }
  .print-card span { font-size: 15pt; font-weight: 600; }
  .print-card.word span { font-size: 18pt; }
}

/* ------------------------------------------------------------------ motion off, small screens, embed */
.no-anim *, .no-anim *::before, .no-anim *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }
.no-anim .card.timing .reveal-bar { animation-duration: var(--reveal, 3s) !important; }
@media (max-width: 600px) { .hide-sm { display: none !important; } }
@media (max-width: 420px) { .hide-xs { display: none !important; } }
.embed .home-foot { display: none; }
