:root {
  color-scheme: light;
  --page: #f0f3ec;
  --paper: #fcfdf9;
  --ink: #172a22;
  --muted: #4b6255;
  --line: #d7e0d3;
  --pine: #173a30;
  --lime: #d6f47c;
  --soft: #e8f1df;
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

@font-face {
  font-family: Manrope;
  src: url("./font.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("./font-cyrillic.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0400-045F, U+0460-052F, U+2116;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #54883b; outline-offset: 3px; }

.page-width {
  width: min(100% - 64px, 1120px);
  margin-inline: auto;
}

.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.08em;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pine);
  color: var(--lime);
}

.die {
  --pip: currentColor;
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  background:
    radial-gradient(circle at 25% 25%, var(--pip) 0 1px, transparent 1.5px),
    radial-gradient(circle at 75% 25%, var(--pip) 0 1px, transparent 1.5px),
    radial-gradient(circle at 50% 50%, var(--pip) 0 1px, transparent 1.5px),
    radial-gradient(circle at 25% 75%, var(--pip) 0 1px, transparent 1.5px),
    radial-gradient(circle at 75% 75%, var(--pip) 0 1px, transparent 1.5px);
}

.brand-icon .die { transform: rotate(-15deg); }
.brand-period { color: #598338; }

.outline-button {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  font-weight: 800;
}

.settings-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: .875rem;
}

.outline-button:hover { background: var(--soft); }
.sliders { display: grid; width: 16px; gap: 4px; }
.sliders i { height: 1.5px; background: currentColor; border-radius: 2px; position: relative; }
.sliders i::after {
  content: "";
  width: 3px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
  position: absolute;
  top: -1.75px;
  left: 3px;
}
.sliders i:nth-child(2)::after { left: 10px; }
.sliders i:nth-child(3)::after { left: 6px; }

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding-block: 51px 28px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6.4vw, 4.65rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -.079em;
}

.intro h1 span { color: #598338; }
.intro p { color: var(--muted); margin: 13px 0 0; line-height: 1.55; }

.language-pair {
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: .875rem;
}

.language-pair b { font-weight: 800; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, .58fr);
  align-items: start;
  gap: 20px;
  padding-bottom: max(42px, env(safe-area-inset-bottom));
}

.draw-area, .category-panel {
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  min-width: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cards[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.cards[data-count="3"] .word-card:last-child,
.cards[data-count="5"] .word-card:last-child { grid-column: 1 / -1; }

.word-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: start;
  min-width: 0;
  min-height: 181px;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--pine);
  color: #fcfff4;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.word-card::before {
  content: "";
  z-index: -1;
  position: absolute;
  width: 87%;
  aspect-ratio: 1;
  right: -42%;
  top: -30%;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at center, transparent 0 24px, #b4e69926 25px 26px);
  mask-image: linear-gradient(120deg, #000 32%, transparent 76%);
  pointer-events: none;
}

.word-card:hover { background-color: #1c4337; }
.word-card:focus-visible { outline-color: #93bb45; }
.cards[data-count="1"] .word-card {
  min-height: 375px;
  padding: 24px;
  border-radius: 18px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #a6d2aa39;
  border-radius: 8px;
  background: #d5f3d71a;
  color: #e2f5df;
  font-size: .875rem;
  font-weight: 800;
}

.card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  padding-block: 14px 6px;
}

.english {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.38rem, 3vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -.065em;
  line-height: 1.08;
}

.cards[data-count="1"] .card-content { padding: 26px 8px 36px; }
.cards[data-count="1"] .english { font-size: clamp(2.6rem, 6.6vw, 5.1rem); }

.translation-line {
  display: flex;
  align-items: center;
  min-height: 40px;
  max-width: 100%;
  margin-top: 9px;
}

.translate-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #d5e7d3;
  font-size: .875rem;
  font-weight: 750;
}

.translate-hint span { color: var(--lime); font-size: 1.2rem; }
.russian {
  color: var(--lime);
  font-size: 1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.cards[data-count="1"] .russian { font-size: clamp(1.25rem, 3vw, 1.85rem); }

.roll-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 12px;
}

.roll-button, .save-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 49px;
  padding: 10px 20px;
  border: 1px solid #b5d65b;
  border-radius: 12px;
  background: var(--lime);
  color: #1d330f;
  font-weight: 800;
}

