@font-face {
  font-family: Alexandria;
  src: url("../fonts/alexandria-arabic.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range:
    U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: Alexandria;
  src: url("../fonts/alexandria-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF, U+2212;
}
:root {
  font-family: Alexandria, Tahoma, Arial, sans-serif;
  color: var(--ink);
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  line-height: 1.7;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
.tool {
  width: min(920px, calc(100% - 40px));
  margin-inline: auto;
  padding-block: 21px 40px;
}
.tool-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tool-nav div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}
.tool-nav a,
.tool-nav button {
  font-size: 13px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--round, 16px);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
.tool-nav a {
  font-weight: 700;
}
.tool-nav button[aria-pressed="false"] {
  opacity: 0.72;
}
.tool-head {
  margin-block: 24px 16px;
  padding: clamp(19px, 4vw, 38px);
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--banner);
  color: var(--banner-ink, #fff);
  border-radius: var(--head-round, 28px);
  position: relative;
  overflow: hidden;
}
.tool-head > div {
  position: relative;
}
.tool-head h1 {
  font-size: clamp(24px, 5vw, 47px);
  line-height: 1.27;
  margin: 0 0 5px;
  font-weight: 800;
}
.tool-head p {
  font-size: clamp(14px, 2vw, 16px);
  margin: 0;
  max-width: 56ch;
}
.tool-head .tile {
  display: grid;
  place-items: center;
  flex: none;
  width: clamp(44px, 8vw, 66px);
  aspect-ratio: 1;
  border-radius: var(--round, 16px);
  background: var(--sticker, #fff);
  color: var(--sticker-ink, var(--accent));
  transform: rotate(-8deg);
}
.ico svg {
  width: 27px;
  height: 27px;
  display: block;
}
.workspace {
  display: grid;
  gap: 12px;
  align-items: start;
}
.panel,
.result:not(:empty) {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--round, 20px);
  padding: clamp(15px, 3vw, 26px);
  min-width: 0;
}
.result:empty {
  display: none;
}
.result {
  position: relative;
  scroll-margin-block-start: 12px;
}
.related-tools {
  margin-top: 28px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}
.related-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 11px;
}
.related-head h2 { font-size: 22px; margin: 0; }
.tool-like { font-size: 13px; background: transparent !important; }
.tool-like[aria-pressed="true"] { opacity: .85; }
.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 232px), 1fr));
  gap: 8px;
}
.related-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.related-card:hover { border-color: var(--accent); }
.related-icon {
  display: grid;
  place-items: center;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--accent);
}
.related-icon svg { width: 19px; height: 19px; }
.related-card p,.related-card small { color: var(--muted); font-size: 13px; margin: 1px 0 0; }
.result h2,
.result h3 {
  margin: 0 0 8px;
}
.result p {
  margin: 0 0 8px;
}
.result ul {
  padding-inline-start: 23px;
  margin: 0;
}
.result li {
  overflow-wrap: anywhere;
}
.btn {
  border: 1px solid transparent;
  border-radius: var(--button-round, 12px);
  min-height: 44px;
  padding: 9px 13px;
  background: var(--accent);
  color: var(--button-ink, #fff);
  font-weight: 700;
  font-size: 14px;
}
.btn.secondary {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--line);
}
.btn:hover:not(:disabled),
.tool-nav button:hover {
  filter: brightness(0.94);
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
}
.field input,
.field textarea,
.field select {
  min-width: 0;
  width: 100%;
  color: var(--ink);
  background: var(--input, var(--soft));
  border: 1px solid var(--line);
  border-radius: var(--button-round, 12px);
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 400;
}
.field textarea {
  min-height: 104px;
  resize: vertical;
}
.fields,
.scores,
.group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.hint,
.copy-status {
  color: var(--muted);
  font-size: 13px;
}
.hint {
  margin: 6px 0 0;
}
.picked {
  color: var(--accent);
  font-size: clamp(25px, 6vw, 51px);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.error {
  color: var(--error, #a62642);
  font-weight: 650;
}
.skip {
  position: absolute;
  inset-inline-start: 12px;
  top: -100px;
  background: var(--surface);
  padding: 8px;
  z-index: 5;
}
.skip:focus {
  top: 8px;
}
.local-actions {
  padding-top: 10px;
  margin-top: 14px;
  border-top: 1px dashed var(--line);
}
.reveal {
  animation: reveal 0.38s cubic-bezier(0.2, 0.85, 0.37, 1.2) both;
}
.celebration {
  position: absolute;
  inset: 50% auto auto 50%;
  pointer-events: none;
  z-index: 5;
}
.celebration i {
  position: absolute;
  width: 8px;
  height: 10px;
  border-radius: 2px;
  background: var(--piece);
  animation: confetti 0.7s ease-out both;
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes confetti {
  0% {
    opacity: 1;
    transform: scale(0.45);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(150deg);
  }
}
.countdown-ring {
  --remaining: 100%;
  display: grid;
  place-items: center;
  margin: 8px auto 14px;
  width: min(80%, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(
    var(--ring, #82dbff) var(--remaining),
    var(--ring-track, #244b68) 0
  );
  position: relative;
  isolation: isolate;
}
.countdown-ring:before {
  content: "";
  position: absolute;
  inset: 9px;
  background: var(--surface);
  border-radius: 50%;
  z-index: -1;
}
.clock {
  display: block;
  font-size: clamp(37px, 10vw, 79px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.countdown-ring.done {
  animation: reveal 0.45s ease both;
}
.countdown-ring.ending {
  --ring: #ff927c;
  color: #ffc4b9;
}
.timer-settings {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 19px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.timer-presets {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.preset[aria-pressed="true"] {
  background: var(--accent);
  color: var(--button-ink, #fff);
}
.custom-timer {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: start;
}
.custom-timer summary {
  cursor: pointer;
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 700;
}
.custom-timer form {
  padding: 2px 12px 12px;
}
#duration-status:empty,
#share-status:empty {
  display: none;
}
.reveal-dialog {
  color: var(--ink);
  background: transparent;
  width: min(570px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  border: 0;
  padding: 0;
  border-radius: 27px;
}
.reveal-dialog::backdrop {
  background: #21132caa;
  backdrop-filter: blur(4px);
}
body:has(.reveal-dialog[open]) {
  overflow: hidden;
}
.reveal-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, var(--soft), var(--surface) 70%);
  text-align: center;
  border: 2px solid var(--line);
  border-radius: inherit;
  padding: clamp(19px, 6vw, 42px);
}
.reveal-dialog[open] .reveal-card {
  animation: reveal 0.35s ease-out both;
}
.reveal-card h2 {
  font-size: 15px;
  margin: 4px 0 8px;
}
.reveal-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  border-radius: 17px;
  background: var(--sticker);
  color: var(--sticker-ink);
  font-size: 27px;
}
.reveal-value {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: clamp(23px, 5vw, 42px);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.reveal-progress {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.reveal-card .actions {
  justify-content: center;
  margin-top: 20px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}
.metric {
  padding: 9px 12px;
  background: var(--soft);
  border-radius: 12px;
}
.metric dt {
  font-size: 14px;
  color: var(--muted);
}
.metric dd {
  font-size: 17px;
  font-weight: 750;
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 520px) {
  .tool {
    width: calc(100% - 26px);
    padding-top: 11px;
  }
  .tool-nav a,
  .tool-nav button {
    padding-inline: 7px;
    font-size: 12px;
  }
  .tool-head {
    margin-top: 15px;
    gap: 10px;
  }
  .tool-head p {
    font-size: 13px;
  }
  .group-grid {
    gap: 7px;
  }
  .fields {
    gap: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.utility-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; margin-block: 12px; }
.utility-table table { width: 100%; border-collapse: collapse; text-align: start; font-size: 14px; }
.utility-table th,.utility-table td { padding: 9px 10px; text-align: start; border-block-end: 1px solid var(--line); min-width: 90px; overflow-wrap: anywhere; }
.utility-table th { background: var(--soft); font-weight: 750; }
.utility-table tbody tr:last-child td { border-block-end: 0; }
.utility-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.utility-stage { padding: clamp(14px,4vw,30px); border-radius: 19px; background: var(--soft); text-align: center; overflow-wrap: anywhere; }
.utility-stage + .actions { justify-content: center; }
.utility-stage h3 { font-size: clamp(20px,4vw,34px); line-height: 1.4; }
.utility-stage :last-child { margin-block-end: 0; }
.utility-meta { color: var(--muted); font-size: 14px; }
@media print {
  body.printable { background: #fff; color: #000; }
  .printable .tool { width: 100%; padding: 0; }
  .printable .tool-nav,.printable .tool-head,.printable #tool-panel,.printable .related-tools,
  .printable #share-status,.printable .skip,.printable .hide-on-print { display: none !important; }
  .printable #result { display: block; border: 0; background: none; padding: 0; }
  .printable .utility-table { overflow: visible; }
  .printable .utility-table table { font-size: 11px; }
  .printable .utility-table th,.printable .utility-table td { min-width: 0; border-color: #bbb; }
  .printable tr { break-inside: avoid; }
}

:root {
  --ink:#3c2458;--muted:#624a79;--canvas:#f5edfe;--surface:#fffcff;--soft:#f1e7fc;
  --line:#e2d1f5;--accent:#673ba3;--banner:radial-gradient(circle at 11% 17%,#9a70d9 0,transparent 55%),#69439b;
  --sticker:#f5d7a4;--sticker-ink:#624397;--round:22px;
}
.flip-card {
  width:min(100%,620px);min-height:132px;padding:14px;margin:10px 0;
  border:2px solid #8b61bb;border-radius:20px;background:#fbf3ff;color:var(--ink);
  box-shadow:0 4px #b496d5;font-size:clamp(19px,4vw,31px);font-weight:800;overflow-wrap:anywhere;
}
.flip-card.flipped { background:#e8f6e9;color:#214f3a;border-color:#84b596;box-shadow:0 4px #9ac5aa;animation:reveal .28s ease both; }
.utility-stage .actions { justify-content:center; }
