    :root {
      --bg:              #F0EDE6;
      --surface:         #FFFFFF;
      --ink:             #1C1C1C;
      --ink-mid:         #575757;
      --ink-light:       #9A9A9A;
      --border:          #DDD7CD;
      --border-light:    #EAE5DC;

      --tile:            #FFFFFF;
      --tile-shadow:     0 1px 3px rgba(0,0,0,0.09);

      --revealed-bg:     #C05220;
      --revealed-text:   #FFFFFF;

      --locked-bg:       #E7F4ED;
      --locked-border:   #2F8B50;
      --locked-text:     #1B5E35;

      --hint-bg:         #6589C4;
      --hint-bg-hover:   #5578B4;
      --hint-border:     #7599D4;

      --group-a-pale:    #F3E4BE;
      --group-a-border:  #CCBA70;

      --group-b-pale:    #C9DFEF;
      --group-b-border:  #94BDD8;

      --btn-primary:     #1C1C1C;
      --btn-text:        #FFFFFF;
      --accent:          #C05220;
      --select-ring:     rgba(192,82,32,0.28);
      --gold:            #9A7A00;

      --success:         #2F8B50;
      --error:           #C05220;
      --info-bg:         #EDF2F7;
    }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: 'Outfit', system-ui, sans-serif;
      background: var(--bg);
      color: var(--ink);
      min-height: 100vh;
    }

    /* ═══════════════════════ SCREEN MANAGEMENT ═══════════════════════ */
    .screen { display: none; min-height: 100vh; flex-direction: column; }
    .screen.active { display: flex; }

    /* ═══════════════════════ AUTH SCREENS ═══════════════════════ */
    .auth-screen {
      align-items: center;
      justify-content: center;
      padding: 2rem 1.5rem;
    }

    .auth-card {
      max-width: 380px;
      width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 2.5rem 2rem 2rem;
    }

    .auth-logo {
      text-align: center;
      margin-bottom: 1.8rem;
    }

    .auth-title {
      font-size: 1.1rem;
      font-weight: 700;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      text-align: center;
      margin-bottom: 0.3rem;
    }

    .auth-subtitle {
      font-size: 0.85rem;
      color: var(--ink-light);
      text-align: center;
      margin-bottom: 1.8rem;
    }

    .form-group {
      margin-bottom: 1rem;
    }

    .form-label {
      display: block;
      font-size: 0.72rem;
      font-weight: 600;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--ink-mid);
      margin-bottom: 0.35rem;
    }

    .form-input {
      width: 100%;
      font-family: 'Outfit', sans-serif;
      font-size: 0.95rem;
      padding: 0.7rem 0.9rem;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      background: var(--bg);
      color: var(--ink);
      outline: none;
      transition: border-color 0.15s;
    }
    .form-input:focus { border-color: var(--accent); }
    .form-input.error { border-color: var(--error); }

    .form-error {
      font-size: 0.78rem;
      color: var(--error);
      margin-top: 0.25rem;
      min-height: 1rem;
    }

    .auth-alert {
      font-size: 0.82rem;
      padding: 0.6rem 0.8rem;
      border-radius: 6px;
      margin-bottom: 1rem;
      text-align: center;
      display: none;
    }
    .auth-alert.success { display: block; background: var(--locked-bg); color: var(--locked-text); border: 1px solid var(--locked-border); }
    .auth-alert.error   { display: block; background: #FFF0EC; color: var(--error); border: 1px solid var(--accent); }

    .btn-auth {
      font-family: 'Outfit', sans-serif;
      font-size: 0.88rem;
      font-weight: 700;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      background: var(--btn-primary);
      color: var(--btn-text);
      border: none;
      border-radius: 7px;
      padding: 0.8rem 0;
      width: 100%;
      cursor: pointer;
      transition: background 0.15s, transform 0.12s;
      margin-top: 0.5rem;
    }
    .btn-auth:hover { background: #333; transform: translateY(-1px); }

    .auth-links {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.5rem;
      margin-top: 1.2rem;
    }

    .auth-link {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      color: var(--ink-mid);
      background: none;
      border: none;
      cursor: pointer;
      text-decoration: underline;
      text-underline-offset: 3px;
      transition: color 0.13s;
    }
    .auth-link:hover { color: var(--ink); }

    .auth-divider {
      display: flex;
      align-items: center;
      gap: 0.8rem;
      margin: 1.4rem 0;
    }
    .auth-divider::before, .auth-divider::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }
    .auth-divider span {
      font-size: 0.72rem;
      color: var(--ink-light);
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    .btn-guest {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 600;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      background: transparent;
      color: var(--ink-mid);
      border: 1.5px solid var(--border);
      border-radius: 7px;
      padding: 0.7rem 0;
      width: 100%;
      cursor: pointer;
      transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    .btn-guest:hover { background: var(--bg); color: var(--ink); border-color: var(--ink-mid); }

    /* Password strength meter */
    .pw-strength {
      height: 3px;
      border-radius: 2px;
      background: var(--border);
      margin-top: 0.4rem;
      overflow: hidden;
    }
    .pw-strength-bar {
      height: 100%;
      border-radius: 2px;
      width: 0;
      transition: width 0.25s, background 0.25s;
    }

    /* ═══════════════════════ WELCOME SCREEN ═══════════════════════ */
    #welcome-screen {
      align-items: center;
      justify-content: center;
      padding: 2rem 1.5rem;
    }

    .welcome-card {
      max-width: 380px;
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      padding: 3.5rem 2.5rem 2.2rem;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 18px;
    }

    .welcome-logo { margin-bottom: 2.2rem; }

    .welcome-title {
      font-size: 1.7rem;
      font-weight: 700;
      letter-spacing: 0.32em;
      text-transform: uppercase;
      color: var(--ink);
      margin-bottom: 0.55rem;
    }

    .welcome-divider {
      width: 36px; height: 1px;
      background: var(--ink-light);
      margin: 0 auto 1.4rem;
    }

    .welcome-tagline {
      font-size: 0.95rem;
      font-weight: 400;
      color: var(--ink-mid);
      line-height: 1.65;
      max-width: 250px;
      margin: 0 auto 2rem;
    }

    .welcome-puzzle-info {
      font-size: 0.68rem;
      font-weight: 600;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--ink-light);
      margin-bottom: 2rem;
    }

    .welcome-user-greeting {
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--ink-mid);
      margin-bottom: 1rem;
    }

    .btn-play {
      font-family: 'Outfit', sans-serif;
      font-size: 0.92rem;
      font-weight: 700;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      background: var(--btn-primary);
      color: var(--btn-text);
      border: none;
      border-radius: 7px;
      padding: 0.88rem 0;
      width: 100%;
      max-width: 240px;
      cursor: pointer;
      transition: background 0.15s, transform 0.12s;
      margin-bottom: 1.1rem;
    }
    .btn-play:hover { background: #333; transform: translateY(-1px); }

    .welcome-htp-link {
      font-family: 'Outfit', sans-serif;
      font-size: 0.85rem;
      font-weight: 400;
      color: var(--ink-mid);
      text-decoration: underline;
      text-underline-offset: 3px;
      background: none;
      border: none;
      cursor: pointer;
      margin-bottom: 2.8rem;
      transition: color 0.13s;
    }
    .welcome-htp-link:hover { color: var(--ink); }

    .welcome-footer {
      font-size: 0.7rem;
      color: var(--ink-light);
      letter-spacing: 0.05em;
    }

    /* ═══════════════════════ GAME SCREEN ═══════════════════════ */
    .game-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.8rem 1.1rem;
      background: var(--bg);
      border-bottom: 1px solid var(--border-light);
      position: sticky;
      top: 0;
      z-index: 100;
    }

    .header-brand {
      display: flex;
      align-items: center;
      gap: 0.55rem;
    }

    .header-title {
      font-size: 0.88rem;
      font-weight: 700;
      letter-spacing: 0.28em;
      text-transform: uppercase;
      color: var(--ink);
    }

    .header-right {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .timer-display {
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--ink-mid);
      font-variant-numeric: tabular-nums;
      letter-spacing: 0.04em;
      min-width: 3.2rem;
      text-align: right;
    }

    .menu-btn {
      width: 38px; height: 38px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--ink);
      transition: background 0.13s, border-color 0.13s;
    }
    .menu-btn:hover { border-color: var(--ink-mid); background: var(--bg); }

    .game-main {
      flex: 1;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 1.1rem 1rem 0.8rem;
      gap: 1rem;
      overflow-y: auto;
    }

    .grid-section { display: flex; flex-direction: column; align-items: center; }

    .grid-outer {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 9px;
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(3, 52px);
      gap: 5px;
    }

    .cell {
      width: 52px; height: 52px;
      display: flex; align-items: center; justify-content: center;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      font-family: 'Outfit', sans-serif;
      font-weight: 600;
      font-size: 1.28rem;
      background: var(--tile);
      user-select: none;
      transition: background 0.13s, border-color 0.13s, transform 0.12s, box-shadow 0.13s;
      position: relative;
    }
    .cell.empty {
      cursor: pointer;
      background: rgba(255,255,255,0.55);
      border-style: dashed;
      border-color: var(--border);
    }
    .cell.empty:hover, .cell.empty.drag-over {
      border-color: var(--accent);
      border-style: solid;
      transform: scale(1.04);
    }
    .cell.occupied {
      cursor: pointer;
      box-shadow: var(--tile-shadow);
    }
    .cell.occupied:hover { border-color: var(--accent); }
    .cell.revealed {
      background: var(--revealed-bg);
      color: var(--revealed-text);
      border-color: var(--revealed-bg);
      cursor: default;
      font-weight: 700;
      font-size: 1.3rem;
    }
    .cell.locked {
      cursor: default;
      pointer-events: none;
    }
    .cell.blocked {
      background: transparent;
      border: none;
      box-shadow: none;
      pointer-events: none;
    }

    .cell.empty[data-group="0"]    { background: var(--group-a-pale); border-color: var(--group-a-border); border-style: solid; }
    .cell.occupied[data-group="0"] { background: var(--group-a-pale); }
    .cell.empty[data-group="1"]    { background: var(--group-b-pale); border-color: var(--group-b-border); border-style: solid; }
    .cell.occupied[data-group="1"] { background: var(--group-b-pale); }

    .cell.hint-row {
      background: var(--hint-bg) !important;
      border-color: var(--hint-bg) !important;
      border-style: solid !important;
      cursor: pointer;
    }
    .cell.hint-row:hover, .cell.hint-row.drag-over {
      background: var(--hint-bg-hover) !important;
      transform: scale(1.04);
    }
    .cell.hint-row.occupied {
      color: var(--revealed-text) !important;
      box-shadow: var(--tile-shadow);
    }

    .cell.pop   { animation: cellPop   0.22s ease; }
    .cell.shake { animation: cellShake 0.2s ease; }
    @keyframes cellPop {
      0%   { transform: scale(0.7);  opacity: 0.5; }
      60%  { transform: scale(1.1); }
      100% { transform: scale(1);    opacity: 1; }
    }
    @keyframes cellShake {
      0%,100% { transform: translateX(0); }
      25%     { transform: translateX(-4px); }
      75%     { transform: translateX(4px); }
    }

    /* ─── Check animation v2 ─── correct cells briefly flash green and stay
       locked; incorrect cells launch a flying tile that arcs back to the
       pile. The old reveal-flip / reveal-fade keyframes are kept so any
       residue references continue to work, but the check loop now uses
       flash-correct + the flying-tile DOM element instead. */

    .cell.reveal-flip { animation: revealFlip 0.4s ease; }
    @keyframes revealFlip {
      0%   { transform: scaleX(1); }
      45%  { transform: scaleX(0); }
      55%  { transform: scaleX(0); }
      100% { transform: scaleX(1); }
    }

    .cell.flash-correct {
      animation: flashCorrect 1.0s ease-out forwards;
    }

    .cell.flash-wrong {
      animation: flashWrong 1.5s ease-out forwards;
    }
    @keyframes flashWrong {
      0%   { background: var(--tile); transform: scale(1);    box-shadow: var(--tile-shadow); }
      25%  { background: #FF6B6B;     transform: scale(1.12); box-shadow: 0 0 22px rgba(220,60,60,0.85), 0 0 8px rgba(220,60,60,0.5); border-color: #c0392b; color: #fff; }
      65%  { background: #FF8E8E;     transform: scale(1.04); box-shadow: 0 0 14px rgba(220,60,60,0.55); border-color: #c0392b; color: #fff; }
      100% { background: var(--tile); transform: scale(1);    box-shadow: var(--tile-shadow); }
    }
    @keyframes flashCorrect {
      0%   { background: var(--tile);     transform: scale(1);    box-shadow: var(--tile-shadow); }
      25%  { background: #6FD58A;          transform: scale(1.18); box-shadow: 0 0 22px rgba(80,200,120,0.85), 0 0 8px rgba(80,200,120,0.5); border-color: #2F8B50; color: #fff; }
      65%  { background: #6FD58A;          transform: scale(1.05); box-shadow: 0 0 14px rgba(80,200,120,0.65); border-color: #2F8B50; color: #fff; }
      100% { background: var(--locked-bg); transform: scale(1);    box-shadow: var(--tile-shadow); border-color: var(--locked-border); color: var(--locked-text); }
    }


    /* The transient tile that arcs from a wrong cell back to the pile. */
    .flying-tile {
      position: fixed;
      width: 52px;
      height: 52px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #FFE0D6;
      color: var(--accent);
      border: 1.5px solid var(--accent);
      border-radius: 8px;
      font-family: 'Outfit', sans-serif;
      font-weight: 600;
      font-size: 1.28rem;
      z-index: 9999;
      pointer-events: none;
      box-shadow: 0 6px 16px rgba(192,82,32,0.35);
      will-change: transform, opacity;
    }

    /* ─── Win celebration ─── modal-style banner with a medal whose colour
       reflects how many attempts the player used (1 = gold, 2 = silver,
       3 = bronze). Confetti rains down behind it. */
    .celebrate-overlay {
      position: fixed;
      inset: 0;
      background: rgba(28, 28, 28, 0.45);
      backdrop-filter: blur(2px);
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
      animation: fadeIn 0.3s ease;
    }
    .celebrate-banner {
      background: var(--surface);
      border-radius: 24px;
      padding: 2.4rem 3rem 2rem;
      text-align: center;
      box-shadow: 0 20px 80px rgba(0,0,0,0.4);
      animation: bannerPop 0.55s cubic-bezier(0.5, 1.6, 0.5, 1.0) forwards;
      max-width: 90vw;
      min-width: 320px;
      pointer-events: auto;
    }
    @keyframes bannerPop {
      0%   { transform: scale(0) rotate(-8deg); opacity: 0; }
      60%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
      100% { transform: scale(1) rotate(0deg);    opacity: 1; }
    }
    .celebrate-medal {
      font-size: 5.4rem;
      line-height: 1;
      margin: 0 auto 0.6rem;
      display: inline-block;
      animation: medalSpin 1.0s cubic-bezier(0.3, 1.6, 0.4, 1.0) forwards,
                 medalGlow 2.4s ease-in-out 1s infinite alternate;
      transform-origin: center;
    }
    @keyframes medalSpin {
      0%   { transform: rotate(-720deg) scale(0); }
      70%  { transform: rotate(20deg)  scale(1.2); }
      100% { transform: rotate(0deg)    scale(1); }
    }
    @keyframes medalGlow {
      0%   { filter: brightness(1)     drop-shadow(0 4px 8px rgba(0,0,0,0.18)); }
      100% { filter: brightness(1.35) drop-shadow(0 4px 18px currentColor); }
    }
    .celebrate-medal.tier-gold   { color: #D4AF37; }
    .celebrate-medal.tier-silver { color: #B5B5B5; }
    .celebrate-medal.tier-bronze { color: #CD7F32; }
    .celebrate-medal.tier-fail   { color: #8a8a8a; animation: none; transform: none; }

    .celebrate-banner h2 {
      font-size: 2rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      margin: 0.4rem 0 0.3rem;
      color: var(--ink);
    }
    .celebrate-banner .celebrate-tier-label {
      font-size: 0.85rem;
      letter-spacing: 0.22em;
      text-transform: uppercase;
      color: var(--ink-mid);
      margin-bottom: 0.8rem;
    }
    .celebrate-words {
      font-weight: 700;
      letter-spacing: 0.1em;
      color: var(--accent);
      font-size: 1.05rem;
      margin: 0.7rem 0 0.4rem;
      word-spacing: 0.4em;
    }
    .celebrate-time {
      color: var(--ink-mid);
      font-size: 0.95rem;
      margin-bottom: 0.4rem;
    }
    .celebrate-countdown {
      color: var(--ink-mid);
      font-size: 0.9rem;
      font-weight: 600;
      margin-bottom: 1.4rem;
      font-variant-numeric: tabular-nums;
    }
    .celebrate-close {
      background: var(--btn-primary);
      color: var(--btn-text);
      border: none;
      padding: 0.7rem 1.6rem;
      border-radius: 10px;
      font-family: inherit;
      font-size: 1rem;
      font-weight: 600;
      cursor: pointer;
      transition: transform 0.12s ease, box-shadow 0.12s ease;
    }
    .celebrate-close:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    }
    .celebrate-stats-link {
      display: block;
      margin-top: 0.9rem;
      font-size: 0.88rem;
      color: var(--ink-mid);
      text-decoration: underline;
      cursor: pointer;
      background: none;
      border: none;
      font-family: inherit;
      padding: 0;
    }
    .celebrate-stats-link:hover { color: var(--ink); }

    /* Confetti — DOM-based pieces that fall + spin */
    .confetti-piece {
      position: fixed;
      top: -14px;
      width: 9px;
      height: 14px;
      z-index: 9999;
      pointer-events: none;
      will-change: transform, opacity;
      animation: confettiFall var(--dur, 3.6s) linear var(--delay, 0s) forwards;
    }
    @keyframes confettiFall {
      0%   { transform: translate3d(0, 0, 0) rotate(0deg);   opacity: 1; }
      90%  { opacity: 0.9; }
      100% { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 720deg)); opacity: 0; }
    }

    .pile-section { display: flex; flex-direction: column; }

    .pile-outer {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 9px;
      overflow-y: auto;
    }

    .pile {
      display: grid;
      grid-template-columns: repeat(2, 52px);
      grid-template-rows: repeat(10, 52px);
      grid-auto-flow: column;
      gap: 5px;
      align-content: start;
    }

    .pile-tile {
      width: 52px; height: 52px;
      display: flex; align-items: center; justify-content: center;
      background: var(--tile);
      border: 1.5px solid var(--border);
      border-radius: 8px;
      font-family: 'Outfit', sans-serif;
      font-weight: 600;
      font-size: 1.28rem;
      cursor: pointer;
      user-select: none;
      transition: background 0.13s, border-color 0.13s, transform 0.13s, box-shadow 0.13s;
    }
    .pile-tile:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
      box-shadow: 0 4px 10px rgba(0,0,0,0.12);
    }
    .pile-tile.selected {
      border-color: var(--accent);
      background: #FFF3EE;
      box-shadow: 0 0 0 3px var(--select-ring), var(--tile-shadow);
      transform: translateY(-2px);
    }
    .pile-tile.dragging { opacity: 0.3; transform: none; }

    /* Greyed out: a letter that has already been tried (and was wrong) at the
       hovered/selected cell, OR a cell where the hovered/selected pile letter
       has already been tried (and was wrong). Visual hint only — the user can
       still click/drag if they really want to. */
    .pile-tile.dimmed {
      opacity: 0.32;
      filter: grayscale(0.7);
      text-decoration: line-through;
      text-decoration-thickness: 2px;
    }
    .pile-tile.dimmed:hover {
      transform: none;
      box-shadow: none;
    }
    .cell.empty.dimmed {
      opacity: 0.32;
      filter: grayscale(0.7);
    }

    .pile-empty-msg {
      grid-column: span 2;
      text-align: center;
      font-size: 0.82rem;
      color: var(--ink-light);
      padding: 1.2rem 0.5rem;
      line-height: 1.5;
    }

    .game-bottom {
      padding: 0.8rem 1.1rem 1rem;
      background: var(--bg);
      border-top: 1px solid var(--border-light);
      display: flex;
      flex-direction: column;
      gap: 0.55rem;
    }

    .message {
      text-align: center;
      font-size: 0.88rem;
      font-weight: 500;
      color: var(--ink-mid);
      min-height: 1.25rem;
      padding: 0 0.5rem;
    }
    .message.win  { color: var(--ink); font-weight: 600; }
    .message.lose { color: var(--accent); font-weight: 600; }
    .message.warn { color: var(--gold); }

    .game-controls {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.65rem;
    }

    .attempt-dots { display: flex; gap: 6px; }
    .dot {
      width: 12px; height: 12px;
      border-radius: 50%;
      background: var(--ink);
      transition: background 0.35s, transform 0.2s;
    }
    .dot.used { background: var(--border); transform: scale(0.8); }

    .controls-right {
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }

    .btn-check {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 700;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      background: var(--btn-primary);
      color: var(--btn-text);
      border: none;
      border-radius: 7px;
      padding: 0.62rem 1.6rem;
      cursor: pointer;
      transition: background 0.15s, transform 0.12s;
    }
    .btn-check:hover:not(:disabled) { background: #333; transform: translateY(-1px); }
    .btn-check:disabled { background: var(--border); color: var(--ink-light); cursor: not-allowed; }

    .btn-next {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 600;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      background: transparent;
      color: var(--accent);
      border: 1.5px solid var(--accent);
      border-radius: 7px;
      padding: 0.62rem 1.1rem;
      cursor: pointer;
      display: none;
      transition: background 0.15s, color 0.15s;
    }
    .btn-next:hover { background: var(--accent); color: #fff; }

    .game-footer-text {
      font-size: 0.7rem;
      color: var(--ink-light);
      text-align: center;
      letter-spacing: 0.05em;
    }

    /* ═══════════════════════ MENU PANEL ═══════════════════════ */
    .menu-backdrop {
      display: none;
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.22);
      z-index: 1001;
    }
    .menu-backdrop.open { display: block; }

    .menu-panel {
      position: fixed;
      top: 0; right: -280px;
      width: 260px; height: 100%;
      background: var(--surface);
      border-left: 1px solid var(--border);
      box-shadow: -4px 0 24px rgba(0,0,0,0.09);
      z-index: 1002;
      transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
      display: flex;
      flex-direction: column;
    }
    .menu-panel.open { right: 0; }

    .menu-panel-header {
      padding: 1rem 1.2rem;
      border-bottom: 1px solid var(--border-light);
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.22em;
      text-transform: uppercase;
      color: var(--ink);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .menu-user-info {
      padding: 0.9rem 1.2rem;
      border-bottom: 1px solid var(--border-light);
    }
    .menu-user-name {
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--ink);
    }
    .menu-user-email {
      font-size: 0.75rem;
      color: var(--ink-light);
      margin-top: 0.15rem;
    }

    .menu-close-btn {
      background: none; border: none;
      cursor: pointer;
      font-size: 1.4rem;
      color: var(--ink-light);
      line-height: 1; padding: 0;
      transition: color 0.13s;
    }
    .menu-close-btn:hover { color: var(--ink); }

    .menu-list { list-style: none; padding: 0.5rem 0; flex: 1; }
    .menu-list li button {
      width: 100%;
      padding: 0.8rem 1.2rem;
      background: none; border: none;
      text-align: left;
      font-family: 'Outfit', sans-serif;
      font-size: 0.95rem;
      font-weight: 500;
      color: var(--ink-mid);
      cursor: pointer;
      transition: background 0.12s, color 0.12s;
      display: flex;
      align-items: center;
      gap: 0.7rem;
    }
    .menu-list li button:hover { background: var(--bg); color: var(--ink); }
    .menu-list li button svg { flex-shrink: 0; }

    .menu-separator {
      height: 1px;
      background: var(--border-light);
      margin: 0.3rem 1.2rem;
    }

    .menu-footer {
      padding: 1rem 1.2rem;
      border-top: 1px solid var(--border-light);
    }
    .menu-footer button {
      width: 100%;
      padding: 0.65rem;
      background: none;
      border: 1.5px solid var(--border);
      border-radius: 7px;
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--ink-mid);
      cursor: pointer;
      letter-spacing: 0.08em;
      transition: background 0.13s, color 0.13s;
    }
    .menu-footer button:hover { background: var(--bg); color: var(--ink); }

    /* ═══════════════════════ STATISTICS PAGE ═══════════════════════ */
    .stats-page {
      align-items: center;
      padding: 0;
    }

    .stats-header {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.8rem 1.1rem;
      background: var(--bg);
      border-bottom: 1px solid var(--border-light);
      position: sticky;
      top: 0;
      z-index: 100;
    }

    .stats-back {
      width: 38px; height: 38px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--ink);
      transition: background 0.13s;
    }
    .stats-back:hover { background: var(--bg); }

    .stats-title {
      font-size: 0.78rem;
      font-weight: 700;
      letter-spacing: 0.22em;
      text-transform: uppercase;
    }

    .stats-body {
      width: 100%;
      max-width: 480px;
      padding: 1.5rem 1.2rem 3rem;
      margin: 0 auto;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 0.6rem;
      margin-bottom: 2rem;
    }

    .stat-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0.9rem 0.5rem;
      text-align: center;
    }

    .stat-value {
      font-size: 1.6rem;
      font-weight: 700;
      color: var(--ink);
      line-height: 1;
      margin-bottom: 0.3rem;
    }

    .stat-label {
      font-size: 0.62rem;
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--ink-light);
      line-height: 1.3;
    }

    .stats-section {
      margin-bottom: 1.8rem;
    }

    .stats-section-title {
      font-size: 0.66rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.22em;
      color: var(--ink-light);
      margin-bottom: 0.8rem;
      padding-bottom: 0.3rem;
      border-bottom: 1px solid var(--border-light);
    }

    /* Distribution chart */
    .dist-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.4rem;
    }

    .dist-label {
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--ink-mid);
      width: 1.8rem;
      text-align: right;
      flex-shrink: 0;
    }

    .dist-bar-wrap {
      flex: 1;
      height: 26px;
      background: var(--border-light);
      border-radius: 5px;
      overflow: hidden;
      position: relative;
    }

    .dist-bar {
      height: 100%;
      border-radius: 5px;
      min-width: 2px;
      transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
      display: flex;
      align-items: center;
      justify-content: flex-end;
      padding-right: 0.5rem;
    }
    .dist-bar.att-1 { background: var(--locked-border); }
    .dist-bar.att-2 { background: var(--hint-bg); }
    .dist-bar.att-3 { background: var(--gold); }
    .dist-bar.att-x { background: var(--accent); }

    .dist-count {
      font-size: 0.72rem;
      font-weight: 700;
      color: #fff;
    }

    /* Streak section */
    .streak-cards {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.6rem;
    }

    .streak-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 1rem;
      text-align: center;
    }

    .streak-icon {
      font-size: 1.2rem;
      margin-bottom: 0.3rem;
    }

    .streak-value {
      font-size: 1.8rem;
      font-weight: 800;
      color: var(--ink);
      line-height: 1;
      margin-bottom: 0.25rem;
    }

    .streak-label {
      font-size: 0.68rem;
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--ink-light);
    }

    /* Recent results */
    .recent-list { list-style: none; }

    .recent-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.7rem 0.8rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 0.4rem;
    }

    .recent-puzzle {
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--ink);
    }

    .recent-meta {
      display: flex;
      align-items: center;
      gap: 0.8rem;
    }

    .recent-time {
      font-size: 0.78rem;
      color: var(--ink-light);
      font-variant-numeric: tabular-nums;
    }

    .recent-badge {
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      padding: 0.2rem 0.55rem;
      border-radius: 4px;
      text-transform: uppercase;
    }
    .recent-badge.solved-1 { background: var(--locked-bg); color: var(--locked-text); }
    .recent-badge.solved-2 { background: #E8EEF6; color: #3B5998; }
    .recent-badge.solved-3 { background: #FFF6E0; color: var(--gold); }
    .recent-badge.failed   { background: #FFF0EC; color: var(--accent); }

    .stats-empty {
      text-align: center;
      padding: 2.5rem 1rem;
      color: var(--ink-light);
      font-size: 0.9rem;
    }

    /* ═══════════════════════ ACCOUNT PAGE ═══════════════════════ */
    .account-body {
      width: 100%;
      max-width: 420px;
      padding: 1.5rem 1.2rem 3rem;
      margin: 0 auto;
    }

    .account-section {
      margin-bottom: 1.6rem;
    }

    .account-section-title {
      font-size: 0.66rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.22em;
      color: var(--ink-light);
      margin-bottom: 0.8rem;
      padding-bottom: 0.3rem;
      border-bottom: 1px solid var(--border-light);
    }

    .account-field {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.7rem 0;
      border-bottom: 1px solid var(--border-light);
    }
    .account-field:last-child { border-bottom: none; }

    .account-field-label {
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--ink-mid);
      text-transform: uppercase;
      letter-spacing: 0.1em;
    }

    .account-field-value {
      font-size: 0.9rem;
      color: var(--ink);
    }

    .btn-danger {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 600;
      letter-spacing: 0.08em;
      background: none;
      color: var(--accent);
      border: 1.5px solid var(--accent);
      border-radius: 7px;
      padding: 0.6rem 1.2rem;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
      width: 100%;
      margin-top: 0.5rem;
    }
    .btn-danger:hover { background: var(--accent); color: #fff; }

    .btn-secondary {
      font-family: 'Outfit', sans-serif;
      font-size: 0.82rem;
      font-weight: 600;
      letter-spacing: 0.08em;
      background: none;
      color: var(--ink-mid);
      border: 1.5px solid var(--border);
      border-radius: 7px;
      padding: 0.6rem 1.2rem;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
      width: 100%;
    }
    .btn-secondary:hover { background: var(--bg); color: var(--ink); }

    /* ═══════════════════════ HOW TO PLAY ═══════════════════════ */
    .how-to-play {
      display: none;
      position: fixed; inset: 0;
      background: var(--bg);
      z-index: 2000;
      overflow-y: auto;
      flex-direction: column;
      align-items: center;
      padding: 2.5rem 1.5rem 4rem;
      animation: fadeIn 0.2s ease;
    }
    .how-to-play.open { display: flex; }

    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

    .htp-close {
      position: fixed;
      top: 1rem; right: 1rem;
      width: 40px; height: 40px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 1.3rem;
      cursor: pointer;
      color: var(--ink-light);
      display: flex; align-items: center; justify-content: center;
      transition: color 0.13s, border-color 0.13s;
      z-index: 2001;
    }
    .htp-close:hover { color: var(--ink); border-color: var(--ink-mid); }

    .htp-inner { max-width: 540px; width: 100%; }

    .htp-title {
      font-size: clamp(1.8rem, 6vw, 2.8rem);
      font-weight: 800;
      letter-spacing: 0.3em;
      text-transform: uppercase;
      text-align: center;
      line-height: 1;
      margin-bottom: 0.3rem;
    }
    .htp-subtitle {
      color: var(--ink-light);
      font-size: 0.92rem;
      text-align: center;
      letter-spacing: 0.08em;
    }
    .htp-divider {
      width: 44px; height: 1px;
      background: var(--border);
      margin: 0.9rem auto 2rem;
    }
    .htp-section { margin-bottom: 1.6rem; }
    .htp-section-title {
      font-size: 0.66rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.22em;
      color: var(--ink-light);
      margin-bottom: 0.6rem;
      padding-bottom: 0.3rem;
      border-bottom: 1px solid var(--border-light);
    }
    .htp-section p {
      font-size: 0.94rem;
      line-height: 1.65;
      color: var(--ink-mid);
      margin-bottom: 0.5rem;
    }
    .htp-list { list-style: none; }
    .htp-list li {
      font-size: 0.94rem;
      line-height: 1.65;
      color: var(--ink-mid);
      padding: 0.12rem 0 0.12rem 1.2rem;
      position: relative;
    }
    .htp-list li::before {
      content: '\u00b7';
      position: absolute;
      left: 0.3rem;
      color: var(--accent);
      font-size: 1.2rem;
      line-height: 1.45;
    }
    .htp-list li strong { color: var(--ink); }

    .htp-example {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 0.9rem 1.1rem;
      margin-top: 0.7rem;
    }
    .htp-example-label {
      font-size: 0.66rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      color: var(--ink-light);
      margin-bottom: 0.5rem;
    }
    .htp-example-body {
      font-size: 0.92rem;
      line-height: 1.7;
      color: var(--ink-mid);
    }
    .htp-example-body em { color: var(--gold); font-style: italic; }

    /* ═══════════════════════ CHANGE PASSWORD MODAL ═══════════════════════ */
    .modal-backdrop {
      display: none;
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.3);
      z-index: 3000;
      align-items: center;
      justify-content: center;
      padding: 1.5rem;
    }
    .modal-backdrop.open { display: flex; }

    .modal-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 2rem;
      max-width: 380px;
      width: 100%;
      animation: fadeIn 0.2s ease;
    }

    .modal-title {
      font-size: 1rem;
      font-weight: 700;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      margin-bottom: 1.2rem;
    }

    .modal-close {
      position: absolute;
      top: 0.8rem; right: 0.8rem;
      background: none; border: none;
      cursor: pointer; font-size: 1.3rem;
      color: var(--ink-light);
    }

    .feedback-textarea {
      width: 100%;
      font-family: 'Outfit', sans-serif;
      font-size: 0.95rem;
      padding: 0.7rem 0.9rem;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      background: var(--bg);
      color: var(--ink);
      outline: none;
      resize: vertical;
      min-height: 120px;
      max-height: 300px;
      transition: border-color 0.15s;
      box-sizing: border-box;
    }
    .feedback-textarea:focus { border-color: var(--accent); }
    .feedback-char-count {
      font-size: 0.75rem;
      color: var(--ink-light);
      text-align: right;
      margin-top: 0.25rem;
    }
    .feedback-char-count.near-limit { color: var(--accent); }

    /* Admin panel */
    .admin-feedback-item {
      padding: 0.9rem 1rem;
      border: 1px solid var(--border-light);
      border-radius: 10px;
      margin-bottom: 0.75rem;
      background: var(--surface);
    }
    .admin-feedback-meta {
      font-size: 0.72rem;
      color: var(--ink-light);
      margin-bottom: 0.4rem;
      display: flex;
      gap: 0.6rem;
      flex-wrap: wrap;
    }
    .admin-feedback-text {
      font-size: 0.9rem;
      color: var(--ink);
      white-space: pre-wrap;
      word-break: break-word;
    }
    .admin-empty {
      text-align: center;
      color: var(--ink-light);
      font-size: 0.9rem;
      padding: 2rem 0;
    }

    /* ═══════════════════════ COOKIE BANNER ═══════════════════════ */
    .cookie-banner {
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 9000;
      background: var(--ink);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 1rem;
      padding: 0.85rem 1.25rem;
      flex-wrap: wrap;
    }
    .cookie-banner[hidden] { display: none; }
    .cookie-text {
      font-size: 0.88rem;
      margin: 0;
      color: rgba(255,255,255,0.85);
    }
    .cookie-link {
      color: #fff;
      font-weight: 600;
      text-underline-offset: 2px;
    }
    .cookie-btn {
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: 0.4rem 1rem;
      font-family: inherit;
      font-size: 0.88rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
    }
    .cookie-btn:hover { opacity: 0.88; }

    /* ═══════════════════════ ACCOUNT DATA BUTTONS ═══════════════════════ */
    .btn-export {
      display: block;
      width: 100%;
      padding: 0.75rem 1rem;
      background: var(--surface);
      color: var(--ink);
      border: 1.5px solid var(--border);
      border-radius: 10px;
      font-family: inherit;
      font-size: 0.95rem;
      font-weight: 600;
      cursor: pointer;
      text-align: center;
      margin-bottom: 0.6rem;
      transition: border-color 0.15s, background 0.15s;
    }
    .btn-export:hover { border-color: var(--accent); background: #FFF3EE; }
