:root {
      --accent: #a78bfa;
      --accent2: #3cdcff;
      --wood: #b45309;
      --wood2: #f59e0b;
      --ink: #0f172a;
      --bg: #05050a;
      --muted: rgba(255,255,255,.65);
      --panel: rgba(255,255,255,.06);
      --panel2: rgba(255,255,255,.1);
      --border: rgba(255,255,255,.14);
      --cell-empty: rgba(255,255,255,.05);
      --cell-target: rgba(167,139,250,.18);
      --cell-target-border: rgba(167,139,250,.35);
      --cell-selected: rgba(60,220,255,.25);
      --err: #ff3c3c;
    }
    html, body {
      margin: 0;
      padding: 0;
      background: var(--bg);
      color: #fff;
      height: 100%;
      overflow: hidden;
      font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
      touch-action: none;
      user-select: none;
    }
    * { box-sizing: border-box; }
    a, button { -webkit-tap-highlight-color: transparent; }
    .shell {
      position: relative;
      height: 100vh;
      height: 100dvh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      padding: max(10px, env(safe-area-inset-top)) 12px 12px;
      gap: 10px;
      box-sizing: border-box;
    }
    .topbar {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      z-index: 5;
    }
    .topbar-title {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 2px;
      min-width: 0;
    }
    .topbar-title .title {
      font-weight: 1000;
      letter-spacing: -0.02em;
      font-size: 1rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topbar-title .subtitle {
      font-size: 0.78rem;
      font-weight: 800;
      color: rgba(255,255,255,.7);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .topbar-stats {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }
    .chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      border: 1px solid rgba(255,255,255,.16);
      backdrop-filter: blur(10px);
      font-weight: 900;
      font-size: 0.78rem;
      color: #fff;
    }
    .chip b {
      font-variant-numeric: tabular-nums;
      direction: ltr;
      display: inline-block;
    }
    .back {
      text-decoration: none;
      color: #fff;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 7px 12px;
      border-radius: 999px;
      background: rgba(255,255,255,.08);
      border: 1px solid rgba(255,255,255,.18);
      backdrop-filter: blur(10px);
      font-weight: 700;
      font-size: 0.85rem;
    }.content {
      width: 100%;
      flex: 1;
      display: grid;
      grid-template-columns: 0.9fr 1.1fr;
      grid-template-areas: "panel board";
      gap: 12px;
      align-items: start;
    }
    @media (max-width: 991px) {
      html, body { overflow: auto; }
      .shell { min-height: 100vh; }
      .content { grid-template-columns: 1fr; }
    }
    .board-wrap {
      grid-area: board;
      background: rgba(255,255,255,.03);
      border: 1px solid rgba(255,255,255,.08);
      border-radius: 16px;
      padding: 12px;
      overflow: hidden;
    }
    .board {
      display: grid;
      gap: 0;
      background: rgba(255,255,255,.02);
      border-radius: 12px;
      touch-action: none;
      transform: translateZ(0);
      border: 1px solid rgba(255,255,255,.06);
      overflow: hidden;
    }
    .cell {
      width: var(--cell);
      height: var(--cell);
      background: var(--cell-empty);
      border: 1px solid rgba(255,255,255,.035);
    }
    .cell.target {
      background: var(--cell-target);
      border-color: var(--cell-target-border);
    }
    .cell.placed {
      background: linear-gradient(135deg, rgba(60,220,255,.22), rgba(167,139,250,.18));
      border-color: rgba(255,255,255,.14);
      box-shadow: inset 0 0 0 999px rgba(255,255,255,.02);
    }
    .cell.selected-preview {
      outline: 2px solid rgba(60,220,255,.6);
      outline-offset: -2px;
      background: rgba(60,220,255,.14);
      border-color: rgba(60,220,255,.35);
    }
    .panel {
      grid-area: panel;
      background: var(--panel);
      border: 1px solid rgba(255,255,255,.1);
      border-radius: 16px;
      padding: 12px;
      text-align: right;
    }
    .panel h2 {
      margin: 0 0 8px 0;
      font-size: 1rem;
      font-weight: 900;
      letter-spacing: .02em;
    }
    .small {
      color: var(--muted);
      font-size: 0.84rem;
      line-height: 1.7;
      margin-bottom: 10px;
    }
    .btnrow {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 10px;
    }
    button {
      font-family: inherit;
    }
    .btn {
      padding: 10px 12px;
      border-radius: 12px;
      background: rgba(255,255,255,.06);
      border: 1px solid rgba(255,255,255,.14);
      color: #fff;
      font-weight: 800;
      font-size: 0.9rem;
      cursor: pointer;
      transition: transform .12s ease, background .12s ease, border-color .12s ease;
    }.btn:active { transform: scale(0.98); }
    .btn.primary {
      border-color: rgba(60,220,255,.35);
      background: rgba(60,220,255,.12);
      box-shadow: 0 0 18px rgba(60,220,255,.12);
    }
    .btn.danger {
      border-color: rgba(255,60,60,.35);
      background: rgba(255,60,60,.12);
    }
    .pieces {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin-top: 10px;
    }
    .piece-btn {
      text-align: right;
      width: 100%;
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(255,255,255,.04);
      border: 1px solid rgba(255,255,255,.12);
      cursor: pointer;
      transition: transform .12s ease, border-color .12s ease, background .12s ease;
      color: #fff;
    }
    .piece-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .piece-preview {
      display: grid;
      gap: 3px;
      grid-auto-flow: row;
      padding: 6px;
      border-radius: 12px;
      background: rgba(255,255,255,.04);
      border: 1px solid rgba(255,255,255,.10);
      flex-shrink: 0;
    }
    .piece-preview .px {
      width: 10px;
      height: 10px;
      border-radius: 3px;
      background: rgba(255,255,255,.06);
      border: 1px solid rgba(255,255,255,.08);
    }
    .piece-preview .px.on {
      background: linear-gradient(135deg, rgba(60,220,255,.35), rgba(167,139,250,.25));
      border-color: rgba(255,255,255,.18);
      box-shadow: 0 4px 14px rgba(60,220,255,.10);
    }
    .piece-btn.active {
      border-color: rgba(60,220,255,.55);
      background: rgba(60,220,255,.14);
      box-shadow: 0 0 18px rgba(60,220,255,.12);
    }
    .piece-btn.disabled {
      opacity: 0.5;
      cursor: default;
    }
    .piece-name { font-weight: 950; font-size: 0.92rem; }
    .piece-size {
      color: var(--muted);
      font-weight: 900;
      font-size: 0.82rem;
    }
    .preview-hint {
      margin-top: 10px;
      color: var(--muted);
      font-weight: 800;
      font-size: 0.85rem;
      min-height: 20px;
    }
    .error {
      color: var(--err);
      font-weight: 900;
      font-size: 0.85rem;
      min-height: 20px;
    }
    .win {
      position: fixed;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(0,0,0,.6);
      z-index: 50;
    }
    .win-card {
      width: min(520px, 100%);
      border-radius: 18px;
      background: rgba(20,20,35,.96);
      border: 1px solid rgba(255,255,255,.16);
      box-shadow: 0 24px 80px rgba(0,0,0,.4);
      padding: 16px;
    }
    .win-card h2 { margin: 0 0 6px 0; font-weight: 1000; }
    .win-card p { margin: 0 0 10px 0; color: var(--muted); font-weight: 800; line-height: 1.7; }
    .win-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-start; }
    .shake {
      animation: shake .18s ease-in-out 0s 2;
    }
    @keyframes shake {
      0% { transform: translateX(0); }
      33% { transform: translateX(-6px); }
      66% { transform: translateX(6px); }
      100% { transform: translateX(0); }
    }
