﻿:root{
      --boardW: 420px;
      --sidePanelW: 560px;
      --gap: 22px;

      --bg1: #0b0f14;
      --bg2: #101a22;
      --card: rgba(255,255,255,.92);
      --stroke: rgba(0,0,0,.10);
      --shadow: 0 14px 40px rgba(0,0,0,.18);
      --radius: 16px;

    }

    body{
      margin:0;
      padding:22px;
      font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
      color:#111;
      background:
        radial-gradient(900px 600px at 15% 10%, rgba(255,255,255,.10), transparent 55%),
        radial-gradient(900px 600px at 90% 25%, rgba(255,255,255,.08), transparent 55%),
        linear-gradient(160deg, var(--bg1), var(--bg2));
      min-height:100vh;
    }

    .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
    .tiny{ font-size:13px; opacity:.82; line-height:1.35; }
    .ok{ color:#0a7a2f; font-weight:800; }
    .bad{ color:#b00020; font-weight:800; }

    #wrap{
      max-width: calc((var(--sidePanelW) * 2) + var(--boardW) + (var(--gap) * 2));
      margin: 0 auto;
      display:grid;
      gap: var(--gap);
      align-items:start;
      grid-template-columns: var(--sidePanelW) var(--boardW) var(--sidePanelW);
      grid-template-areas: "left board panel";
    }
    #leftCol{ grid-area:left; }
    #boardCol{ grid-area:board; }
    #panelCol{ grid-area:panel; }

    .siteFooter{
      max-width: calc((var(--sidePanelW) * 2) + var(--boardW) + (var(--gap) * 2));
      margin: 26px auto 0;
      padding: 8px 4px 0;
      display:flex;
      flex-wrap:wrap;
      justify-content:space-between;
      gap:8px 18px;
      color: rgba(255,255,255,.72);
    }
    .siteFooterLink{
      color: rgba(255,255,255,.94);
      text-decoration: none;
      border-bottom: 1px solid rgba(255,255,255,.24);
    }
    .siteFooterLink:hover{
      border-bottom-color: rgba(255,255,255,.52);
    }

    .updateBanner{
      position: fixed;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      z-index: 1000;
      display: flex;
      align-items: center;
      gap: 12px;
      width: min(92vw, 520px);
      padding: 12px 14px;
      border-radius: 14px;
      border: 1px solid rgba(255,255,255,.16);
      background: rgba(12, 18, 26, .94);
      color: rgba(255,255,255,.96);
      box-shadow: 0 18px 40px rgba(0,0,0,.30);
      backdrop-filter: blur(10px);
    }
    .updateBanner[hidden]{
      display: none !important;
    }
    .updateBannerText{
      flex: 1 1 auto;
      font-size: 14px;
      line-height: 1.35;
    }
    .updateBannerBtn{
      flex: 0 0 auto;
      min-width: 96px;
      border: 0;
      border-radius: 10px;
      background: #f0c14b;
      color: #1d1505;
      font-weight: 800;
      cursor: pointer;
      padding: 10px 14px;
    }
    .updateBannerBtn:disabled{
      opacity: .6;
      cursor: wait;
    }

    .card{
      background: var(--card);
      border:1px solid var(--stroke);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 12px 14px;
      backdrop-filter: blur(8px);
    }

    #boardCol{
      position: relative;
      width: var(--boardW);
      max-width: 100%;
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-self: center;
      margin-inline: auto;
      overscroll-behavior: contain;
      -webkit-user-select: none;
      user-select: none;
    }
    #board{
      width: 100%;
      border-radius: 14px;
      overflow:hidden;
      box-shadow: 0 18px 50px rgba(0,0,0,.28);
      border: 1px solid rgba(255,255,255,.10);
      touch-action: none;
      overscroll-behavior: contain;
      -webkit-user-select: none;
      user-select: none;
    }

    /* ===== Board themes ===== */
    #board .board-b72b1{
      border-width: 2px;
      border-style: solid;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 14px 32px rgba(0,0,0,.28);
    }
    #board [data-square].isTapMoveSelected{
      box-shadow:
        inset 0 0 0 4px rgba(255, 222, 89, .92),
        inset 0 0 0 1px rgba(24, 18, 6, .28);
    }

    body[data-board-theme="slate"] #board .board-b72b1{
      border-color: #2b3440;
      background:
        radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.05), transparent 55%),
        linear-gradient(180deg, #171f28, #121920);
    }
    body[data-board-theme="slate"] #board .white-1e1d7{
      background:
        radial-gradient(170% 120% at 15% 10%, rgba(255,255,255,.20), transparent 55%),
        linear-gradient(145deg, #c8d0db, #a8b4c4) !important;
      color: #5f6d7f !important;
    }
    body[data-board-theme="slate"] #board .black-3c85d{
      background:
        radial-gradient(170% 120% at 80% 90%, rgba(255,255,255,.10), transparent 60%),
        linear-gradient(145deg, #59687c, #3e4a5b) !important;
      color: #c9d2de !important;
    }

    body[data-board-theme="walnut"] #board .board-b72b1{
      border-color: #4f3320;
      background:
        radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.08), transparent 55%),
        linear-gradient(180deg, #6b4329, #4f3320);
    }
    body[data-board-theme="walnut"] #board .white-1e1d7{
      background:
        radial-gradient(170% 120% at 18% 12%, rgba(255,255,255,.18), transparent 56%),
        linear-gradient(145deg, #e6d5b5, #d6be96) !important;
      color: #a67f58 !important;
    }
    body[data-board-theme="walnut"] #board .black-3c85d{
      background:
        radial-gradient(170% 120% at 80% 88%, rgba(255,255,255,.08), transparent 58%),
        linear-gradient(145deg, #b38862, #986f4f) !important;
      color: #e7d8c1 !important;
    }

    body[data-board-theme="dark-wood"] #board .board-b72b1{
      border-color: #3e2214;
      background:
        radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.06), transparent 55%),
        linear-gradient(180deg, #5b311e, #3f2316);
    }
    body[data-board-theme="dark-wood"] #board .white-1e1d7{
      background:
        repeating-linear-gradient(
          0deg,
          rgba(130, 95, 58, 0.06) 0px,
          rgba(130, 95, 58, 0.06) 2px,
          rgba(218, 177, 118, 0.06) 2px,
          rgba(218, 177, 118, 0.06) 5px
        ),
        radial-gradient(170% 120% at 15% 10%, rgba(255,255,255,.16), transparent 56%),
        linear-gradient(145deg, #d9b175, #c89f64) !important;
      color: #90683f !important;
    }
    body[data-board-theme="dark-wood"] #board .black-3c85d{
      background:
        repeating-linear-gradient(
          0deg,
          rgba(130, 80, 50, 0.08) 0px,
          rgba(130, 80, 50, 0.08) 2px,
          rgba(78, 44, 28, 0.08) 2px,
          rgba(78, 44, 28, 0.08) 5px
        ),
        radial-gradient(170% 120% at 80% 88%, rgba(255,255,255,.08), transparent 58%),
        linear-gradient(145deg, #7e4a33, #5f3424) !important;
      color: #e3caa9 !important;
    }

    #cheatLine{
      margin-top: 12px;
      width: 100%;
      text-align:center;
      font-size:14px;
      line-height:1.7;
      color: rgba(255,255,255,.90);
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(0,0,0,.22);
      border: 1px solid rgba(255,255,255,.12);
      box-shadow: 0 14px 40px rgba(0,0,0,.18);
      display:block;
      min-height: 22px;
      word-break: break-word;
    }
    .cheatToken{
      display:inline-block;
      padding: 1px 2px;
      border-radius: 6px;
      transition: color .15s ease, opacity .15s ease, background-color .15s ease;
    }
    .cheatMoveNo{
      display:inline-block;
      margin-right: 4px;
      color: rgba(255,255,255,.55);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: .02em;
    }
    .cheatToken.isWhiteMove{
      color: rgba(255,255,255,.96);
    }
    .cheatToken.isBlackMove{
      color: #7df0a8;
    }
    .cheatToken.isPlayed{
      opacity: .42;
    }
    .cheatToken.isCurrent{
      background: rgba(255,255,255,.16);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
      opacity: 1;
      font-weight: 800;
    }

    #moveStrengthBadge{
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 7;
      min-height: 20px;
      max-width: calc(100% - 20px);
      padding: 8px 12px;
      border-radius: 12px;
      border: 1px solid rgba(255,255,255,.14);
      background: rgba(8,12,18,.74);
      color: rgba(255,255,255,.92);
      text-align: right;
      font-size: 26px;
      line-height: 1.15;
      box-shadow: 0 10px 28px rgba(0,0,0,.30);
      pointer-events: none;
      visibility: hidden;
      opacity: 0;
      transform: translateY(-4px);
      transition: opacity .18s ease, transform .18s ease;
    }
    #moveStrengthBadge.isVisible{
      visibility: visible;
      opacity: 1;
      transform: translateY(0);
    }
    #moveStrengthBadge[data-label="brilliant"]{ background: rgba(180, 110, 0, .76); }
    #moveStrengthBadge[data-label="great"]{ background: rgba(18, 87, 143, .78); }
    #moveStrengthBadge[data-label="best"]{ background: rgba(21, 34, 49, .78); }
    #moveStrengthBadge[data-label="playable"]{ background: rgba(10, 122, 47, .76); }
    #moveStrengthBadge[data-label="dubious"]{ background: rgba(136, 92, 0, .78); }
    #moveStrengthBadge[data-label="mistake"]{ background: rgba(160, 68, 0, .80); }
    #moveStrengthBadge[data-label="blunder"]{ background: rgba(176, 0, 32, .82); }

    #puzzleArrowOverlay{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      aspect-ratio: 1 / 1;
      z-index: 6;
      pointer-events: none;
      overflow: visible;
      visibility: hidden;
      opacity: 0;
      transition: opacity .16s ease;
    }
    #puzzleArrowOverlay.isVisible{
      visibility: visible;
      opacity: 1;
    }
    #puzzleHintBadge{
      position: absolute;
      top: 50%;
      left: 50%;
      z-index: 8;
      min-width: 48px;
      min-height: 48px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      background: rgba(255, 244, 186, .92);
      color: #7c5200;
      border: 1px solid rgba(124, 82, 0, .18);
      box-shadow: 0 12px 30px rgba(0,0,0,.22);
      pointer-events: none;
      visibility: hidden;
      opacity: 0;
      transform: translate(-50%, -50%) scale(.92);
      transition: opacity .18s ease, transform .18s ease;
      font-size: 28px;
      line-height: 1;
    }
    #puzzleHintBadge.isVisible{
      visibility: visible;
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
      animation: puzzleHintPulse 1s ease;
    }
    #puzzleHintBadge[data-label="brilliant"]{
      background: rgba(255, 239, 163, .96);
      color: #9a6700;
    }
    #puzzleHintBadge[data-label="great"]{
      background: rgba(225, 244, 255, .94);
      color: #0f4c81;
    }
    #puzzleHintBadge[data-label="blunder"]{
      background: rgba(255, 221, 221, .96);
      color: #9f1239;
    }
    @keyframes puzzleHintPulse{
      0%{
        opacity: 0;
        transform: translate(-50%, -50%) scale(.82);
      }
      25%{
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.08);
      }
      60%{
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
      }
      100%{
        opacity: 0;
        transform: translate(-50%, -50%) scale(.92);
      }
    }

    body.drillMode #cheatLine{
      display:block !important;
      visibility:visible !important;
      opacity:1 !important;
    }

    textarea{
      width:100%;
      height:120px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      border-radius: 12px;
      border:1px solid rgba(0,0,0,.14);
      padding: 10px;
      outline:none;
      resize: vertical;
      background:#fff;
    }

    /* SAN input: keep default width, only make it deeper for long lines */
    #lineInput{
      height: 88px;
      min-height: 88px;
      padding-top: 10px;
      padding-bottom: 10px;
      width: 100%;
      transform: none;
      box-sizing: border-box;
    }

    #lineTip,
    #openingSearchHint{
      display:none;
    }

    #myLibraryDetails summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 12px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 8px 11px;
      font-size: 14px;
      line-height: 1.1;
      font-weight: 700;
      color: #222;
      list-style: none;
    }
    #myLibraryDetails summary::-webkit-details-marker{ display:none; }
    #myLibraryDetails summary::after{
      content: "+";
      font-weight: 900;
      opacity: .75;
    }
    #myLibraryDetails[open] summary::after{
      content: "-";
    }

    input{
      border-radius:12px;
      border:1px solid rgba(0,0,0,.14);
      padding: 9px 10px;
      outline:none;
      background:#fff;
    }

    .row{ margin:10px 0; }
    .rowFlex{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
    .chip{
      display:inline-block;
      padding:2px 9px;
      border:1px solid rgba(0,0,0,.12);
      border-radius:999px;
      font-size:12px;
      background: rgba(255,255,255,.75);
    }

    .listcol{ display:flex; flex-direction:column; gap:6px; margin-top:10px; }
    .listbtn{
      width:100%;
      text-align:left;
      border-radius: 12px;
      border:1px solid rgba(0,0,0,.12);
      background:#fff;
      padding: 9px 10px;
      cursor:pointer;
    }
    .listbtn:hover{ filter: brightness(.98); }
    .listbtn.isActive{
      border-color: rgba(21,34,49,.24);
      background: #f6f8fb;
    }
    .openingListTitle{
      display:block;
      font-weight: 800;
      line-height: 1.25;
      color: #152231;
    }
    .openingProgressWrap{
      margin-top: 8px;
      display:flex;
      flex-direction:column;
      gap:6px;
    }
    .openingProgressMeta{
      font-size: 12px;
      line-height: 1.25;
      color: rgba(21,34,49,.72);
    }
    .openingProgressBar{
      position: relative;
      width: 100%;
      height: 8px;
      border-radius: 999px;
      overflow: hidden;
      background: rgba(21,34,49,.10);
    }
    .openingProgressBarFill{
      position: absolute;
      inset: 0 auto 0 0;
      width: 0%;
      border-radius: inherit;
      background: linear-gradient(90deg, #2d6a4f, #74c69d);
    }
    .openingProgressDetails{
      display:flex;
      flex-direction:column;
      gap:4px;
      padding-top: 2px;
      font-size: 12px;
      line-height: 1.35;
      color: rgba(21,34,49,.82);
    }
    .openingProgressGrade{
      font-weight: 800;
      color: #152231;
    }
    .openingProgressSubtitle{
      color: rgba(21,34,49,.60);
    }

    .progressionPanel{
      margin-bottom: 12px;
      padding: 10px 12px;
      border: 1px solid rgba(0,0,0,.10);
      border-radius: 14px;
      background: rgba(255,255,255,.72);
    }
    .progressionPanelHead{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
    }
    #progressionGlobal{
      display:grid;
      gap:6px;
    }
    .progressionMetricRow{
      display:flex;
      flex-wrap:wrap;
      gap:8px 14px;
    }
    .progressionMetric{
      min-width: 120px;
    }
    .progressionMetric--withIcon{
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .progressionMetricLabel{
      display: inline-flex;
      align-items: center;
    }
    .progressionMetricValueWrap{
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-weight: 700;
    }
    .progressionMetricValue{
      display: inline-flex;
      align-items: center;
    }
    .progressionMetricIcon{
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      flex: 0 0 20px;
      overflow: hidden;
    }
    .progressionMetricIcon svg{
      display: block;
      width: 20px;
      height: 20px;
    }
    .progressionHero{
      display:grid;
      gap:8px;
      margin-bottom: 10px;
    }
    .progressionHeroMeta{
      display:flex;
      flex-wrap:wrap;
      align-items:center;
      gap:8px 14px;
    }
    .progressionGradeValue{
      font-weight: 800;
      color: #152231;
    }
    .progressionLevelBar{
      position: relative;
      width: 100%;
      height: 10px;
      border-radius: 999px;
      overflow: hidden;
      background: rgba(21,34,49,.10);
    }
    .progressionLevelBarFill{
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 0%;
      border-radius: inherit;
      background: linear-gradient(90deg, #1d4ed8, #60a5fa);
      box-shadow: 0 0 0 1px rgba(29,78,216,.08) inset;
    }
    #playerDetails summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 12px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 8px 11px;
      font-size: 14px;
      line-height: 1.1;
    }
    .playerPanelBody{
      display:grid;
      gap:8px;
      margin-top:8px;
    }
    .playerIdentityRow{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
      align-items:center;
    }
    .playerAvatar{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      width: 16px;
      height: 16px;
      flex: 0 0 16px;
      overflow: hidden;
      border-radius: 5px;
    }
    .playerAvatar svg{
      display:block;
      width: 16px;
      height: 16px;
    }
    #playerProfileTitles{
      min-height: 20px;
    }
    .playerHeroSummary{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      min-height: 24px;
    }
    .playerHeroSummaryBadges{
      flex: 1 1 auto;
    }
    .playerHeroLevelIcon{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      width: 24px;
      height: 24px;
      flex: 0 0 24px;
      border-radius: 999px;
      background: rgba(21,34,49,.06);
      border: 1px solid rgba(21,34,49,.10);
      overflow: hidden;
    }
    .playerHeroLevelIcon svg{
      display:block;
      width: 20px;
      height: 20px;
    }
    .playerBadgeSections{
      display:grid;
      gap:10px;
      margin-top:10px;
    }
    .playerBadgeSection{
      display:grid;
      gap:6px;
    }
    .playerBadgeHeading{
      font-weight: 800;
      letter-spacing: .02em;
      color: rgba(21,34,49,.78);
    }
    .playerBadgeList{
      display:grid;
      gap:6px;
    }
    .playerBadgeChipList{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
    }
    .playerBadgeChipList.isCompact{
      gap:5px;
    }
    .playerBadgeChip{
      display:inline-flex;
      align-items:center;
      gap:7px;
      border-radius: 999px;
      border: 1px solid rgba(21,34,49,.12);
      background: rgba(255,255,255,.82);
      color: #152231;
      padding: 5px 10px;
      line-height: 1.2;
    }
    .playerBadgeChip--summary{
      background: linear-gradient(180deg, #fff, #f6f8fb);
    }
    .playerBadgeChip--global{
      background: linear-gradient(180deg, #fff6d8, #fde68a);
      border-color: rgba(146, 64, 14, .18);
    }
    .playerBadgeChip--local{
      background: linear-gradient(180deg, #eef6ff, #dbeafe);
      border-color: rgba(29, 78, 216, .16);
    }
    .playerBadgeChipIcon{
      display:inline-flex;
      align-items:center;
      justify-content:center;
      width: 22px;
      height: 22px;
      flex: 0 0 22px;
      overflow: hidden;
    }
    .playerBadgeChipIcon svg{
      display:block;
      width: 22px;
      height: 22px;
    }
    .playerBadgeChipText{
      font-size: 12px;
      font-weight: 700;
    }
    #playerAdvancedDetails summary{
      cursor: pointer;
      user-select: none;
    }
    .playerPanelActions{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      margin-top:10px;
    }
    .playerAuthStatus{
      min-height: 18px;
      color: rgba(21,34,49,.76);
    }
    .playerAuthStatus.isSignedIn{
      color: #0a7a2f;
    }
    .playerAuthStatus.isGuest{
      color: rgba(21,34,49,.68);
    }
    .playerAuthStatus.isUnavailable{
      color: #9f1239;
    }
    .playerAuthActions{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      margin-top:0;
    }

    #openingSearchDetails summary,
    #openingsDetails summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 12px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 8px 11px;
      font-size: 14px;
      line-height: 1.1;
      font-weight: 700;
      color: #222;
      list-style: none;
    }
    #openingSearchDetails summary::-webkit-details-marker,
    #openingsDetails summary::-webkit-details-marker{ display:none; }

    #openingSearchResults{
      max-height: min(46vh, 420px);
      overflow-y: auto;
      padding-right: 4px;
    }
    .openingSearchGroup{
      border: 1px solid rgba(0,0,0,.10);
      border-radius: 14px;
      background: rgba(255,255,255,.78);
      padding: 8px;
    }
    .openingSearchGroupTitle{
      font-weight: 800;
      font-size: 13px;
      letter-spacing: .02em;
      margin-bottom: 6px;
      color: #243241;
    }
    .openingSearchItem{
      display:flex;
      flex-direction:column;
      gap:6px;
    }
    .openingSearchRow{
      width:100%;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      text-align:left;
      border-radius: 12px;
      border: 1px solid rgba(0,0,0,.09);
      background: #fff;
      padding: 10px;
    }
    .openingSearchRow.isActive{
      border-color: rgba(21,34,49,.28);
      background: #f6f8fb;
    }
    .openingSearchRowTitle{
      flex: 1 1 auto;
      font-weight: 800;
      line-height: 1.25;
      color: #152231;
    }
    .openingSearchRowMeta{
      flex: 0 0 auto;
      font-size: 12px;
      line-height: 1.25;
      color: rgba(21,34,49,.68);
      text-align: right;
      white-space: nowrap;
    }
    .openingSearchDetailsCard{
      border: 1px solid rgba(0,0,0,.09);
      border-radius: 12px;
      background: #fff;
      padding: 10px;
    }
    .openingSearchDetailsHeader{
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap:8px;
    }
    .openingSearchCloseBtn{
      flex:0 0 auto;
      min-width: 34px;
      height: 34px;
      padding: 0;
      border-radius: 999px;
      font-size: 22px;
      line-height: 1;
    }
    .openingSearchSideRow{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      margin-top:8px;
    }
    .openingSearchSideLabel{
      font-size: 12px;
      line-height: 1.2;
      color: rgba(21,34,49,.72);
      font-weight: 700;
    }
    .openingSearchSideButtons{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
    }
    .openingSideBtn{
      min-width: 86px;
      padding: 6px 10px;
      border-radius: 999px;
      font-size: 12px;
      line-height: 1.1;
    }
    .openingSideBtn.isActive{
      background: #152231;
      color: #fff;
      border-color: #152231;
    }
    .openingSearchActions{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
      margin-top:8px;
    }
    .openingActionBtn{
      flex:1 1 110px;
      min-width:110px;
    }
    .openingSearchBasicHint{
      margin-top: 8px;
      color: rgba(21,34,49,.72);
    }
    .openingActionBtn.isPrimary{
      background: #152231;
      color: #fff;
      border-color: #152231;
    }
    .openingPreviewLine{
      font-size:12px;
      line-height:1.4;
      color: rgba(21,34,49,.76);
    }

    @media (max-width: 680px){
      #openingSearchResults{
        max-height: min(38vh, 360px);
      }
      .openingSearchRow{
        align-items:flex-start;
        flex-direction:column;
      }
      .openingSearchRowMeta{
        text-align:left;
        white-space:normal;
      }
      .openingSearchSideRow{
        align-items:flex-start;
        flex-direction:column;
      }
    }

    button{
      border-radius: 12px;
      border:1px solid rgba(0,0,0,.14);
      background:#fff;
      padding: 8px 11px;
      cursor:pointer;
      font-weight: 700;
    }
    button:hover{ filter: brightness(.98); }
    button:disabled{ opacity:.5; cursor:not-allowed; }

    #setupControlsBox{
      padding: 10px 12px;
    }

    #primaryControls{
      display:flex;
      align-items:center;
      gap:8px;
      margin-bottom: 8px;
    }

    #startBtn{
      min-width: 92px;
      padding: 9px 14px;
      border-radius: 13px;
      font-weight: 800;
    }
    #backBtn{
      display:none;
      min-width: 92px;
      padding: 9px 14px;
      border-radius: 13px;
      font-weight: 800;
    }

    #basicNotesDetails{
      margin-top: 10px;
    }
    #basicNotesDetails summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      border-radius: 11px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 7px 10px;
      font-size: 14px;
      line-height: 1.1;
      font-weight: 700;
      color: #222;
      list-style: none;
    }
    #basicNotesDetails summary::-webkit-details-marker{ display:none; }
    #basicNotesDetails summary::after{
      content: "+";
      font-weight: 900;
      opacity: .75;
    }
    #basicNotesDetails[open] summary::after{
      content: "-";
    }
    #basicNotesDetails[open] .tiny{
      border: 1px solid rgba(0,0,0,.10);
      border-radius: 12px;
      background: rgba(255,255,255,.72);
      padding: 10px 12px;
      width: min(340px, 100%);
      box-shadow: 0 6px 16px rgba(0,0,0,.06);
    }

    #advancedControls{
      margin-top: 2px;
      padding: 0;
    }
    #advancedControls[open]{
      border: 1px solid rgba(0,0,0,.10);
      border-radius: 12px;
      background: rgba(255,255,255,.72);
      padding: 8px;
    }

    #advancedControls summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      width: 132px;
      max-width: 100%;
      gap: 8px;
      border-radius: 11px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 7px 10px;
      font-size: 14px;
      line-height: 1.1;
      font-weight: 700;
      color: #222;
      margin: 0;
      list-style: none;
    }
    #advancedControls summary::-webkit-details-marker{ display:none; }
    #advancedControls summary::after{ content: ""; }

    #controlsRow{
      display:flex;
      gap:8px;
      flex-wrap:wrap;
      margin-top: 8px;
    }

    #languageRow{
      margin-top: 8px;
    }

    #languageBtn{
      padding: 7px 10px;
      border-radius: 11px;
      font-size: 14px;
      line-height: 1.1;
    }

    #controlsRow button{
      padding: 7px 10px;
      border-radius: 11px;
      font-size: 14px;
      line-height: 1.1;
    }

    #boardOptionsBox{
      margin-top: 10px;
      border: 0;
      border-radius: 0;
      background: transparent;
      padding: 0;
    }

    #boardOptionsDetails{
      margin-top: 10px;
      padding: 0;
    }
    #boardOptionsDetails[open]{
      border: 1px solid rgba(0,0,0,.10);
      border-radius: 12px;
      background: rgba(255,255,255,.72);
      padding: 8px;
    }
    #boardOptionsDetails summary{
      cursor: pointer;
      user-select: none;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      width: 132px;
      max-width: 100%;
      gap: 8px;
      border-radius: 11px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      padding: 7px 10px;
      font-size: 14px;
      line-height: 1.1;
      font-weight: 700;
      color: #222;
      list-style: none;
    }
    #boardOptionsDetails summary::-webkit-details-marker{ display:none; }
    #boardOptionsDetails summary::after{ content: ""; }

    #boardOptionsRow{
      display:flex;
      gap:8px;
      flex-wrap:wrap;
      margin-top: 6px;
    }

    #boardOptionsRow button{
      padding: 7px 10px;
      border-radius: 11px;
      font-size: 14px;
      line-height: 1.1;
    }

    #assistanceOptionsBox{
      display:flex;
      flex-direction:column;
      gap:8px;
      margin-top: 8px;
    }

    .assistanceLabelsBox{
      display:flex;
      flex-wrap:wrap;
      gap:6px;
    }
    .assistanceLabelsBox.isDisabled{
      opacity:.58;
    }

    .assistanceLabelToggle{
      display:inline-flex;
      align-items:center;
      gap:6px;
      padding: 6px 9px;
      border-radius: 10px;
      border:1px solid rgba(0,0,0,.12);
      background:#fff;
      font-size:13px;
      line-height:1.1;
      font-weight:700;
      color:#222;
      cursor:pointer;
    }
    .assistanceLabelToggle input{
      margin:0;
      width:auto;
    }

    .orientationModeBtn.isActive{
      background: #152231;
      color: #fff;
      border-color: #152231;
    }

    .grid2{
      display:grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    #moreRecordsDetails{
      margin-top: 10px;
      border-top: 1px solid rgba(0,0,0,.10);
      padding-top: 8px;
    }
    #moreRecordsDetails summary{
      cursor: pointer;
      user-select: none;
      display: flex;
      align-items: center;
      justify-content: space-between;
      list-style: none;
      font-size: 13px;
      font-weight: 700;
      color: #2d3846;
      margin: 0;
    }
    #moreRecordsDetails summary::-webkit-details-marker{ display:none; }
    #moreRecordsDetails summary::after{
      content: "▸";
      font-size: 15px;
      line-height: 1;
      opacity: .85;
    }
    #moreRecordsDetails[open] summary::after{
      content: "▾";
    }

    #feedback{ min-height:24px; }

    .blindfold{ opacity:0; pointer-events:auto; }
    .isHidden{ display:none !important; }

    /* ===== Openings scroll (fix) ===== */
    #leftCol{
      height: calc(100vh - 44px);
      display: flex;
      flex-direction: column;
      min-height: 0;
      gap: 12px;
      overflow: hidden;
    }
    #setupOpenings{
      flex: 1 1 auto;
      display:flex;
      flex-direction:column;
      min-height:0;
      overflow: hidden;
    }
    #setupPlayerTopics{
      order: 2;
      margin-top: 12px !important;
      flex: 0 0 auto;
    }
    #setupLibrary{
      order: 3;
      margin-top: auto !important;
      flex: 0 0 auto;
    }
    #setupOpenings > .row:last-child{
      flex: 1 1 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }
    #openingsDetails{
      width: 100%;
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
    }
    #openingsDetails[open]{
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow: hidden;
    }
    #openingsList{
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      padding-right: 6px;
    }

    /* ===== Timer float ===== */
    #timerFloat{
      position: fixed;
      right: 18px;
      bottom: 18px;
      width: 240px;
      border-radius: 16px;
      background: rgba(255,255,255,.94);
      border: 1px solid rgba(0,0,0,.10);
      box-shadow: 0 14px 40px rgba(0,0,0,.22);
      padding: 12px 14px;
      z-index: 9999;
      backdrop-filter: blur(8px);
    }
    .timerHead{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      margin-bottom: 8px;
    }
    .miniBtn{
      border-radius: 10px;
      padding: 6px 9px;
      font-weight: 800;
    }
    .timerBody{
      font-size: 22px;
      letter-spacing:.2px;
    }

    /* ===== Name modal ===== */
    #nameModal,
    #proModal,
    #libraryModal,
    #authModal{
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.55);
      display: none; /* controlled by JS */
      align-items: center;
      justify-content: center;
      z-index: 10000;
    }

    #libraryModalCanonical{
      padding: 9px 10px;
      border-radius: 12px;
      background: rgba(255,255,255,.72);
      border: 1px solid rgba(0,0,0,.10);
      line-height: 1.35;
      word-break: break-word;
    }

    #languageSelect{
      border-radius:12px;
      border:1px solid rgba(0,0,0,.14);
      padding: 9px 10px;
      outline:none;
      background:#fff;
    }

    @media (max-width: 1400px){
      #wrap{ grid-template-columns: minmax(320px, 1fr) var(--boardW) minmax(320px, 1fr); }
    }
    @media (max-width: 1100px){
      #wrap{
        grid-template-columns: 1fr;
        grid-template-areas:
          "board"
          "panel"
          "left";
      }
      :root{ --boardW: min(420px, 92vw); }
      #cheatLine{ width: var(--boardW); }
      #leftCol{ height:auto; overflow: visible; }
      #setupOpenings{
        height:auto;
        min-height:auto;
        overflow: visible;
      }
      #setupOpenings > .row:last-child{
        flex: 0 0 auto;
        min-height: auto;
        display: block;
      }
      #openingsDetails,
      #openingsDetails[open]{
        flex: 0 0 auto;
        min-height: auto;
        overflow: visible;
      }
      #openingSearchResults{ max-height: 20vh; }
      #openingsList{ max-height: 52vh; }
      #controlsRow button{ font-size: 13px; }
      #boardOptionsRow button{ font-size: 13px; }
    }

    body.drillMode #leftCol,
    body.drillMode #statsBox,
    body.drillMode #showTimerBtn{
      display:none !important;
    }

    body.drillMode #wrap{
      max-width: 1020px;
      grid-template-columns: var(--boardW) minmax(240px, 1fr);
      grid-template-areas: "board panel";
      gap: 16px;
      align-items:start;
    }

    body.drillMode #boardCol{ align-items:center; }

    body.drillMode #panelCol{
      display:block;
    }
    body.drillMode #setupControlsBox{
      background: transparent;
      border: 0;
      box-shadow: none;
      padding: 0;
    }
    body.drillMode #startBtn,
    body.drillMode #advancedControls,
    body.drillMode #boardOptionsDetails,
    body.drillMode #playerDetails{
      display:none !important;
    }
    body.drillMode #backBtn{
      display:inline-flex !important;
      align-items:center;
      justify-content:center;
    }
    body.drillMode #primaryControls{
      margin-bottom: 0;
    }

    body.drillMode #undoBtn{
      display:none !important;
    }

    #resetBtn{
      display:none;
      width:auto;
      padding: 8px 12px;
      border-radius: 11px;
      border: 1px solid rgba(0,0,0,.14);
      background: #fff;
      font-weight: 800;
      letter-spacing: .1px;
      box-shadow: 0 4px 12px rgba(0,0,0,.08);
      transition: transform .08s ease, box-shadow .08s ease;
    }
    body.drillMode #resetBtn{
      display:inline-flex;
      align-items:center;
    }
    #resetBtn:hover{ transform: translateY(-1px); }
    #resetBtn:active{
      transform: translateY(0px);
      box-shadow: 0 3px 9px rgba(0,0,0,.12);
    }

    @media (max-width: 700px){
      body.drillMode #wrap{
        grid-template-columns: 1fr;
        grid-template-areas:
          "board"
          "panel";
      }
      body.drillMode #panelCol{ width: min(420px, 92vw); margin: 0 auto; }
    }
