:root {
  --ink: #202322;
  --muted: #69706d;
  --paper: #f6f4ef;
  --panel: #fffefa;
  --line: #d9d8d1;
  --yellow: #f2df6b;
  --green: #b8d8bc;
  --blue: #a8c9e6;
  --purple: #c6b7e5;
  --red: #b75745;
  --shadow: 0 18px 45px rgba(32, 35, 34, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Vazirmatn", sans-serif;
  direction: rtl;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .42;
  background-image: radial-gradient(#d4d0c5 .7px, transparent .7px);
  background-size: 17px 17px;
}
button { font: inherit; }
.shell { width: min(100% - 40px, 860px); margin: 0 auto; position: relative; }
.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand-mark { display: flex; align-items: center; gap: 10px; font-family: "Vazirmatn", sans-serif; font-weight: 800; font-size: 21px; }
.brand-dot { display: inline-block; width: 15px; height: 15px; background: var(--ink); transform: rotate(45deg); }
.date-stamp, .eyebrow, .status-label { font-family: "Vazirmatn", sans-serif; letter-spacing: 0; font-size: 10px; }
.date-stamp { color: var(--muted); }
.icon-button, .close-button { border: 1px solid var(--ink); background: transparent; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-weight: 600; }
.intro { padding: 74px 0 40px; max-width: 700px; }
.eyebrow { color: var(--red); font-weight: 500; margin: 0 0 16px; }
h1, h2 { font-family: "Vazirmatn", sans-serif; letter-spacing: 0; line-height: 1.25; margin: 0; }
h1 { font-size: clamp(38px, 6vw, 62px); max-width: 600px; }
.instructions { color: var(--muted); font-size: 16px; line-height: 1.65; max-width: 545px; margin: 20px 0 0; }
.game-panel { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 24px; }
.status-row, .actions { display: flex; align-items: center; justify-content: space-between; min-height: 35px; }
.mistakes { display: flex; align-items: center; gap: 13px; }
.status-label { color: var(--muted); letter-spacing: .03em; font-size: 11px; }
.mistake-dots { display: flex; gap: 5px; }
.mistake-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.mistake-dot.used { background: #d7d5cc; }
.text-button, .footer-button { color: var(--ink); background: transparent; border: 0; cursor: pointer; padding: 7px 0; font-size: 13px; font-weight: 600; }
.text-button:hover, .footer-button:hover { color: var(--red); }
.shuffle-icon { display: inline-block; font-size: 19px; margin-left: 4px; vertical-align: -1px; }
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 22px 0 26px; }
.tile { min-height: 75px; border: 1px solid #d5d4cb; background: #f1f0ea; color: var(--ink); padding: 8px 4px; border-radius: 3px; cursor: pointer; font-size: clamp(12px, 1.8vw, 15px); font-weight: 700; letter-spacing: .02em; transition: background .16s, transform .16s, border-color .16s; }
.tile:hover { border-color: var(--ink); transform: translateY(-2px); }
.tile.selected { background: var(--ink); color: white; border-color: var(--ink); transform: translateY(-2px); }
.tile:focus-visible, button:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.tile-grid.shake { animation: shake .38s ease; }
.solved-groups { display: grid; gap: 9px; }
.solved-group { padding: 17px 19px; display: flex; flex-direction: column; gap: 5px; border-radius: 3px; animation: reveal .35s ease both; }
.solved-group strong { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.solved-group span { font-size: 13px; }
.group-yellow { background: var(--yellow); }.group-green { background: var(--green); }.group-blue { background: var(--blue); }.group-purple { background: var(--purple); }
.actions { border-top: 1px solid var(--line); padding-top: 19px; }
.selection-count { font-family: "Vazirmatn", sans-serif; font-size: 11px; color: var(--muted); }
.submit-button { border: 0; border-radius: 3px; background: var(--ink); color: white; padding: 11px 24px; cursor: pointer; font-weight: 700; transition: opacity .15s, transform .15s; }
.submit-button:hover:not(:disabled) { transform: translateY(-1px); }
.submit-button:disabled { opacity: .3; cursor: not-allowed; }
.message { min-height: 20px; color: var(--red); font-size: 13px; text-align: center; margin: 15px 0 0; }
.result-actions { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.result-actions[hidden] { display: none; }
.share-button { border: 1px solid var(--ink); border-radius: 3px; background: transparent; color: var(--ink); padding: 9px 16px; cursor: pointer; font-weight: 700; }
.share-button:hover { background: var(--ink); color: white; }
.share-status { color: var(--muted); font-size: 12px; }
.footer { display: flex; justify-content: center; align-items: center; gap: 15px; padding: 28px 0 54px; color: var(--muted); }.footer-divider { font-size: 10px; color: var(--line); }
.help-dialog { width: min(420px, calc(100% - 40px)); border: 1px solid var(--line); padding: 34px; color: var(--ink); box-shadow: var(--shadow); }.help-dialog::backdrop { background: rgba(32,35,34,.28); }.help-dialog h2 { font-size: 38px; margin-bottom: 18px; }.help-dialog p:not(.eyebrow) { line-height: 1.65; color: var(--muted); font-size: 14px; }.close-button { position: absolute; right: 18px; top: 18px; font-size: 18px; font-weight: 400; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@media (max-width: 600px) { .shell { width: min(100% - 24px, 500px); }.topbar { height: 70px; }.date-stamp { display: none; }.intro { padding: 53px 0 31px; }.game-panel { padding: 16px; }.tile { min-height: 70px; }.status-row { align-items: flex-start; }.mistakes { flex-direction: column; align-items: flex-start; gap: 7px; } }