.roll-button:hover, .save-button:hover { background: #c7eb63; }
.roll-button:active, .save-button:active { background: #bce052; }
.roll-button .die { transform: rotate(-12deg); }

.keyboard-hint { color: var(--muted); font-size: .875rem; }
kbd {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
}

.category-panel { padding: 21px; }
.panel-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.panel-top h2, .dialog-header h2 {
  margin: 0;
  letter-spacing: -.05em;
  font-size: 1.4rem;
  font-weight: 800;
}

.pool-size { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.category-button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 45px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8f2;
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
  font-size: .875rem;
  font-weight: 750;
}

.category-button:hover { background: var(--soft); }
.category-button[aria-pressed="true"] { border-color: #82a66a; background: var(--soft); }
.category-icon { display: grid; place-items: center; flex: 0 0 21px; width: 21px; font-size: 1.03rem; }
.all-categories { grid-column: 1 / -1; }
.all-categories .category-icon { color: #426d38; font-size: 1.25rem; }
.all-check { margin-left: auto; color: #315a2b; visibility: hidden; }
.all-categories[aria-pressed="true"] .all-check { visibility: visible; }

dialog {
  width: min(520px, 100% - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: contain;
  box-shadow: 0 20px 70px #112b2240;
}

dialog::backdrop { background: #142a23a8; }
body:has(dialog[open]) { overflow: hidden; }
.dialog-header, .dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
}

.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-footer { border-top: 1px solid var(--line); }
.close-button { width: 44px; font-size: 1.5rem; line-height: 1; }
.amount-field, .category-field { padding: 0; border: 0; margin: 18px 20px; min-width: 0; }
legend { padding: 0; margin-bottom: 9px; font-weight: 800; }
.amount-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.amount-options label { position: relative; cursor: pointer; }
.amount-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.amount-options span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f6f8f2;
  font-weight: 800;
}

.amount-options input:checked + span { background: var(--soft); border-color: #82a66a; }
.amount-options input:focus-visible + span { outline: 3px solid #54883b; outline-offset: 2px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 9px 0;
  margin-inline: 20px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.setting-row b, .setting-row small { display: block; }
.setting-row small { margin-top: 4px; color: var(--muted); line-height: 1.4; font-size: .875rem; }
.switch {
  appearance: none;
  display: grid;
  align-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  margin: 0;
  padding: 3px;
  border: 1px solid #a5b9a2;
  border-radius: 20px;
  background: #dfe7dd;
  cursor: pointer;
}

.switch::before { content: ""; width: 18px; height: 18px; border-radius: 50%; background: #637d68; }
.switch:checked { background: #3c674b; border-color: #3c674b; }
.switch:checked::before { justify-self: end; background: #fff; }
.setting-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.setting-categories label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow-wrap: anywhere;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 750;
}

.setting-categories input { accent-color: #3c674b; width: 16px; height: 16px; flex: 0 0 16px; margin: 0; }
.category-error { color: #9c2a31; font-size: .875rem; margin: 8px 0 0; }
.category-error:empty { margin: 0; }
.reset-button { border: 0; background: transparent; padding: 10px 0; color: var(--muted); font-size: .875rem; font-weight: 800; }
.reset-button:hover { text-decoration: underline; }
.save-button { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 800px) {
  .page-width { width: calc(100% - 40px); }
  .intro { padding-top: 35px; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(256px, .65fr); gap: 12px; }
  .cards[data-count="1"] .word-card { min-height: 322px; }
  .category-panel { padding: 14px; }
  .category-button { padding-inline: 7px; gap: 5px; }
}

@media (max-width: 620px) {
  .page-width { width: calc(100% - 28px); }
  .header-inner { min-height: 63px; }
  .brand { font-size: 1.42rem; }
  .brand-icon { width: 36px; height: 36px; }
  .intro { align-items: start; padding-block: 26px 18px; }
  .intro h1 { font-size: clamp(2.35rem, 9.5vw, 3.8rem); }
  .intro p { margin-top: 8px; font-size: .94rem; }
  .language-pair { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .draw-area { padding: 9px; border-radius: 20px; }
  .category-panel { border-radius: 20px; }
  .cards[data-count="1"] .word-card { min-height: 242px; padding: 15px; border-radius: 14px; }
  .cards[data-count="1"] .card-content { padding: 18px 3px 20px; }
  .cards[data-count="1"] .english { font-size: clamp(2.35rem, 9vw, 3.65rem); }
  .word-card { padding: 12px; min-height: 151px; border-radius: 13px; }
  .translation-line { min-height: 30px; margin-top: 7px; }
  .roll-bar { padding-top: 9px; }
  .roll-button { width: 100%; }
  .keyboard-hint { display: none; }
  .panel-top { margin-bottom: 12px; }
  .category-button { padding-inline: 10px; }
}

@media (pointer: coarse) {
  .keyboard-hint { display: none; }
}
