@font-face {
  font-family: 'Fredoka One';
  src: url('/fonts/FredokaOne-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --pink: #F5B5B4;
  --pink-light: #FBD3D1;
  --pink-deep: #E8888A;
  --red: #D7141A;
  --ink: #1A1A2E;
  --ink-soft: #5B4A55;
  --tile-shadow: #A8E3E6;
  --white: #fff;
  --green: #4CAF50;
  --green-dark: #388E3C;
  --purple: #6B2FA0;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(160, 70, 80, .18);
  --font-display: 'Fredoka One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--pink-light) 0%, var(--pink) 45%, #F0AAA9 100%) fixed;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); margin: .2rem 0 0; }

/* Decorative daisies */
.daisy { position: fixed; z-index: 0; pointer-events: none; opacity: .9; width: clamp(120px, 18vw, 240px); height: auto; }
.d1 { top: 70px; right: -40px; transform: rotate(12deg); }
.d2 { bottom: 40px; left: -50px; transform: rotate(-20deg); }
.d3 { top: 45%; right: 4%; width: clamp(80px, 10vw, 150px); transform: rotate(40deg); opacity: .75; }
@media (max-width: 700px) { .d3 { display: none; } .d1 { top: 50px; right: -70px; } }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-size: 1.15rem; }
.brand img { border-radius: 10px; }
.heart { color: var(--red); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; font-size: 1.25rem; cursor: pointer; padding: 6px; border-radius: 10px; }
.icon-btn:hover { background: rgba(0,0,0,.05); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; text-decoration: none;
  font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .3px;
  padding: 14px 26px; border-radius: 999px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(2px); }
.btn-play { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-dark); }
.btn-play:active { box-shadow: 0 2px 0 var(--green-dark); }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #E3C3C4; }
.btn-secondary:active { box-shadow: 0 2px 0 #E3C3C4; }
.btn-app { background: #111; color: #fff; box-shadow: 0 4px 0 #000; }
.btn-app.small, .btn.small { font-size: .9rem; padding: 9px 16px; box-shadow: none; }
.btn-small { font-size: .95rem; padding: 10px 16px; background: #fff; box-shadow: 0 3px 0 #E3C3C4; }
.btn-small:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .cat-card:focus-visible, .sub-card:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.view { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }

/* Hero */
.hero { text-align: center; padding: 24px 0 8px; }
.logo { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: normal; }
.logo-i {
  font-family: var(--font-display); color: #fff; font-size: clamp(3rem, 9vw, 4.5rem); line-height: .9;
  text-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.logo-heart { font-size: clamp(3.4rem, 10vw, 5rem); line-height: 1; filter: drop-shadow(0 4px 6px rgba(150, 0, 0, .25)); }
.tiles { display: flex; gap: clamp(4px, 1vw, 8px); }
.tiles b {
  display: grid; place-items: center;
  width: clamp(38px, 8vw, 58px); height: clamp(38px, 8vw, 58px);
  background: #fff; border-radius: 10px;
  font-family: var(--font-display); font-weight: normal; font-size: clamp(1.4rem, 4.6vw, 2.2rem);
  box-shadow: 0 4px 0 var(--tile-shadow);
}
.tagline { max-width: 520px; margin: 18px auto 20px; font-size: 1.08rem; color: var(--ink-soft); }
.hero-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.streak { font-family: var(--font-display); color: var(--purple); margin-top: 16px; }

/* Panels */
.panel {
  background: rgba(255,255,255,.88); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-top: 28px;
}
.panel h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: 1.5rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search input {
  width: min(320px, 80vw); padding: 11px 16px; border-radius: 999px; border: 2px solid #F0D2D3;
  font-size: 1rem; background: #fff; outline: none;
}
.search input:focus { border-color: var(--pink-deep); }

.groups { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 6px; scrollbar-width: thin; }
.groups button {
  flex: none; border: 0; cursor: pointer; padding: 8px 14px; border-radius: 999px;
  background: #FBEAEA; font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.groups button[aria-selected="true"] { background: var(--ink); color: #fff; }

.cat-grid, .sub-grid { display: grid; gap: 10px; margin-top: 12px; }
.cat-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.sub-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 16px; }
.cat-card, .sub-card {
  display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none;
  background: #fff; border: 2px solid #F6E0E0; border-radius: 14px; padding: 12px 14px; cursor: pointer;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.cat-card:hover, .sub-card:hover { transform: translateY(-2px); border-color: var(--pink-deep); box-shadow: 0 4px 10px rgba(200,100,110,.15); }
.cat-card .emoji { font-size: 1.6rem; flex: none; }
.cat-card .name { font-family: var(--font-display); font-size: .95rem; line-height: 1.15; }
.cat-card .count { display: block; font-family: var(--font-body); font-size: .78rem; color: var(--ink-soft); margin-top: 2px; }
.sub-card { font-weight: 600; justify-content: space-between; }
.sub-card .done { color: var(--green); font-size: .9rem; }
.empty { color: var(--ink-soft); padding: 20px 4px; }

.app-promo { display: flex; gap: 22px; align-items: flex-start; }
.promo-icon { border-radius: 22px; box-shadow: 0 6px 14px rgba(0,0,0,.15); flex: none; }
.features { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; }
@media (max-width: 600px) { .app-promo { flex-direction: column; align-items: center; text-align: center; } .features { text-align: left; } }

.back { display: inline-block; text-decoration: none; font-weight: 700; color: var(--ink); padding: 6px 2px; }
.back:hover { text-decoration: underline; }

/* Game */
.game-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.game-title { text-align: center; min-width: 0; }
.game-title h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: clamp(1.1rem, 3.5vw, 1.6rem); overflow-wrap: anywhere; }
.timer { font-family: var(--font-display); font-size: 1.3rem; background: #fff; padding: 6px 14px; border-radius: 999px; font-variant-numeric: tabular-nums; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; margin-top: 14px; align-items: start; }
@media (max-width: 860px) { .game-layout { grid-template-columns: 1fr; } }

.board-wrap { display: flex; flex-direction: column; align-items: center; }
.board {
  --n: 10;
  position: relative;
  width: min(100%, 620px, calc(100vh - 220px));
  min-width: 260px;
  aspect-ratio: 1;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 2.2%;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.marks, .cells { position: absolute; inset: 2.2%; width: 95.6%; height: 95.6%; }
.cells { display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); }
.cell {
  display: grid; place-items: center;
  font-family: var(--font-display); color: var(--ink);
  font-size: calc(var(--board-px, 500px) / var(--n) * .5);
  cursor: pointer; line-height: 1;
}
.cell.hint { animation: hintPulse 1.2s ease-in-out 3; color: var(--red); }
@keyframes hintPulse { 50% { transform: scale(1.35); } }
.marks line { stroke-linecap: round; }
.marks .sel { stroke: rgba(107, 47, 160, .32); }
.marks .bad { stroke: rgba(215, 20, 26, .3); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.difficulty { display: inline-flex; background: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 3px 0 #E3C3C4; }
.difficulty button { border: 0; background: none; cursor: pointer; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.difficulty button[aria-checked="true"] { background: var(--ink); color: #fff; }

.words-panel { background: rgba(255,255,255,.88); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.words-panel h3 { margin: 0 0 12px; font-family: var(--font-display); font-weight: normal; color: var(--purple); }
.words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.words li {
  padding: 6px 12px; border-radius: 999px; background: #F7F2F7; border: 2px solid #E8DDEA;
  font-weight: 700; font-size: .9rem; letter-spacing: .3px; transition: background .3s;
}
.words li.found { text-decoration: line-through; text-decoration-thickness: 2px; border-color: transparent; color: rgba(26,26,46,.75); }
.words li.pop { animation: pop .4s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.mini-promo { margin-top: 18px; padding-top: 14px; border-top: 2px dashed #F0D2D3; font-size: .9rem; color: var(--ink-soft); }
.mini-promo p { margin: 0 0 10px; }
@media (max-width: 860px) { .words li { font-size: .82rem; padding: 5px 10px; } }

/* Win dialog */
.win {
  border: 0; border-radius: 24px; padding: 28px 24px 20px; width: min(440px, 92vw);
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
}
.win::backdrop { background: rgba(80, 20, 40, .45); }
.win h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: 1.8rem; }
.win-time { font-family: var(--font-display); font-size: 2.4rem; margin: 10px 0 0; color: var(--purple); }
.win-buttons { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.win-promo { display: flex; align-items: center; gap: 12px; text-align: left; background: #FBEAEA; border-radius: 16px; padding: 12px; }
.win-promo img { border-radius: 12px; }
.win-promo div { flex: 1; font-size: .85rem; display: flex; flex-direction: column; gap: 2px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: 0; } }

.footer { position: relative; z-index: 1; text-align: center; font-size: .85rem; color: var(--ink-soft); padding: 10px 16px 30px; }
.footer p { margin: 4px 0; }
.version { opacity: .7; font-size: .78rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Phone layout */
.brand, .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .brand span { display: none; }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
  .view { padding: 10px 12px 32px; }
  .game-head { grid-template-columns: auto 1fr auto; gap: 6px; }
  .game-title h2 { font-size: 1.05rem; }
  .game-title p { font-size: .8rem; }
  .timer { font-size: 1.05rem; padding: 4px 10px; }
  .back { font-size: .9rem; }
}
@media (max-width: 860px) {
  .board-wrap { display: contents; }
  .game-layout { gap: 12px; }
  .board { width: min(100%, 560px); justify-self: center; order: 1; }
  .words-panel { order: 2; padding: 12px; }
  .words-panel h3 { font-size: 1rem; margin-bottom: 8px; }
  .words { gap: 6px; }
  .controls { order: 3; margin-top: 0; }
  .mini-promo { display: none; }
}
.mobile-promo { display: none; }
@media (max-width: 860px) {
  .mobile-promo { order: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: rgba(255,255,255,.88); border-radius: 14px; padding: 10px 12px; font-size: .88rem; color: var(--ink-soft); }
}
