@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700;12..96,800&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --paper: #f7f5ee;
  --ink: #211b2f;
  --muted: #595266;
  --violet: #5537c8;
  --violet-deep: #37237f;
  --lavender: #e8dfff;
  --lime: #e4fd89;
  --yellow: #fff0ac;
  --line: #d9d4c8;
  --white: #fffefa;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "DM Sans", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#d6d0c2 0.85px, transparent 0.85px);
  background-size: 21px 21px;
  font-family: var(--body);
}
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #704de5; outline-offset: 4px; }
.word-card button:focus-visible { outline-color: var(--lime); }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin: 0; }
h1, h2, .brand { font-family: var(--display); }
.shell { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.3rem; display: inline-flex; align-items: center; letter-spacing: -.045em; }
.brand-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-right: 12px;
  border-radius: 11px; border: 1px solid var(--violet-deep); background: var(--violet); color: white;
  box-shadow: 2px 2px var(--ink); font-family: var(--body); font-size: 1.65rem; line-height: 1;
}
.brand-amp { color: var(--violet); padding-inline: 3px; }
.help-button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 41px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--white); font-weight: 700; font-size: .875rem;
}
.help-button:hover { border-color: var(--violet); }
.help-button span { display: grid; place-items: center; border: 1.5px solid currentColor; height: 17px; width: 17px; border-radius: 50%; font-size: .72rem; }

