/* ==========================================================
   Liquid Glass theme — translucent, refractive, specular
   ========================================================== */
:root {
    --bg: #0c0f1d;
    --text: #f5f6ff;
    --text2: rgba(240,242,255,0.78);
    --text3: rgba(225,228,250,0.66);
    --accent: #8fa2ff;
    --accent2: #a98bff;
    --accent-solid: #6f7dff;
    --accent-glow: rgba(143,162,255,0.28);
    --green: #6ff0b4;
    --green-bg: rgba(80,230,160,0.18);
    --amber: #ffcb6b;
    --amber-bg: rgba(255,190,80,0.2);
    --red: #ff8f9c;
    --red-bg: rgba(255,90,110,0.22);
    --blue: #8cc8ff;
    --blue-bg: rgba(110,180,255,0.2);
    --purple: #c9a2ff;
    --purple-bg: rgba(190,140,255,0.18);

    /* glass materials */
    --glass: linear-gradient(135deg, rgba(255,255,255,0.20), rgba(255,255,255,0.06));
    --glass-strong: linear-gradient(135deg, rgba(255,255,255,0.30), rgba(255,255,255,0.10));
    --glass-inset: rgba(255,255,255,0.08);
    --glass-inset-hover: rgba(255,255,255,0.16);
    --border: rgba(255,255,255,0.16);
    --border2: rgba(255,255,255,0.28);
    --edge-light: rgba(255,255,255,0.65);
    --edge-dark: rgba(255,255,255,0.05);
    --blur: blur(28px) saturate(185%) brightness(1.08);
    --blur-sm: blur(14px) saturate(170%);
    --shadow: 0 10px 40px rgba(4,6,30,0.38), 0 2px 8px rgba(4,6,30,0.2);
    --shine: inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -1px 0 rgba(255,255,255,0.08),
             inset 1px 0 0 rgba(255,255,255,0.18), inset -1px 0 0 rgba(255,255,255,0.1);

    --radius: 26px;
    --radius-sm: 16px;
    --cell-size: 52px;
    --ease: cubic-bezier(0.3, 0.9, 0.3, 1.2);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { background: var(--bg); }
  body {
    background: transparent;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    position: relative;
  }
  /* Vivid backdrop that the glass refracts */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
      radial-gradient(70vmax 50vmax at 50% -10%, rgba(92,112,200,0.38), transparent 70%),
      radial-gradient(60vmax 45vmax at 100% 100%, rgba(70,150,170,0.20), transparent 70%),
      linear-gradient(180deg, #121629 0%, #0c0f1d 100%);
    background-attachment: fixed;
  }
  body::after {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(26vmax 26vmax at 25% 45%, rgba(130,150,235,0.14), transparent 65%),
      radial-gradient(22vmax 22vmax at 75% 60%, rgba(110,190,210,0.10), transparent 65%);
    animation: drift 40s ease-in-out infinite alternate;
  }
  @keyframes drift {
    from { transform: translate3d(-3%, -2%, 0) scale(1); }
    to   { transform: translate3d(3%, 3%, 0) scale(1.08); }
  }

  /* ---------- Header (floating glass bar) ---------- */
  header {
    width: calc(100% - 2rem);
    max-width: 1000px;
    margin: 1rem 1rem 0;
    padding: 0.8rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow), var(--shine);
    position: sticky;
    top: 0.75rem;
    z-index: 20;
  }
  .logo { display: flex; align-items: center; gap: 12px; }
  .logo-icon {
    width: 38px; height: 38px; display: block; object-fit: contain; flex-shrink: 0;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35));
  }
  h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.02em; text-shadow: 0 1px 8px rgba(0,0,30,0.3); }
  .subtitle { font-size: 0.76rem; color: var(--text3); }

  .main-layout {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 0 2rem;
    max-width: calc(1000px);
    width: calc(100% - 2rem);
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .left-panel { display: flex; flex-direction: column; gap: 1.1rem; min-width: 320px; flex: 1 1 auto; }
  .right-panel { display: flex; flex-direction: column; gap: 1.1rem; flex: 1 1 440px; min-width: 300px; }

  /* ---------- Glass card ---------- */
  .card {
    position: relative;
    background: var(--glass);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.3rem;
    box-shadow: var(--shadow), var(--shine);
    isolation: isolate;
    overflow: hidden;
  }
  /* specular sheen across the top-left of every glass pane */
  .card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    border-radius: inherit;
    background:
      radial-gradient(90% 40% at 0% 0%, rgba(255,255,255,0.14), transparent 60%);
  }
  .card-title {
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text3);
    margin-bottom: 0.9rem;
  }

  /* ---------- Controls ---------- */
  .controls-row { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; }
  label { font-size: 0.82rem; color: var(--text2); }
  select {
    background-color: rgba(255,255,255,0.14);
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 0.42rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    appearance: none;
    padding-right: 1.8rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23ffffff' fill-opacity='.75'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    transition: background-color 0.2s, border-color 0.2s;
  }
  select option { background: #262a52; color: #fff; }
  select:hover { background-color: rgba(255,255,255,0.22); }
  select:focus { outline: none; border-color: rgba(255,255,255,0.7); box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.4); }

  button {
    position: relative;
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 0.46rem 1rem;
    font: inherit;
    font-size: 0.83rem;
    cursor: pointer;
    font-weight: 560;
    white-space: nowrap;
    background: var(--glass);
    box-shadow: var(--shine), 0 4px 14px rgba(6,8,40,0.25);
    transition: transform 0.25s var(--ease), background 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
  }
  button:hover { background: var(--glass-strong); transform: translateY(-1px) scale(1.02); }
  button:active { transform: scale(0.96); transition-duration: 0.08s; }
  .btn-primary {
    background: linear-gradient(135deg, rgba(150,165,255,0.85), rgba(125,95,255,0.7));
    border-color: rgba(255,255,255,0.45);
    color: #fff;
    box-shadow: var(--shine), 0 6px 20px rgba(100,90,255,0.45);
  }
  .btn-primary:hover { background: linear-gradient(135deg, rgba(170,182,255,0.95), rgba(140,110,255,0.82)); }
  .btn-secondary { background: var(--glass); color: var(--text); }
  .btn-ghost { background: transparent; box-shadow: none; color: var(--text2); border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .btn-ghost:hover { background: rgba(255,255,255,0.14); color: var(--text); }
  .btn-success { background: linear-gradient(135deg, rgba(110,240,180,0.34), rgba(60,200,150,0.14)); color: var(--green); border-color: rgba(130,255,200,0.4); }
  .btn-success:hover { background: linear-gradient(135deg, rgba(110,240,180,0.48), rgba(60,200,150,0.24)); }
  .btn-danger { background: linear-gradient(135deg, rgba(255,110,130,0.34), rgba(255,80,110,0.14)); color: var(--red); border-color: rgba(255,150,165,0.4); }
  .btn-danger:hover { background: linear-gradient(135deg, rgba(255,110,130,0.5), rgba(255,80,110,0.24)); }
  button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
  button:focus-visible { outline: 2px solid rgba(255,255,255,0.85); outline-offset: 2px; }

  /* ---------- Grid ---------- */
  .grid-container { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
  #sudoku-grid {
    display: inline-grid;
    gap: 0;
    border: 1.5px solid rgba(255,255,255,0.55);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255,255,255,0.04);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 6px 22px rgba(4,6,30,0.3);
  }
  .cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * 0.46);
    font-weight: 500;
    cursor: pointer;
    background: rgba(255,255,255,0.07);
    transition: background 0.18s, box-shadow 0.18s;
    position: relative;
    user-select: none;
  }
  .cell:hover { background: rgba(255,255,255,0.15); }
  .cell:focus-within { z-index: 2; }
  .cell input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    font-size: calc(var(--cell-size) * 0.46);
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    caret-color: var(--accent);
  }
  .cell.given input { color: #fff; font-weight: 700; text-shadow: 0 1px 6px rgba(0,0,40,0.4); }
  .cell.given { background: rgba(255,255,255,0.17); }
  .cell.solved input { color: #b9c4ff; }
  .cell.highlighted { background: rgba(160,175,255,0.24) !important; }
  .cell.current,
  .cell.selected {
    background: rgba(180,190,255,0.42) !important;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.9), inset 0 1px 12px rgba(255,255,255,0.35), 0 0 18px rgba(150,165,255,0.6);
    z-index: 3;
  }
  .cell.error { background: var(--red-bg) !important; }
  .cell.error input { color: var(--red) !important; }
  .cell.same-digit { background: rgba(190,170,255,0.26); }
  .cell.player input { color: #b9c4ff; }
  .cell.mistake input { color: var(--red) !important; text-decoration: underline wavy var(--red); text-underline-offset: 3px; }
  .cell.step-done { background: var(--green-bg) !important; }
  .cell.step-done input { color: var(--green) !important; }
  .cell.ocr-check { box-shadow: inset 0 0 0 2px var(--amber); }
  /* Thick box borders — set via JS */
  .cell.box-right { border-right: 1.5px solid rgba(255,255,255,0.55) !important; }
  .cell.box-bottom { border-bottom: 1.5px solid rgba(255,255,255,0.55) !important; }

  /* ---------- Numpad ---------- */
  .numpad { display: grid; gap: 0.45rem; }
  .numpad { gap: 0.7rem; justify-items: center; }
  .numpad button {
    width: 54px;
    height: 54px;
    font-size: 1.35rem;
    font-weight: 560;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  @media (max-width: 520px) { .numpad button { width: 46px; height: 46px; font-size: 1.2rem; } .numpad { gap: 0.5rem; } }
  .numpad button.active {
    background: linear-gradient(135deg, rgba(150,165,255,0.9), rgba(125,95,255,0.75));
    border-color: rgba(255,255,255,0.6);
    color: #fff;
    box-shadow: var(--shine), 0 0 20px rgba(130,120,255,0.6);
  }

  /* ---------- Steps ---------- */
  .steps-panel { display: flex; flex-direction: column; gap: 0.5rem; }
  .steps-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
  .speed-label { font-size: 0.78rem; color: var(--text3); margin-left: auto; }
  input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 99px;
    background: rgba(255,255,255,0.18);
    box-shadow: inset 0 1px 2px rgba(0,0,30,0.35), 0 1px 0 rgba(255,255,255,0.2);
    cursor: pointer;
    width: 110px;
    outline: none;
  }
  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px; border-radius: 50%;
    background: linear-gradient(145deg, #fff, rgba(255,255,255,0.7));
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 3px 10px rgba(0,0,40,0.4), inset 0 -2px 4px rgba(120,130,255,0.35);
  }
  input[type=range]::-moz-range-thumb {
    width: 22px; height: 22px; border-radius: 50%;
    background: linear-gradient(145deg, #fff, rgba(255,255,255,0.7));
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 3px 10px rgba(0,0,40,0.4);
  }
  .steps-list {
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 2px 4px 2px 2px;
  }
  .steps-list::-webkit-scrollbar { width: 6px; }
  .steps-list::-webkit-scrollbar-track { background: transparent; }
  .steps-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.28); border-radius: 6px; }
  .step-item {
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.8rem;
    color: inherit;
    white-space: normal;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    line-height: 1.45;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
  }
  .step-item:hover { border-color: var(--border2); background: rgba(255,255,255,0.17); transform: none; }
  .step-item.active { border-color: rgba(255,255,255,0.65); background: rgba(150,165,255,0.3); box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 0 18px rgba(140,150,255,0.35); }
  .step-item.done { border-color: rgba(130,255,200,0.4); background: var(--green-bg); }
  .step-num { font-size: 0.7rem; color: var(--text3); min-width: 22px; padding-top: 1px; font-weight: 600; }
  .step-text { color: var(--text2); flex: 1; }
  .step-item.active .step-text { color: #fff; }
  .step-item.done .step-text { color: var(--green); }
  .step-technique {
    font-size: 0.68rem;
    background: rgba(255,255,255,0.14);
    border-radius: 99px;
    padding: 1px 8px;
    color: var(--text2);
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 1px;
  }
  .step-item.active .step-technique { background: rgba(255,255,255,0.9); color: #4b4fd0; }

  /* ---------- Status bar ---------- */
  .status-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -1px 0 rgba(0,0,30,0.12);
    min-height: 38px;
  }
  .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .status-idle .status-dot { background: var(--text3); }
  .status-solving .status-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1s infinite; }
  .status-done .status-dot { background: var(--green); box-shadow: 0 0 10px var(--green); }
  .status-error .status-dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
  @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
  .candidates-view {
    position: absolute;
    inset: 0;
    display: grid;
    align-items: center;
    justify-items: center;
    font-size: calc(var(--cell-size) * 0.14);
    color: var(--text3);
    font-weight: 400;
    line-height: 1;
    pointer-events: none;
    padding: 2px;
  }
  .notes-view { color: var(--text2); font-size: calc(var(--cell-size) * 0.24); font-weight: 500; padding: 1px; }

  /* ---------- Mode switch (segmented glass) ---------- */
  .mode-switch {
    display: inline-flex;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 3px;
    box-shadow: inset 0 2px 6px rgba(0,0,30,0.25), 0 1px 0 rgba(255,255,255,0.2);
  }
  .mode-switch button {
    border: none;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    color: var(--text2);
    padding: 0.38rem 1.05rem;
  }
  .mode-switch button:hover { color: #fff; transform: none; background: rgba(255,255,255,0.1); }
  .mode-switch button.active {
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(225,230,255,0.82));
    color: #232a7a;
    font-weight: 650;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 3px 10px rgba(0,0,40,0.3);
  }

  /* ---------- Game card ---------- */
  .card-status { padding: 0.55rem; border-radius: 999px; }
  .game-title { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
  .game-info { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text2); }
  .game-stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 0.5rem; }
  .stat-score .stat-value { color: #fff; text-shadow: 0 0 14px rgba(160,170,255,0.9); }
  .combo-badge {
    margin-left: 0.3rem;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--amber-bg);
    color: var(--amber);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    animation: combo-pop 0.35s ease-out;
  }
  @keyframes combo-pop { from { transform: scale(1.5); } to { transform: scale(1); } }
  .score-pop {
    position: absolute;
    left: 50%;
    top: 10%;
    transform: translateX(-50%);
    font-size: max(11px, calc(var(--cell-size) * 0.26));
    font-weight: 700;
    color: var(--green);
    white-space: nowrap;
    pointer-events: none;
    z-index: 6;
    text-shadow: 0 1px 6px rgba(0,0,30,0.7);
    animation: score-rise 0.9s ease-out forwards;
  }
  .score-pop.bad { color: var(--red); }
  .score-pop.bonus { color: var(--amber); }
  @keyframes score-rise {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -120%); }
  }
  .cell.flash { animation: unit-flash 0.8s ease-out; }
  @keyframes unit-flash {
    0% { box-shadow: inset 0 0 0 999px rgba(255,200,100,0.5); }
    100% { box-shadow: inset 0 0 0 999px rgba(255,200,100,0); }
  }
  .confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

  /* ---------- High scores ---------- */
  .scores-title { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
  .scores-title select { text-transform: none; letter-spacing: 0; font-size: 0.78rem; padding: 0.28rem 1.6rem 0.28rem 0.65rem; max-width: 60%; }
  .score-list { max-height: 300px; overflow-y: auto; }
  .score-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
  .score-table th { text-align: left; font-weight: 600; color: var(--text3); font-size: 0.7rem; padding: 0.25rem 0.4rem; border-bottom: 1px solid var(--border); }
  .score-table td { padding: 0.4rem 0.4rem; color: var(--text2); border-bottom: 1px solid rgba(255,255,255,0.1); }
  .score-table td:nth-child(2) { color: var(--text); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .score-table td:nth-child(3) { color: #fff; font-weight: 650; }
  .score-table tr.score-new td { background: var(--amber-bg); color: var(--amber); }

  /* ---------- Win dialog (floating glass sheet) ---------- */
  .win-dialog {
    margin: auto;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 32px;
    background: linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08));
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    backdrop-filter: blur(40px) saturate(200%);
    color: var(--text);
    padding: 1.6rem 1.7rem;
    width: min(400px, calc(100vw - 32px));
    box-shadow: 0 30px 80px rgba(2,4,30,0.6), var(--shine);
    overflow: hidden;
  }
  .win-dialog[open] { animation: sheet-in 0.45s var(--ease); }
  @keyframes sheet-in { from { opacity: 0; transform: scale(0.9) translateY(14px); } to { opacity: 1; transform: none; } }
  .win-dialog::backdrop { background: rgba(8,10,40,0.35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .win-dialog h2 { font-size: 1.15rem; text-align: center; }
  .win-total { text-align: center; font-size: 2.6rem; font-weight: 700; color: #fff; margin: 0.3rem 0 0.8rem; font-variant-numeric: tabular-nums; text-shadow: 0 0 24px rgba(160,170,255,0.9); }
  .win-breakdown { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--text2); margin-bottom: 0.9rem; }
  .win-breakdown li { display: flex; justify-content: space-between; gap: 0.8rem; }
  .win-breakdown li span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
  .win-save { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.7rem; }
  .win-rank { color: var(--amber); font-weight: 600; font-size: 0.88rem; }
  .win-save-row { display: flex; gap: 0.5rem; }
  .win-save-row input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,0.14);
    color: var(--text);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font: inherit;
    font-size: 0.85rem;
    box-shadow: inset 0 2px 5px rgba(0,0,30,0.25);
  }
  .win-save-row input:focus { outline: none; border-color: rgba(255,255,255,0.75); box-shadow: 0 0 0 3px var(--accent-glow), inset 0 2px 5px rgba(0,0,30,0.25); }
  .win-note { font-size: 0.75rem; color: var(--text3); margin-bottom: 0.8rem; }
  .win-actions { justify-content: flex-end; }

  .stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
  }
  .stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); }
  .stat-value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
  #btn-notes.active { background: rgba(160,175,255,0.35); border-color: rgba(255,255,255,0.7); color: #fff; }
  .card-note { margin-top: 0.8rem; font-size: 0.74rem; color: var(--text3); line-height: 1.45; }
  .progress-bar-wrap {
    height: 6px;
    background: rgba(255,255,255,0.14);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 0.8rem;
    box-shadow: inset 0 1px 3px rgba(0,0,30,0.35);
  }
  .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #7f95f5, #8fb8f2);
    border-radius: 99px;
    transition: width 0.4s;
    width: 0%;
    box-shadow: 0 0 12px rgba(180,160,255,0.8);
  }
  .badge { font-size: 0.7rem; padding: 3px 10px; border-radius: 99px; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }
  .badge-green { background: var(--green-bg); color: var(--green); }
  .badge-amber { background: var(--amber-bg); color: var(--amber); }
  .badge-red { background: var(--red-bg); color: var(--red); }
  .badge-blue { background: var(--blue-bg); color: var(--blue); }
  .presets-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
  .preset-btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.8rem;
    color: var(--text2);
  }
  .preset-btn:hover { color: #fff; background: rgba(160,175,255,0.35); border-color: rgba(255,255,255,0.6); }
  .presets-empty { font-size: 0.78rem; color: var(--text3); }

  /* ---------- Toggle (Apple-style glass switch) ---------- */
  .toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.84rem; color: var(--text2); }
  .toggle-switch {
    width: 46px; height: 28px;
    padding: 0;
    background: rgba(255,255,255,0.16);
    border: 1px solid var(--border2);
    border-radius: 99px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: inset 0 2px 6px rgba(0,0,30,0.3);
    transition: background 0.3s, box-shadow 0.3s;
  }
  .toggle-switch:hover { transform: none; background: rgba(255,255,255,0.24); }
  .toggle-switch:active { transform: none; }
  .toggle-switch.on {
    background: linear-gradient(135deg, rgba(110,240,180,0.85), rgba(60,200,170,0.7));
    box-shadow: inset 0 2px 6px rgba(0,60,40,0.25), 0 0 14px rgba(100,240,180,0.4);
  }
  .toggle-switch::after {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    background: linear-gradient(145deg, #fff, rgba(255,255,255,0.8));
    border-radius: 50%;
    top: 2px; left: 2px;
    box-shadow: 0 3px 8px rgba(0,0,40,0.4), inset 0 -2px 3px rgba(120,130,255,0.25);
    transition: transform 0.35s var(--ease), width 0.2s;
  }
  .toggle-switch:active::after { width: 27px; }
  .toggle-switch.on::after { transform: translateX(18px); }
  .toggle-switch.on:active::after { transform: translateX(13px); }
  /* ---------- Upload & solve hero ---------- */
  .card-import { padding: 0.8rem; border-color: rgba(255,255,255,0.3); box-shadow: var(--shadow), var(--shine), 0 0 40px rgba(130,150,255,0.25); }
  .card-import::after {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
    background: linear-gradient(135deg, rgba(143,162,255,0.22), rgba(111,214,230,0.10));
  }
  .dropzone {
    display: flex; align-items: center; gap: 0.95rem; flex-wrap: wrap;
    padding: 1rem 1.1rem; cursor: pointer; color: var(--text);
    border: 1.5px dashed rgba(255,255,255,0.4); border-radius: calc(var(--radius) - 8px);
    background: rgba(255,255,255,0.06);
    transition: background 0.2s, border-color 0.2s, transform 0.25s var(--ease);
  }
  .dropzone:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.7); }
  .dropzone.dragover { background: rgba(143,162,255,0.3); border-color: #fff; border-style: solid; transform: scale(1.015); }
  .dropzone.busy { opacity: 0.75; cursor: progress; }
  .dropzone-icon {
    flex: 0 0 auto; width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, rgba(150,165,255,0.9), rgba(105,200,225,0.75));
    box-shadow: var(--shine), 0 6px 18px rgba(100,120,255,0.45);
  }
  .dropzone-text { flex: 1 1 180px; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
  .dropzone-text strong { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
  .dropzone-text span { font-size: 0.78rem; color: var(--text2); line-height: 1.4; }
  .btn-import { flex: 0 0 auto; padding: 0.6rem 1.25rem; font-size: 0.9rem; }
  @media (max-width: 520px) { .btn-import { width: 100%; } }
  .divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); margin: 0.3rem 0; }
  .empty-steps { text-align: center; color: var(--text3); font-size: 0.82rem; padding: 2rem; }

  /* No backdrop-filter support: fall back to denser panes */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card, header, .win-dialog { background: rgba(38,42,92,0.88); }
    button { background: rgba(255,255,255,0.14); }
  }

  @media (max-width: 900px) {
    header { padding: 0.65rem 1rem; }
    .main-layout { padding: 1rem 0 1.5rem; gap: 1rem; }
    .left-panel, .right-panel { min-width: 0; width: 100%; max-width: none; }
    .card { padding: 0.95rem; }
    .steps-list { max-height: 250px; }
  }
  @media (max-width: 520px) {
    header { width: calc(100% - 1rem); margin: 0.5rem 0.5rem 0; }
    .main-layout { width: calc(100% - 1rem); }
    .logo-icon { width: 30px; height: 30px; }
    h1 { font-size: 1.05rem; }
    .subtitle { font-size: 0.72rem; }
    button { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
    select { font-size: 0.8rem; padding: 0.35rem 0.55rem; padding-right: 1.5rem; }
    .status-bar { font-size: 0.78rem; }
    .game-stats { grid-template-columns: 1fr 1fr; }
  }
  @media (prefers-reduced-motion: reduce) {
    body::after, .win-dialog[open] { animation: none; }
    .combo-badge, .cell.flash, .score-pop { animation: none; }
    button, .toggle-switch::after { transition: none; }
  }
  @media (prefers-reduced-transparency: reduce) {
    .card, header, button, .win-dialog, #sudoku-grid { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(38,42,92,0.95); }
  }