main.shell { padding-block: 44px 42px; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
h1 { font-size: clamp(2.9rem, 7vw, 5.35rem); font-weight: 800; letter-spacing: -.075em; line-height: .99; }
h1 em { color: var(--violet); font-style: normal; }
h1 em span { color: var(--violet); }
.heading p { color: var(--muted); font-size: 1.0625rem; margin-top: 15px; }
.dictionary {
  display: flex; align-items: center; gap: 7px; white-space: nowrap; background: var(--lavender);
  border: 1px solid #cbb9f2; border-radius: 999px; padding: 9px 13px; color: var(--violet-deep);
  font-weight: 700; font-size: .875rem;
}
.dictionary span:first-child { font-size: 1.03rem; line-height: 1; }

.game-grid { display: grid; grid-template-columns: minmax(0, 2.18fr) minmax(285px, 1fr); gap: 21px; align-items: stretch; }
.word-card, .timer-card, .difficulty-card, .categories { border: 1.5px solid var(--ink); border-radius: 18px; box-shadow: 4px 4px var(--ink); }
.word-card {
  position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto;
  min-height: 412px; padding: 24px 26px; color: white; background-color: var(--violet);
  background-image: linear-gradient(#ffffff13 1px, transparent 1px), linear-gradient(90deg, #ffffff13 1px, transparent 1px);
  background-size: 28px 28px;
}
.word-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.word-top h2 { font-size: 1.125rem; letter-spacing: -.02em; }
.round { border: 1px solid #ffffff70; border-radius: 999px; background: var(--violet-deep); padding: 6px 12px; font-size: .875rem; font-weight: 700; white-space: nowrap; }
.word-center { position: relative; display: grid; justify-items: center; align-content: center; gap: 19px; min-width: 0; padding: 19px 0; }
.secret-mark {
  display: grid; place-items: center; background: var(--lavender); color: var(--violet-deep); width: 108px; height: 108px;
  border-radius: 25px; border: 2px solid var(--ink); transform: rotate(-9deg); box-shadow: 5px 5px var(--violet-deep);
  font: 800 4.6rem/.95 var(--display); padding-bottom: 4px;
}
.spark { position: absolute; color: var(--lime); pointer-events: none; font-size: 2rem; line-height: 1; }
.spark-left { top: 41%; left: 17%; }
.spark-right { top: 23%; right: 16%; }
.word-center:has(.word:not([hidden])) .spark { display: none; }
.word { color: var(--lime); font: 800 clamp(2.3rem, 6vw, 5.5rem)/1 var(--display); letter-spacing: -.05em; text-align: center; overflow-wrap: anywhere; max-width: 100%; }
.word-hint { font-size: 1rem; color: #f0eaff; text-align: center; }
.word-actions { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; }
.word-actions button { min-height: 53px; border-radius: 10px; font-weight: 800; padding: 8px 12px; }
.reveal { color: var(--ink); background: var(--lime); border: 1.5px solid var(--ink); box-shadow: 2px 3px var(--ink); }
.reveal:hover { background: #efffb6; }
.next { background: var(--violet-deep); color: white; border: 1px solid #ffffff97; }
.next:hover { background: #2b1967; }
.word-actions button:active, #start-timer:active { transform: translateY(2px); box-shadow: none; }

.side { display: grid; grid-template-rows: 1fr auto; gap: 17px; }
.timer-card { padding: 19px 20px 17px; background: var(--yellow); }
.difficulty-card { padding: 16px 20px 18px; background: var(--white); }
.control-heading { display: flex; align-items: center; gap: 9px; }
.control-heading h2, .category-heading h2 { font-size: 1.13rem; font-weight: 800; letter-spacing: -.025em; }
.control-icon { flex: 0 0 19px; height: 19px; display: inline-block; }
.timer-icon { position: relative; width: 19px; border: 1.8px solid; border-radius: 50%; }
.timer-icon::before { content: ""; position: absolute; width: 5px; height: 6px; border-left: 1.8px solid; border-bottom: 1.8px solid; top: 3px; left: 7px; }
.level-icon { display: inline-flex; align-items: end; gap: 3px; padding-bottom: 2px; color: var(--violet); }
.level-icon i { width: 4px; background: currentColor; border-radius: 2px; height: 6px; }
.level-icon i:nth-child(2) { height: 11px; }
.level-icon i:nth-child(3) { height: 16px; }
.timer-value { font: 800 clamp(3rem, 5.8vw, 4.15rem)/1 var(--display); text-align: center; letter-spacing: -.065em; margin: 13px 0 10px; font-variant-numeric: tabular-nums; }
.timer-value.expired { color: #a53039; }
progress { display: block; width: 100%; height: 7px; border: 0; border-radius: 30px; overflow: hidden; appearance: none; background: #e7d68b; color: var(--violet); }
progress::-webkit-progress-bar { background: #e7d68b; }
progress::-webkit-progress-value { background: var(--violet); border-radius: 30px; }
progress::-moz-progress-bar { background: var(--violet); border-radius: 30px; }
.durations, .difficulty-options { display: grid; gap: 5px; }
.durations { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 13px 0 11px; }
.difficulty-options { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 12px; }
.durations button, .difficulty-options button {
  border-radius: 7px; border: 1px solid transparent; min-height: 35px; padding: 3px;
  background: #ffffff82; font-size: .875rem; font-weight: 700;
}
.durations button:hover, .difficulty-options button:hover { border-color: var(--violet); }
.durations button[aria-pressed="true"] { background: var(--white); border-color: var(--ink); }
.difficulty-options button { background: #f1eef5; }
.difficulty-options button[aria-pressed="true"] { background: var(--lavender); color: var(--violet-deep); border-color: #a98aeb; }
.timer-actions { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }
.timer-actions button { border: 1.5px solid var(--ink); border-radius: 8px; min-height: 43px; font-weight: 700; }
#start-timer { background: var(--ink); color: white; }
#start-timer:hover { background: var(--violet-deep); }
#timer-symbol { margin-right: 3px; font-size: .75rem; }
#reset-timer { background: transparent; font-size: 1.42rem; line-height: 1; }
#reset-timer:hover { background: var(--white); }

.categories { margin-top: 24px; padding: 19px 21px 21px; background: var(--white); }
.category-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 12px; }
#filtered-count { color: var(--muted); font-size: .875rem; }
.category-options { display: flex; flex-wrap: wrap; gap: 8px; }
.category-options button {
  min-height: 41px; display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; font-size: .9rem;
}
.category-options button:hover { border-color: var(--violet); }
.category-options button[aria-pressed="true"] { background: var(--violet); color: white; border-color: var(--violet-deep); }
.category-options span { font-size: 1rem; line-height: 1; }

dialog { background: var(--white); color: var(--ink); width: min(485px, calc(100% - 34px)); border: 1.5px solid var(--ink); border-radius: 16px; box-shadow: 5px 5px var(--ink); padding: 24px; }
dialog::backdrop { background: #211b2fa6; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading button { display: grid; place-items: center; background: var(--lavender); border: 1px solid var(--ink); border-radius: 7px; width: 36px; height: 36px; font-size: 1.5rem; line-height: 1; }
dialog ol { padding-left: 1.5em; margin-bottom: 0; line-height: 1.55; }
dialog li + li { margin-top: 10px; }
.sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 800px) {
  .shell { width: calc(100% - 40px); }
  .heading { align-items: start; flex-direction: column; gap: 12px; }
  .game-grid { grid-template-columns: minmax(0, 1fr) minmax(245px, .75fr); gap: 15px; }
  .word-card { min-height: 390px; padding: 18px; }
  .timer-card, .difficulty-card { padding-inline: 14px; }
}
@media (max-width: 620px) {
  main.shell { padding-block: 28px 32px; }
  .shell { width: calc(100% - 32px); }
  .top-inner { min-height: 62px; }
  .brand { font-size: 1.1rem; }
  .brand-icon { width: 34px; height: 34px; margin-right: 8px; }
  .heading { margin-bottom: 20px; }
  .heading p { margin-top: 10px; }
  .game-grid { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .word-card { min-height: 320px; }
  .secret-mark { width: 84px; height: 84px; font-size: 3.7rem; }
  .word-center { gap: 15px; }
  .categories { margin-top: 17px; padding-inline: 15px; }
}
@media (prefers-reduced-motion: no-preference) {
  .word:not([hidden]) { animation: reveal-word 170ms ease-out; }
  @keyframes reveal-word { from { opacity: .25; transform: scale(.94); } }
}
