/* Game Log Tracker styles */

  @import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Inter:wght@400;500;600;700&family=Metal+Mania&family=Rubik+Distressed&family=Comic+Neue:wght@700&display=swap');

  :root{
    --bg:#15121f;
    --bg-alt:#1b1729;
    --panel:#201a32;
    --panel-2:#251e3a;
    --border:#332a52;
    --gold:#e4a93f;
    --gold-dim:#8a6a2e;
    --teal:#59c9a5;
    --text:#ece8f7;
    --muted:#948db3;
    --danger:#e2685c;
    --radius:3px;
    --status-h:0px;
  }
  body.show-status{--status-h:22px;}

  *{box-sizing:border-box;}
  html{font-size:16px;} /* base for all the rem font sizes below, changed at runtime to scale app-wide text size */
  html,body{margin:0;padding:0;background:var(--bg);overscroll-behavior-y:contain;height:100%;}
  body{
    font-family:'Inter',sans-serif;
    color:var(--text);
    min-height:100vh;
    min-height:100dvh;
    padding-top:calc(24px + env(safe-area-inset-top));
    padding-left:calc(16px + env(safe-area-inset-left));
    padding-right:calc(16px + env(safe-area-inset-right));
    padding-bottom:calc(64px + env(safe-area-inset-bottom));
    background-image:
      radial-gradient(circle at 20% 0%, rgba(228,169,63,0.06), transparent 40%),
      radial-gradient(circle at 80% 100%, rgba(89,201,165,0.06), transparent 40%);
  }

  .wrap{max-width:960px;margin:0 auto;}

  .install-banner{
    display:flex;align-items:center;gap:12px;justify-content:space-between;
    background:var(--panel);border:1px solid var(--gold-dim);border-radius:6px;
    padding:12px 14px;margin-bottom:18px;
  }
  .install-banner span{font-size:0.8125rem;color:var(--text);line-height:1.4;}
  .install-banner-actions{display:flex;align-items:center;gap:10px;flex-shrink:0;}
  .install-banner-close{
    background:transparent;border:none;color:var(--muted);font-size:0.9375rem;
    cursor:pointer;padding:4px;line-height:1;
  }
  .install-banner-close:hover{color:var(--text);}
  @media (max-width:480px){
    .install-banner{flex-direction:column;align-items:flex-start;}
    .install-banner-actions{width:100%;justify-content:space-between;}
  }

  .brand{
    display:flex;align-items:center;gap:10px;margin-bottom:28px;
  }
  .brand .menu-wrap{margin-left:auto;}
  .brand .mark{
    width:90px;height:90px;border-radius:8px;flex-shrink:0;display:block;
  }
  .brand .name{font-family:'Space Mono',monospace;font-size:1.0625rem;color:var(--muted);}

  .field{margin-bottom:16px;}
  .field label{
    display:block;font-size:0.75rem;color:var(--muted);
    margin-bottom:6px;font-family:'Space Mono',monospace;
  }
  .field input{
    width:100%;padding:10px 12px;background:var(--bg-alt);
    border:1px solid var(--border);border-radius:var(--radius);
    color:var(--text);font-size:0.875rem;font-family:'Inter',sans-serif;
  }
  .field input:focus{outline:none;border-color:var(--gold);}
  .field .hint{font-size:0.75rem;color:var(--muted);margin-top:6px;}
  .field .hint a{color:var(--teal);}

  button{
    font-family:'Space Mono',monospace;
    cursor:pointer;border:none;border-radius:var(--radius);
    font-size:0.8125rem;font-weight:700;letter-spacing:0.3px;
  }
  .btn-primary{
    background:var(--gold);color:#1a1424;padding:11px 20px;width:100%;
  }
  .btn-primary:hover{background:#f0b953;}
  .btn-primary:disabled{background:var(--gold-dim);cursor:wait;}
  .btn-ghost{
    background:transparent;border:1px solid var(--border);color:var(--muted);
    padding:8px 14px;
  }
  .btn-ghost:hover{color:var(--text);border-color:var(--muted);}
  .btn-ghost.active{color:var(--gold);border-color:var(--gold);}

  /* Hamburger dropdown menu */
  .menu-wrap{position:relative;}
  .btn-hamburger{
    background:transparent;border:1px solid var(--border);border-radius:4px;
    width:38px;height:34px;display:flex;flex-direction:column;justify-content:center;
    align-items:center;gap:4px;cursor:pointer;
  }
  .btn-hamburger:hover{border-color:var(--muted);}
  .btn-hamburger{position:relative;}
  /* Gold dot shown only while an app update is waiting (see the update code in app.js). */
  .btn-hamburger.has-update::after{
    content:'';position:absolute;top:-4px;right:-4px;width:10px;height:10px;border-radius:50%;
    background:var(--gold);box-shadow:0 0 0 2px var(--bg);
  }
  .dropdown-update{color:var(--gold);font-weight:700;}
  .dropdown-update:disabled{opacity:0.7;cursor:default;}
  .btn-hamburger .bar{width:18px;height:2px;background:var(--text);border-radius:1px;}
  .dropdown-menu{
    display:none;position:absolute;top:calc(100% + 6px);right:0;
    background:var(--panel);border:1px solid var(--border);border-radius:6px;
    min-width:150px;overflow:hidden;z-index:50;
    box-shadow:0 8px 20px rgba(0,0,0,0.45);
  }
  .dropdown-menu.open{display:block;}
  .dropdown-item{
    display:block;width:100%;text-align:left;background:transparent;border:none;
    color:var(--text);padding:11px 14px;font-family:'Space Mono',monospace;font-size:0.7812rem;
    cursor:pointer;
  }
  .dropdown-item:hover{background:var(--bg-alt);}
  .dropdown-item + .dropdown-item{border-top:1px solid var(--border);}
  .dropdown-heading{
    display:flex;justify-content:space-between;align-items:center;
    color:var(--gold);font-weight:700;
  }
  .dropdown-heading #ra-heading-arrow,.dropdown-heading #textsize-heading-arrow,.dropdown-heading #display-heading-arrow{font-size:0.625rem;color:var(--muted);}
  .dropdown-plain{color:var(--text);font-weight:400;}
  .dropdown-subitem{
    padding-left:26px;font-size:0.7188rem;color:var(--muted);background:var(--bg-alt);
  }
  .dropdown-subitem:hover{color:var(--text);}
  #ra-submenu .dropdown-subitem + .dropdown-subitem{border-top:1px solid var(--border);}

  .textsize-row{
    display:flex;align-items:center;gap:8px;padding:9px 14px 9px 26px;
    background:var(--bg-alt);border-top:1px solid var(--border);
  }
  .textsize-btn{
    width:26px;height:24px;flex-shrink:0;display:flex;align-items:center;justify-content:center;
    background:var(--panel);border:1px solid var(--border);border-radius:4px;color:var(--text);
    font-family:'Space Mono',monospace;font-size:0.6875rem;font-weight:700;cursor:pointer;padding:0;
  }
  .textsize-btn:hover{border-color:var(--muted);}
  .textsize-btn:disabled{opacity:0.4;cursor:default;}
  .textsize-row .size-label{
    font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--text);min-width:34px;text-align:center;
  }
  .textsize-reset{
    margin-left:auto;background:transparent;border:none;color:var(--muted);
    font-family:'Space Mono',monospace;font-size:0.65rem;text-decoration:underline;cursor:pointer;padding:0;flex-shrink:0;
  }
  .textsize-reset:hover{color:var(--text);}

  .display-row{
    display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 14px 9px 26px;
    background:var(--bg-alt);border-top:1px solid var(--border);
    font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--text);
  }
  .display-note{display:block;font-size:0.6562rem;color:var(--muted);margin-top:2px;}
  .display-switch{
    width:34px;height:18px;flex-shrink:0;border-radius:9px;border:1px solid var(--border);
    background:var(--panel);position:relative;cursor:pointer;padding:0;
  }
  .display-switch::after{
    content:'';position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;
    background:var(--muted);transition:left 0.15s;
  }
  .display-switch.on{background:var(--teal);border-color:var(--teal);}
  .display-switch.on::after{left:18px;background:var(--bg);}
  .display-switch:disabled{opacity:0.4;cursor:default;}

  /* Optional clock and battery readout (Display menu). Sits above every full-screen layer, and
     those layers leave room for it through --status-h, which is 0 unless the readout is on. */
  .device-status{
    display:none;position:fixed;top:env(safe-area-inset-top, 0px);right:calc(8px + env(safe-area-inset-right, 0px));
    height:22px;z-index:1000;align-items:center;gap:7px;pointer-events:none;
    font-family:'Space Mono',monospace;font-size:11px;font-weight:700;color:var(--text);
    text-shadow:0 1px 2px rgba(0,0,0,0.85);
  }
  body.show-status .device-status{display:flex;}
  .device-status .ds-hearts{display:flex;align-items:center;gap:2px;}

  .pull-refresh-indicator{
    position:fixed;top:0;left:0;right:0;height:0;overflow:hidden;
    display:flex;justify-content:center;align-items:center;
    color:var(--gold);font-family:'Space Mono',monospace;font-size:0.7188rem;
    background:var(--bg);z-index:60;transition:height 0.15s ease-out;
  }
  /* While pulling inside the full-screen game profile (z-index 100), show the indicator above it. */
  .pull-refresh-indicator.over-profile{z-index:150;}

  .error-box{
    background:rgba(226,104,92,0.1);border:1px solid var(--danger);
    color:#f3aca4;padding:12px 14px;border-radius:var(--radius);
    font-size:0.8125rem;margin-top:16px;line-height:1.5;
  }

  /* Dashboard */
  #dashboard{display:none;}

  .topbar{display:flex;justify-content:flex-end;align-items:center;margin-bottom:22px;gap:12px;flex-wrap:wrap;}

  .profile-hero{
    background:linear-gradient(135deg, var(--panel-2), var(--panel));
    border:1px solid var(--border);
    border-radius:6px;
    padding:22px;
    display:flex;gap:18px;align-items:center;
    margin-bottom:24px;
    flex-wrap:wrap;
  }
  .profile-hero img.avatar{
    width:72px;height:72px;border-radius:var(--radius);
    border:2px solid var(--gold);
    image-rendering:pixelated;
    flex-shrink:0;
  }
  .profile-hero .who{flex:1;min-width:160px;}
  .profile-hero .who h2{
    font-family:'Space Mono',monospace;margin:0 0 4px;font-size:1.25rem;
  }
  .profile-hero .who .motto{color:var(--muted);font-size:0.8125rem;margin:0;}
  .stat-row{display:flex;gap:22px;flex-wrap:wrap;}
  .stat{text-align:right;}
  .stat .num{
    font-family:'Space Mono',monospace;font-size:1.375rem;font-weight:700;color:var(--gold);
    line-height:1;
  }
  .stat .lbl{font-size:0.6875rem;color:var(--muted);margin-top:4px;}

  .section-title{
    font-family:'Space Mono',monospace;font-size:0.875rem;color:var(--muted);
    letter-spacing:0.5px;margin:32px 0 12px;
    display:flex;justify-content:space-between;align-items:center;
  }
  .section-title span.count{color:var(--gold-dim);}

  .cart-grid{
    display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));
    gap:10px;
  }
  .cart{
    background:var(--panel);border:1px solid var(--border);border-radius:6px;
    overflow:hidden;display:flex;flex-direction:column;cursor:pointer;
    transition:border-color 0.15s;
  }
  .cart:hover{border-color:var(--gold-dim);}
  .cart .art-wrap{position:relative;line-height:0;}
  .cart .art{
    width:100%;aspect-ratio:1/1;object-fit:cover;background:var(--bg-alt);
    display:block;
  }
  /* The body grows to fill the card and stacks its contents in a column, so the progress group
     below can be pushed to the bottom edge (see .cart-progress-group). */
  .cart .body{padding:8px;flex:1;display:flex;flex-direction:column;}
  .cart .title{
    font-size:0.7188rem;font-weight:600;margin:0 0 2px;line-height:1.3;
    display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
  }
  .cart .console{font-size:0.5938rem;color:var(--muted);margin:0 0 6px;}
  /* Progress bar + achievement count/% + playtime: always pinned to the bottom of the card, so titles
     that wrap to one or two lines still leave those lines level across the whole row. */
  .cart .cart-progress-group{margin-top:auto;}
  .progress-track{
    background:var(--bg-alt);border-radius:20px;height:5px;overflow:hidden;margin-bottom:4px;
  }
  .progress-fill{height:100%;background:var(--teal);border-radius:20px;}
  .progress-fill.complete{background:var(--gold);}
  .progress-fill.hardcore{background:var(--gold);}
  .cart .prog-lbl{
    display:flex;justify-content:space-between;font-size:0.5938rem;color:var(--muted);
    font-family:'Space Mono',monospace;
  }
  .cart .hours{
    font-size:0.5938rem;color:var(--muted);font-family:'Space Mono',monospace;margin-top:3px;
  }
  .cart .hours .val{color:var(--gold);}
  /* Small pulsing bar shown in place of a playtime that hasn't loaded yet. */
  .pt-pending{
    display:inline-block;width:28px;height:0.7em;border-radius:3px;background:var(--border);
    vertical-align:middle;animation:pt-pulse 1.2s ease-in-out infinite;
  }
  @keyframes pt-pulse{0%,100%{opacity:0.35;}50%{opacity:0.9;}}
  /* The ⟳ button beside the playtime in a game's profile; spins while re-checking. */
  .pt-refresh-btn{
    background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:5px;
    width:24px;height:24px;padding:0;line-height:1;font-size:0.9rem;cursor:pointer;
  }
  .pt-refresh-btn:hover{border-color:var(--gold);color:var(--gold);}
  .pt-refresh-btn:disabled{cursor:default;opacity:0.7;}
  .pt-refresh-btn.spinning{animation:pt-spin 0.8s linear infinite;}
  @keyframes pt-spin{to{transform:rotate(360deg);}}

  .unlock-list{display:flex;flex-direction:column;gap:1px;background:var(--border);border-radius:6px;overflow:hidden;border:1px solid var(--border);}
  .unlock{
    background:var(--panel);padding:10px 14px;cursor:pointer;
  }
  .unlock-row{display:flex;align-items:center;gap:12px;}
  .unlock img{width:40px;height:40px;border-radius:var(--radius);flex-shrink:0;image-rendering:pixelated;}
  .unlock .info{flex:1;min-width:0;}
  .unlock .info .t{font-size:0.8438rem;font-weight:600;margin:0 0 2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .unlock .info .g{font-size:0.7188rem;color:var(--muted);margin:0;}
  .unlock .pts{
    font-family:'Space Mono',monospace;color:var(--gold);font-size:0.8125rem;font-weight:700;
    flex-shrink:0;
  }
  .unlock .when{font-size:0.6875rem;color:var(--muted);flex-shrink:0;width:70px;text-align:right;}
  .unlock-desc{
    display:none;margin:8px 0 0;padding-left:52px;
    font-size:0.7812rem;color:var(--muted);line-height:1.5;
  }
  .unlock.expanded .unlock-desc{display:block;}

  .lib-search{
    width:100%;padding:9px 12px;background:var(--bg-alt);border:1px solid var(--border);
    border-radius:var(--radius);color:var(--text);font-size:0.8125rem;margin-bottom:12px;font-family:'Inter',sans-serif;
  }
  .lib-search:focus{outline:none;border-color:var(--gold);}

  .lib-table{width:100%;border-collapse:collapse;font-size:0.8125rem;}
  .lib-table th{
    text-align:left;font-family:'Space Mono',monospace;font-weight:400;
    color:var(--muted);font-size:0.6875rem;padding:6px 10px;border-bottom:1px solid var(--border);
    cursor:pointer;user-select:none;
  }
  .lib-table th:hover{color:var(--text);}
  .lib-table td{padding:8px 10px;border-bottom:1px solid var(--bg-alt);vertical-align:middle;}
  .lib-table tr:last-child td{border-bottom:none;}
  .lib-table tbody tr{cursor:pointer;}
  .lib-table tbody tr:hover{background:var(--panel-2);}
  .lib-table .g-title{display:flex;align-items:center;gap:8px;}
  .lib-table .g-title img{width:22px;height:22px;border-radius:2px;image-rendering:pixelated;}
  .lib-table .bar{width:90px;}

  .pill{
    display:inline-block;font-family:'Space Mono',monospace;font-size:0.5938rem;
    padding:2px 7px;border-radius:10px;white-space:nowrap;
  }
  .pill-teal{background:rgba(89,201,165,0.15);color:var(--teal);}
  .pill-gold{background:rgba(228,169,63,0.15);color:var(--gold);}
  .pill-muted{background:rgba(148,141,179,0.12);color:var(--muted);}
  /* Beaten / Mastered label on the corner of an Overview card's box art. */
  .pill.pill-corner{
    position:absolute;top:4px;right:4px;font-size:0.4rem;line-height:1.3;padding:0.24em 0.7em;
    background:rgba(21,18,31,0.85);border:1px solid currentColor;
  }

  /* Tabs */
  .tabs{display:flex;gap:0;border-bottom:1px solid var(--border);margin-bottom:18px;}
  .tab-btn{
    background:transparent;border:none;color:var(--muted);
    padding:10px 16px 10px 0;margin-right:20px;font-size:0.8125rem;
    border-bottom:2px solid transparent;
  }
  .tab-btn.active{color:var(--text);border-bottom-color:var(--gold);}
  .tab-btn:hover{color:var(--text);}
  .tab-panel{display:none;}
  .tab-panel.active{display:block;}

  /* System filter chips */
  .chip-row{
    display:none;gap:8px;overflow-x:auto;padding-bottom:10px;margin-bottom:6px;
    -webkit-overflow-scrolling:touch;cursor:grab;
  }
  /* Grabbing-hand cursor and no accidental text selection while a mouse drag is in progress
     (enableDragToScroll in app.js toggles this class on #system-chips). */
  .dragging, .dragging *{cursor:grabbing !important;user-select:none;-webkit-user-select:none;}
  .chip-row.visible{display:flex;}
  .chip-row::-webkit-scrollbar{height:4px;}
  .chip{
    flex-shrink:0;background:var(--panel);border:1px solid var(--border);color:var(--muted);
    font-family:'Space Mono',monospace;font-size:0.7188rem;padding:6px 12px;border-radius:20px;
    white-space:nowrap;cursor:pointer;
  }
  .chip:hover{color:var(--text);border-color:var(--muted);}
  .chip.active{background:var(--gold);color:#1a1424;border-color:var(--gold);font-weight:700;}

  /* Game detail modal */
  .modal-backdrop{
    display:none;position:fixed;inset:0;background:rgba(10,8,16,0.75);
    z-index:100;padding:20px;padding-top:calc(20px + var(--status-h));overflow-y:auto;
  }
  .modal-backdrop.open{display:block;}
  .modal-card{
    max-width:480px;margin:20px auto 40px;background:var(--panel);
    border:1px solid var(--border);border-radius:8px;overflow:hidden;position:relative;
  }
  .modal-art{width:100%;aspect-ratio:4/3;object-fit:contain;background:var(--bg-alt);display:block;cursor:zoom-in;}
  .modal-art-wrap{position:relative;max-width:70%;margin:0 auto;}
  .modal-body{padding:20px;overflow-wrap:anywhere;}
  .modal-close{
    position:absolute;top:10px;right:10px;background:rgba(0,0,0,0.5);color:var(--text);
    width:30px;height:30px;border-radius:50%;font-size:1rem;line-height:1;z-index:2;
  }

  /* Game profile: its own full-screen view, not a popup over the
     dashboard. Same open/close JS as the other modals (.modal-backdrop),
     but styled to fill the entire viewport solidly so nothing from the
     dashboard shows behind or around it. */
  .game-profile-view{
    background:var(--bg);padding:0;overflow-x:hidden;overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-y:contain; /* keep the browser's own pull-to-reload out of the profile; the app handles it */
  }
  .game-profile-card{
    max-width:none;margin:0;border:none;border-radius:0;
    min-height:100%;min-height:100dvh;
    padding-top:calc(env(safe-area-inset-top) + var(--status-h));
    padding-bottom:env(safe-area-inset-bottom);
    overflow-x:hidden;
  }
  .game-profile-card .modal-art-wrap{max-width:min(70%, 672px);margin:0 auto;}
  .game-profile-card .modal-body{max-width:960px;margin:0 auto;padding:12px 20px 40px;}
  .game-profile-card .modal-close{
    top:calc(10px + env(safe-area-inset-top) + var(--status-h));right:calc(10px + env(safe-area-inset-right));
  }
  /* Game profile text runs 10% larger than the shared modal baseline used by
     the settings dialogs (Connect RA, Add game, RAWG, Data), scoped so it
     doesn't affect those. */
  .game-profile-card .modal-body h2{font-size:1.3125rem;}
  .game-profile-card .modal-body .sub{font-size:0.8938rem;}
  .game-profile-card .modal-links a{font-size:0.7937rem;}
  .game-profile-card .modal-note{font-size:0.7562rem;}
  .game-profile-card .rawg-setup-note{font-size:0.7562rem;}
  .modal-body h2{font-family:'Space Mono',monospace;font-size:1.1875rem;margin:0 0 4px;overflow-wrap:anywhere;}
  .modal-body .sub{color:var(--muted);font-size:0.8125rem;margin:0 0 16px;}
  .modal-meta{display:grid;grid-template-columns:1fr 1fr;gap:12px 16px;margin-bottom:18px;}
  .modal-meta .mi .k{font-size:0.725rem;color:var(--muted);font-family:'Space Mono',monospace;margin-bottom:2px;}
  .modal-meta .mi .v{font-size:0.8938rem;}
  .modal-progress{background:var(--bg-alt);border-radius:6px;padding:14px;margin-bottom:16px;}
  .modal-progress .row{display:flex;justify-content:space-between;font-size:0.8938rem;margin-bottom:8px;}
  .modal-progress .row:last-child{margin-bottom:0;}
  .modal-links{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px;}
  .modal-links a{
    font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--teal);
    border:1px solid var(--border);padding:6px 12px;border-radius:20px;text-decoration:none;
  }
  .modal-links a:hover{border-color:var(--teal);}
  .modal-note{font-size:0.6875rem;color:var(--muted);margin-top:14px;line-height:1.5;}

  .btn-view-achievements{
    width:100%;margin-top:14px;background:var(--bg-alt);border:1px solid var(--border);
    color:var(--text);border-radius:6px;padding:10px;font-family:'Space Mono',monospace;
    font-size:0.8625rem;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px;
  }
  .btn-view-achievements:hover{border-color:var(--gold);}
  .btn-view-achievements .arrow{transition:transform 0.15s;}
  .btn-view-achievements.open .arrow{transform:rotate(90deg);}
  .btn-view-achievements:disabled{opacity:0.8;cursor:default;}

  /* Game Details section: average playtime and the RAWG write-up */
  .gd-wrap{margin-top:10px;background:var(--bg-alt);border:1px solid var(--border);border-radius:6px;padding:12px;}
  .gd-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px;}
  .gd-label{font-size:0.725rem;color:var(--muted);font-family:'Space Mono',monospace;letter-spacing:0.04em;}
  .gd-mode{font-size:0.6875rem;color:var(--muted);}
  .gd-boxes{display:flex;gap:8px;}
  .gd-box{flex:1;background:var(--panel);border:1px solid var(--border);border-radius:4px;padding:10px;}
  .gd-box .gd-k{font-size:0.6875rem;color:var(--muted);}
  .gd-box .gd-v{font-size:1.25rem;color:var(--gold);margin:3px 0 2px;}
  .gd-box .gd-n{font-size:0.6875rem;color:var(--muted);min-height:1em;}
  .gd-empty{font-size:0.8125rem;color:var(--muted);}
  .gd-about-label{margin:14px 0 6px;}
  .gd-about{font-size:0.8125rem;line-height:1.55;white-space:pre-line;}
  .gd-about.clamp{display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;overflow:hidden;}
  .gd-more{background:none;border:0;padding:0;cursor:pointer;font-size:0.75rem;color:var(--gold);margin-top:6px;}
  .cheats-spinner{
    display:inline-block;width:0.9em;height:0.9em;margin-right:6px;vertical-align:-0.12em;
    border:2px solid currentColor;border-right-color:transparent;border-radius:50%;
    animation:cheats-spin 0.8s linear infinite;
  }
  @keyframes cheats-spin{to{transform:rotate(360deg);}}
  .achievements-list{margin-top:12px;display:flex;flex-direction:column;gap:1px;background:var(--border);border-radius:6px;overflow:hidden;border:1px solid var(--border);}
  .ach-row{background:var(--panel);padding:10px 12px;display:flex;align-items:center;gap:10px;}
  .ach-row.locked{opacity:0.55;}
  .ach-row img{width:36px;height:36px;border-radius:var(--radius);flex-shrink:0;image-rendering:pixelated;}
  .ach-row .info{flex:1;min-width:0;}
  .ach-row .info .t{font-size:0.8938rem;font-weight:600;margin:0 0 2px;}
  .ach-row .info .d{font-size:0.7937rem;color:var(--muted);margin:0;line-height:1.4;}
  .ach-row .info .when{font-size:0.725rem;color:var(--teal);margin:3px 0 0;}
  .ach-row .pts{
    font-family:'Space Mono',monospace;color:var(--gold);font-size:0.825rem;font-weight:700;flex-shrink:0;
    min-width:3ch;text-align:right;
  }
  .ach-row.locked .pts{color:var(--muted);}

  /* Gold "!" badge for a missable achievement, matches RA's own site marker.
     Shown on the achievement row itself, and doubles as the filter toggle's icon. */
  .ach-missable-badge{
    flex-shrink:0;width:22px;height:22px;border-radius:50%;
    border:2px dotted var(--gold);color:var(--gold);
    display:inline-flex;align-items:center;justify-content:center;
    font-family:'Comic Sans MS','Comic Neue',cursive;font-weight:700;font-size:0.95rem;line-height:1;
  }
  .ach-filter-row{padding:10px 12px;background:var(--panel);border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;}
  .ach-filter-left{display:flex;gap:8px;flex-wrap:wrap;}
  .ach-rows{display:flex;flex-direction:column;gap:1px;position:relative;}
  .ach-row.ach-shifting{transition:transform 0.15s ease;}
  .ach-reorder-hint{padding:6px 12px;background:var(--panel);border-bottom:1px solid var(--border);font-size:0.75rem;color:var(--muted);}
  .ach-reorder-controls{display:flex;flex-direction:column;align-items:center;justify-content:center;flex-shrink:0;}
  .ach-move-btn{background:rgba(255,255,255,0.05);border:none;border-radius:6px;color:var(--gold);font-size:1rem;line-height:1;padding:12px 16px;margin:2px 0;cursor:pointer;}
  .ach-move-btn:active{background:var(--gold);color:var(--bg);}
  .ach-row.dragging{background:var(--bg-alt);box-shadow:0 4px 14px rgba(0,0,0,0.5);position:relative;z-index:3;outline:1px solid var(--gold);transition:none;}
  .ach-filter-btn{
    display:inline-flex;align-items:center;gap:6px;padding:6px 12px;
    background:transparent;border:1px solid var(--gold-dim);border-radius:999px;
    color:var(--gold);font-family:'Inter',sans-serif;font-size:0.75rem;font-weight:600;cursor:pointer;
  }
  .ach-filter-btn:hover{border-color:var(--gold);}
  .ach-filter-btn.active{background:var(--gold);border-color:var(--gold);color:var(--bg);}
  .ach-filter-btn.active .ach-missable-badge{border-color:var(--bg);color:var(--bg);}
  .ach-filter-count{font-family:'Space Mono',monospace;font-size:0.6875rem;opacity:0.85;}

  /* Share/import a saved achievement order, tucked below the achievement
     list itself and visually quiet, since it's a niche feature most people
     browsing their achievements will never need. */
  .ach-share-footer-row{
    display:flex;gap:8px;justify-content:center;flex-wrap:wrap;
    padding:12px;border-top:1px solid var(--border);
  }
  .ach-share-footer-btn{
    background:transparent;border:none;color:var(--muted);
    font-family:'Inter',sans-serif;font-size:0.6875rem;font-weight:600;
    cursor:pointer;padding:4px 8px;opacity:0.75;
  }
  .ach-share-footer-btn:hover{color:var(--gold);opacity:1;}
  .ach-share-footer-error{padding:0 12px 12px;text-align:center;font-size:0.75rem;color:var(--danger);}

  .subsets-list{margin-top:12px;display:none;flex-direction:column;gap:8px;}
  .subset-head{
    width:100%;display:flex;align-items:center;gap:10px;padding:8px 10px;background:var(--bg-alt);
    border:1px solid var(--border);border-radius:6px;color:var(--text);font-family:'Space Mono',monospace;
    text-align:left;cursor:pointer;
  }
  .subset-head:hover{border-color:var(--gold);}
  .subset-head .arrow{transition:transform 0.15s;font-size:0.8625rem;}
  .subset-head.open .arrow{transform:rotate(90deg);}
  .subset-icon{width:36px;height:36px;border-radius:3px;object-fit:cover;background:var(--panel);flex-shrink:0;}
  .subset-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;}
  .subset-name{font-size:0.8125rem;font-weight:700;}
  .subset-meta{font-size:0.6562rem;color:var(--muted);}
  .subset-item .achievements-list{margin-top:8px;}
  .achievements-list-loading{padding:14px;text-align:center;color:var(--muted);font-size:0.8625rem;}

  .guide-panel{
    margin-top:12px;background:var(--panel);border:1px solid var(--border);
    border-radius:6px;padding:14px;
  }
  .guide-btn{
    border-radius:6px;padding:9px;font-family:'Space Mono',monospace;font-weight:700;
    font-size:0.7812rem;cursor:pointer;text-align:center;text-decoration:none;display:block;
  }
  .guide-btn-primary{background:var(--gold);border:none;color:#1a1408;}
  .guide-btn-outline{background:transparent;border:1px solid var(--teal);color:var(--teal);}
  .guide-btn-ghost{flex:1;background:transparent;border:1px solid var(--border);color:var(--text);font-size:0.725rem;padding:8px;}
  .guide-btn-danger{flex:1;background:transparent;border:1px solid var(--danger);color:var(--danger);font-size:0.725rem;padding:8px;}
  .guide-btn:disabled{opacity:0.6;cursor:default;}

  .guide-divider{display:flex;align-items:center;gap:10px;margin:2px 0;color:var(--muted);font-size:0.6625rem;letter-spacing:0.06em;text-transform:uppercase;}
  .guide-divider::before,.guide-divider::after{content:'';flex:1;height:1px;background:var(--border);}
  .guide-status-text{font-size:0.725rem;color:var(--muted);margin:0;line-height:1.5;}
  .guide-status-text.err{color:var(--danger);}

  /* Several guides saved per game, each its own row with its own saved
     reading position shown as a percentage (set under the guide's name,
     per guideVisibleTextLength/scrollFrac tracking in guides.js). */
  .guide-list{display:flex;flex-direction:column;gap:1px;background:var(--border);border-radius:6px;overflow:hidden;}
  .guide-list-item{
    background:var(--bg-alt);padding:9px 10px;display:flex;align-items:center;
    justify-content:space-between;gap:10px;
  }
  .guide-list-item-info{min-width:0;display:flex;flex-direction:column;gap:2px;}
  .guide-list-item-name{
    font-size:0.75rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;
    white-space:nowrap;max-width:34vw;
  }
  .guide-list-item-meta{font-size:0.675rem;color:var(--muted);letter-spacing:0.02em;}
  .guide-list-item-actions{display:flex;gap:6px;flex-shrink:0;}
  /* Three buttons per row now (Read / Rename / Remove): let the row wrap on narrow phones. */
  .guide-list-item{flex-wrap:wrap;}
  .guide-list-item-info{flex:1 1 120px;}
  .guide-list-item-name{max-width:100%;}
  .guide-list-item.renaming .guide-list-item-info{flex:1 1 100%;}
  .guide-rename-input{
    width:100%;box-sizing:border-box;background:var(--bg);border:1px solid var(--teal);color:var(--text);
    border-radius:4px;padding:7px 8px;font-family:'Space Mono',monospace;font-size:0.75rem;
  }
  .guide-list-item-btn{
    background:transparent;border:1px solid var(--teal);color:var(--teal);border-radius:4px;
    padding:6px 10px;font-family:'Space Mono',monospace;font-size:0.6875rem;font-weight:700;
    cursor:pointer;
  }
  .guide-list-item-btn.danger{border-color:var(--danger);color:var(--danger);}
  .guide-list-item-btn:disabled{opacity:0.6;cursor:default;}
  /* RetroAchievements guide results: the "GitHub" link is an <a> styled like the buttons, and long
     page names wrap instead of being cut off so two similar guides can be told apart. */
  a.guide-list-item-btn{display:inline-block;text-decoration:none;}
  .guide-list-item[data-ra-page] .guide-list-item-name{white-space:normal;overflow:visible;line-height:1.35;}

  .patch-result-list{display:flex;flex-direction:column;gap:1px;background:var(--border);border-radius:6px;overflow-y:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--border);margin-top:4px;max-height:340px;overscroll-behavior:contain;}
  .patch-result-row{background:var(--panel);padding:9px 11px;display:flex;align-items:center;gap:10px;}
  .patch-result-row .info{flex:1;min-width:0;}
  .patch-result-row .info .fn{font-size:0.7812rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .patch-result-row .info .pth{font-size:0.675rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
  .patch-result-row button{
    flex-shrink:0;background:transparent;border:1px solid var(--gold);color:var(--gold);
    border-radius:5px;padding:6px 10px;font-family:'Space Mono',monospace;font-size:0.6875rem;font-weight:700;cursor:pointer;
  }
  .patch-info-link{
    flex-shrink:0;max-width:88px;box-sizing:border-box;text-align:center;text-decoration:none;
    border:1px solid var(--border);color:var(--text);border-radius:5px;padding:5px 8px;
    font-family:'Space Mono',monospace;font-size:0.625rem;font-weight:700;line-height:1.25;
  }
  .patch-info-link:hover{border-color:var(--gold);}
  .hash-status{font-size:0.725rem;border-radius:5px;padding:8px 10px;line-height:1.45;}
  .hash-status.ok{background:rgba(89,201,165,0.12);color:var(--teal);border:1px solid rgba(89,201,165,0.3);}
  .hash-status.mismatch{background:rgba(226,104,92,0.12);color:var(--danger);border:1px solid rgba(226,104,92,0.3);}
  .hash-status.unknown{background:rgba(148,141,179,0.12);color:var(--muted);border:1px solid var(--border);}

  .guide-reader-overlay{
    --gr-bg:#000; --gr-bg-panel:#0e0e0e; --gr-bg-input:#161616; --gr-border:#2a2a2a; --gr-border-2:#444;
    --gr-text:#fff; --gr-muted:#9a9a9a; --gr-muted-2:#c9c9c9; --gr-accent:var(--gold);
    position:fixed;inset:0;background:var(--gr-bg);z-index:200;display:none;flex-direction:column;
    padding-top:calc(env(safe-area-inset-top, 0px) + var(--status-h));padding-bottom:env(safe-area-inset-bottom, 0px);
  }
  /* "Retro" theme: the same purple background and gold text used across the rest of the app. */
  .guide-reader-overlay[data-theme="retro"]{
    --gr-bg:var(--bg); --gr-bg-panel:var(--bg-alt); --gr-bg-input:var(--panel); --gr-border:var(--border);
    --gr-border-2:var(--border); --gr-text:var(--gold); --gr-muted:var(--gold-dim); --gr-muted-2:var(--gold-dim);
    --gr-accent:var(--gold);
  }
  .guide-reader-overlay.open{display:flex;}
  .guide-reader-header{
    display:flex;align-items:center;justify-content:space-between;gap:10px;flex-shrink:0;
    padding:12px 16px;border-bottom:1px solid var(--gr-border);
  }
  .guide-reader-header .guide-reader-fn{
    font-family:'Space Mono',monospace;font-size:0.75rem;color:var(--gr-muted);
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;
  }
  .guide-reader-toolbar{
    display:none;align-items:center;gap:6px;flex-shrink:0;padding:8px 16px;border-bottom:1px solid var(--gr-border);
  }
  .guide-reader-toolbar .spacer{flex:1;}
  .guide-reader-toolbar button,.guide-find-bar button,.guide-marks-panel button.tool-btn,.guide-text-panel button{
    display:inline-flex;align-items:center;justify-content:center;gap:6px;
    background:transparent;border:1px solid var(--gr-border-2);color:var(--gr-text);border-radius:4px;
    min-width:38px;padding:7px 10px;font-family:'Space Mono',monospace;font-weight:700;font-size:0.7812rem;cursor:pointer;
  }
  .guide-reader-toolbar button:disabled,.guide-find-bar button:disabled,.guide-text-panel button:disabled{opacity:0.35;cursor:default;}
  .guide-reader-toolbar button.active,.guide-text-panel button.active{border-color:var(--gr-accent);color:var(--gr-accent);}
  .guide-reader-toolbar svg{flex-shrink:0;}
  .guide-find-bar,.guide-marks-panel,.guide-text-panel{
    display:none;flex-direction:column;gap:8px;flex-shrink:0;padding:10px 16px;background:var(--gr-bg-panel);border-bottom:1px solid var(--gr-border);
  }
  .guide-find-bar.open,.guide-marks-panel.open,.guide-text-panel.open{display:flex;}
  .guide-text-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap;}
  .guide-text-row .lbl{font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--gr-muted);width:38px;flex-shrink:0;}
  .guide-text-row .size-label{font-family:'Space Mono',monospace;font-size:0.7812rem;color:var(--gr-text);min-width:26px;text-align:center;}
  .guide-text-row .grow{flex:1;}
  .guide-font-options{display:flex;flex-wrap:wrap;gap:6px;flex:1;}
  .guide-text-note{font-family:'Space Mono',monospace;font-size:0.6875rem;color:var(--gr-muted);margin:0;line-height:1.5;}
  .guide-menu-show{
    display:none;position:absolute;z-index:5;right:8px;top:calc(env(safe-area-inset-top, 0px) + var(--status-h) + 8px);
    width:36px;height:36px;align-items:center;justify-content:center;border-radius:50%;
    background:rgba(30,30,30,0.6);border:1px solid rgba(255,255,255,0.25);color:#fff;opacity:0.65;cursor:pointer;padding:0;
  }
  .guide-reader-overlay.menu-hidden .guide-reader-header,
  .guide-reader-overlay.menu-hidden .guide-reader-toolbar,
  .guide-reader-overlay.menu-hidden .guide-find-bar,
  .guide-reader-overlay.menu-hidden .guide-marks-panel,
  .guide-reader-overlay.menu-hidden .guide-text-panel{display:none !important;}
  .guide-reader-overlay.menu-hidden .guide-menu-show{display:flex;}
  .guide-find-row{display:flex;align-items:center;gap:6px;}
  .guide-find-row input{
    flex:1;min-width:0;background:var(--gr-bg-input);border:1px solid var(--gr-border-2);color:var(--gr-text);border-radius:4px;
    padding:8px 10px;font-family:'Space Mono',monospace;font-size:1rem;
  }
  .guide-find-count{font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--gr-muted);white-space:nowrap;}
  .guide-find-back{flex:1;}
  .guide-marks-panel{max-height:45vh;overflow-y:auto;}
  .guide-marks-panel button.tool-btn{border-color:var(--gr-accent);color:var(--gr-accent);align-self:flex-start;}
  .guide-marks-msg{font-family:'Space Mono',monospace;font-size:0.7188rem;color:var(--gr-muted);margin:0;min-height:0;}
  .guide-marks-empty{font-family:'Space Mono',monospace;font-size:0.75rem;color:var(--gr-muted);margin:2px 0;line-height:1.5;}
  .guide-marks-row{display:flex;align-items:stretch;gap:6px;}
  .guide-marks-go{
    flex:1;min-width:0;text-align:left;background:var(--gr-bg-input);border:1px solid var(--gr-border);border-left:3px solid var(--gr-accent);color:var(--gr-text);
    border-radius:4px;padding:8px 10px;font-family:'Space Mono',monospace;font-size:0.75rem;cursor:pointer;
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  }
  .guide-marks-go .pct{color:var(--gr-accent);margin-right:8px;}
  .guide-marks-del{background:transparent;border:1px solid var(--gr-border-2);color:var(--gr-muted-2);border-radius:4px;width:38px;font-size:1rem;cursor:pointer;}
  ::highlight(guide-find){background-color:rgba(228,169,63,0.35);color:#fff;}
  ::highlight(guide-find-current){background-color:#e4a93f;color:#000;}
  ::highlight(guide-bookmark){background-color:rgba(228,169,63,0.22);}
  .guide-bm-mark{
    position:absolute;left:4px;width:5px;border-radius:3px;background:var(--gold);
    box-shadow:0 0 8px rgba(228,169,63,0.7);pointer-events:none;
  }
  .guide-reader-close{
    background:transparent;border:1px solid var(--gr-border-2);color:var(--gr-text);border-radius:4px;flex-shrink:0;
    padding:6px 14px;font-family:'Space Mono',monospace;font-size:0.7812rem;cursor:pointer;
  }
  .guide-reader-body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:18px 16px;position:relative;font-family:var(--guide-font,'Space Mono',monospace);font-weight:var(--guide-weight,400);}
  .guide-reader-body pre{
    font-family:inherit;font-weight:inherit;font-size:var(--guide-font-size,14px);line-height:1.65;color:var(--gr-text);
    white-space:pre-wrap;word-break:break-word;margin:0;
  }
  .guide-reader-body.html-guide{font-size:var(--guide-font-size,14px);line-height:1.65;color:var(--gr-text);}
  .guide-reader-body.html-guide code,.guide-reader-body.html-guide tt,.guide-reader-body.html-guide kbd,.guide-reader-body.html-guide samp{font-family:inherit;font-size:inherit;}
  .guide-reader-body.html-guide *{color:inherit !important;background:transparent !important;max-width:100%;box-sizing:border-box;}
  .guide-reader-body.html-guide a{color:var(--gr-accent) !important;}
  .guide-reader-body.html-guide pre{white-space:pre-wrap;word-break:break-word;}
  .guide-reader-body.html-guide img{max-width:100%;height:auto;vertical-align:middle;}
  /* Structure for guides converted from Markdown (RA guides) and for imported HTML guides. */
  .guide-reader-body.html-guide h1,.guide-reader-body.html-guide h2,.guide-reader-body.html-guide h3,
  .guide-reader-body.html-guide h4,.guide-reader-body.html-guide h5,.guide-reader-body.html-guide h6{line-height:1.3;margin:1.4em 0 0.5em;font-weight:700;}
  .guide-reader-body.html-guide h1{font-size:1.45em;}
  .guide-reader-body.html-guide h2{font-size:1.25em;}
  .guide-reader-body.html-guide h3{font-size:1.1em;}
  .guide-reader-body.html-guide h4,.guide-reader-body.html-guide h5,.guide-reader-body.html-guide h6{font-size:1em;}
  .guide-reader-body.html-guide p{margin:0 0 0.9em;}
  .guide-reader-body.html-guide ul,.guide-reader-body.html-guide ol{margin:0 0 0.9em;padding-left:1.4em;}
  .guide-reader-body.html-guide li{margin:0.2em 0;}
  .guide-reader-body.html-guide hr{border:0;border-top:1px solid var(--gr-border-2);margin:1.3em 0;}
  .guide-reader-body.html-guide blockquote{margin:0.8em 0;padding:0.1em 0 0.1em 12px;border-left:3px solid var(--gr-accent);}
  .guide-reader-body.html-guide .ra-table-wrap{overflow-x:auto;margin:0 0 0.9em;}
  .guide-reader-body.html-guide table{border-collapse:collapse;}
  .guide-reader-body.html-guide th,.guide-reader-body.html-guide td{border:1px solid var(--gr-border-2);padding:4px 8px;vertical-align:top;text-align:left;}
  .guide-reader-body.html-guide img.ra-badge{width:36px;height:36px;margin-right:4px;border-radius:3px;}
  .guide-reader-empty{padding:24px 8px;text-align:center;font-family:'Space Mono',monospace;font-size:0.8125rem;line-height:1.6;color:var(--gr-muted-2);}
  .guide-reader-body iframe{width:100%;height:100%;border:0;display:block;}


  .rawg-badge-row{
    position:absolute;right:14px;bottom:10px;display:flex;justify-content:flex-end;
    padding:0;min-height:0;
  }
  .rawg-score{
    font-family:'Rubik Distressed', cursive;
    font-size:2.125rem;
    line-height:1;
    padding:6px 12px 8px;
    border-radius:5px;
    transform:rotate(-6deg);
    text-shadow:0 1px 2px rgba(0,0,0,0.5);
    border:2px solid rgba(0,0,0,0.35);
    box-shadow:0 3px 8px rgba(0,0,0,0.45);
    white-space:nowrap;
    display:inline-block;
  }
  .rawg-score.tier-green{background:linear-gradient(135deg,#8fe0a8,#3fae5c);color:#0c2414;}
  .rawg-score.tier-yellow{background:linear-gradient(135deg,#f2df8a,#dcb52e);color:#3a2c05;}
  .rawg-score.tier-red{background:linear-gradient(135deg,#f0958a,#d8483a);color:#3a0a06;}
  .rawg-score.tier-muted{background:var(--panel-2);color:var(--muted);border-color:var(--border);box-shadow:none;transform:rotate(-3deg);font-size:1.375rem;}
  .rawg-setup-note{font-size:0.6875rem;color:var(--muted);margin:2px 0 0;}
  .rawg-setup-note a{color:var(--teal);cursor:pointer;}

  /* Box art pinch-to-zoom viewer ----
     Installed/fullscreen PWAs typically block native page pinch-zoom on most
     platforms, so box art can't be zoomed the normal browser way. This is a
     dedicated full-screen viewer with its own pinch/pan handling. */
  .img-zoom-overlay{
    display:none;position:fixed;inset:0;background:rgba(8,6,14,0.96);
    z-index:300;overflow:hidden;touch-action:none;
  }
  .img-zoom-overlay.open{display:flex;align-items:center;justify-content:center;}
  .img-zoom-overlay img{
    max-width:100%;max-height:100%;touch-action:none;-webkit-user-drag:none;
    user-select:none;-webkit-user-select:none;transform-origin:center center;
  }
  .img-zoom-overlay .modal-close{
    top:calc(10px + env(safe-area-inset-top) + var(--status-h));right:calc(10px + env(safe-area-inset-right));
  }
  .img-zoom-hint{
    position:absolute;left:0;right:0;bottom:calc(18px + env(safe-area-inset-bottom));
    text-align:center;font-family:'Space Mono',monospace;font-size:0.6875rem;color:var(--muted);
    pointer-events:none;transition:opacity 0.3s;
  }
  .img-zoom-hint.hidden{opacity:0;}

  /* Library search row + add game */
  .lib-search-row{display:flex;gap:8px;margin-bottom:12px;}
  .lib-search-row .lib-search{margin-bottom:0;flex:1;}
  .lib-search-row .btn-ghost{flex-shrink:0;white-space:nowrap;}

  #addgame-card select, .field select{
    width:100%;padding:10px 12px;background:var(--bg-alt);
    border:1px solid var(--border);border-radius:3px;color:var(--text);
    font-size:0.875rem;font-family:'Inter',sans-serif;
  }
  #addgame-card select:focus, .field select:focus{outline:none;border-color:var(--gold);}

  /* Open dropdown lists: the phone/OS draws these itself and defaults to black or white
     depending on its own theme, so set the app's purple and gold explicitly. */
  select{color-scheme:dark;}
  select option, select optgroup{background:var(--panel);color:var(--gold);}
  select option:checked{background:var(--panel-2);}
  #addgame-results, #link-ra-results{margin-top:16px;max-height:280px;overflow-y:auto;}
  .ag-result{
    display:flex;align-items:center;gap:10px;padding:8px 6px;border-radius:4px;cursor:pointer;
  }
  .ag-result:hover{background:var(--bg-alt);}
  .ag-result.selected{background:var(--bg-alt);box-shadow:inset 2px 0 0 var(--gold);}
  .ag-result img{width:32px;height:32px;border-radius:2px;image-rendering:pixelated;flex-shrink:0;}
  .ag-result .t{font-size:0.8125rem;flex:1;}
  .ag-result .n{font-size:0.6562rem;color:var(--muted);font-family:'Space Mono',monospace;}
  .ag-checkbox{flex-shrink:0;width:16px;height:16px;accent-color:var(--gold);cursor:pointer;}
  .ag-empty{font-size:0.7812rem;color:var(--muted);margin-top:14px;}

  .addgame-selection-bar{
    position:sticky;bottom:0;margin-top:12px;padding:10px 12px;
    background:var(--panel-2);border:1px solid var(--border);border-radius:var(--radius);
    display:flex;align-items:center;justify-content:space-between;gap:10px;
  }
  .addgame-selection-bar span{font-size:0.8125rem;color:var(--text);}
  .addgame-selection-bar .btn-primary{width:auto;padding:8px 16px;}

  /* Custom (non-RA) add-game results: platform comes from a dropdown built
     from that game's own RAWG data, plus an explicit add button, instead of
     the whole row being one big "click to add" target. */
  .ag-result-custom{cursor:default;flex-wrap:wrap;}
  .ag-result-custom:hover{background:transparent;}
  .ag-platform-select{
    flex:0 0 auto;max-width:150px;padding:6px 8px;background:var(--bg-alt);
    border:1px solid var(--border);border-radius:3px;color:var(--text);
    font-size:0.75rem;font-family:'Inter',sans-serif;
  }
  .ag-platform-select:focus{outline:none;border-color:var(--gold);}
  .ag-add-btn{
    flex-shrink:0;width:28px;height:28px;border-radius:4px;border:1px solid var(--gold);
    background:transparent;color:var(--gold);font-size:1rem;line-height:1;cursor:pointer;
  }
  .ag-add-btn:hover{background:var(--gold);color:var(--bg);}

  .g-title{position:relative;}
  .manual-remove{
    background:transparent;border:none;color:var(--muted);font-size:0.8125rem;
    margin-left:8px;padding:2px 6px;flex-shrink:0;
  }
  .manual-remove:hover{color:var(--danger);}

  /* By year */
  .year-group{margin-bottom:28px;}
  .year-heading{
    font-family:'Space Mono',monospace;font-size:0.9375rem;color:var(--text);
    margin:0 0 12px;display:flex;align-items:baseline;gap:8px;
  }
  .year-heading .n{font-size:0.6875rem;color:var(--muted);font-weight:400;}
  .year-icons{display:flex;flex-wrap:wrap;gap:12px;}
  .year-item{width:60px;text-align:center;cursor:pointer;position:relative;}
  .year-item img{
    width:48px;height:48px;border-radius:3px;image-rendering:pixelated;
    border:1px solid var(--border);display:block;margin:0 auto 5px;
  }
  .year-item{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;}
  .year-tip{
    position:fixed;z-index:120;max-width:70vw;padding:6px 10px;border-radius:4px;
    background:var(--panel-2);border:1px solid var(--gold);color:var(--text);
    font-size:0.75rem;line-height:1.3;pointer-events:none;opacity:0;visibility:hidden;
    transition:opacity 0.1s;
  }
  .year-tip.show{opacity:1;visibility:visible;}

  /* Mastered label sitting on the bottom edge of a Beaten by Year icon. The 5px offset is
     the gap under the icon, so the pill lands just inside the art. */
  .year-item .pill-year{
    position:absolute;left:50%;bottom:8px;transform:translateX(-50%);
    padding:1px 4px;text-align:center;
    font-size:0.375rem;line-height:1.2;letter-spacing:0;
    background:rgba(21,18,31,0.85);border:1px solid currentColor;
  }

  .empty, .loading{
    text-align:center;color:var(--muted);padding:30px 10px;font-size:0.8125rem;
  }
  .loading::after{
    content:'';display:inline-block;width:12px;height:12px;margin-left:8px;
    border:2px solid var(--border);border-top-color:var(--gold);border-radius:50%;
    animation:spin 0.7s linear infinite;vertical-align:middle;
  }
  @keyframes spin{to{transform:rotate(360deg);}}

  @media (max-width:520px){
    .profile-hero{flex-direction:column;align-items:flex-start;}
    .stat-row{width:100%;justify-content:space-between;}
    .stat{text-align:left;}
    .lib-table .bar{display:none;}
  }

  /* Reorder mode: rows are pick-up-and-drag, so suppress text selection and the
     image long-press callout that would otherwise fight the hold gesture. */
  .ach-rows.reordering .ach-row{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;}
  .ach-rows.reordering .ach-row img{pointer-events:none;-webkit-user-drag:none;}
  .ach-row.dragging{transform-origin:center;}

  /* Walkthrough videos (Search YouTube panel) */
  .yt-find{width:100%;}
  .yt-hint{font-size:0.7188rem;color:var(--muted);margin:8px 0 12px;line-height:1.5;}
  .yt-add-row{display:flex;gap:8px;}
  .yt-input{
    flex:1;min-width:0;padding:10px 12px;background:var(--bg-alt);border:1px solid var(--border);
    border-radius:var(--radius);color:var(--text);font-size:0.875rem;font-family:'Inter',sans-serif;
  }
  .yt-input:focus{outline:none;border-color:var(--gold);}
  .yt-save-btn{background:var(--gold);color:#1a1424;padding:10px 16px;flex-shrink:0;}
  .yt-save-btn:disabled{background:var(--gold-dim);cursor:wait;}
  .yt-msg{font-size:0.7188rem;color:var(--muted);margin-top:6px;min-height:0;line-height:1.5;}
  .yt-msg:empty{display:none;}
  .yt-msg.err{color:var(--danger);}
  .yt-list{margin-top:12px;max-height:260px;overflow-y:auto;display:flex;flex-direction:column;gap:6px;-webkit-overflow-scrolling:touch;}
  .yt-empty{font-size:0.75rem;color:var(--muted);text-align:center;padding:10px;}
  .yt-item{display:flex;align-items:stretch;background:var(--bg-alt);border:1px solid var(--border);border-radius:6px;overflow:hidden;}
  .yt-item.playing{border-color:var(--gold);}
  .yt-item-main{
    flex:1;min-width:0;display:flex;align-items:center;gap:10px;background:none;color:var(--text);
    padding:6px;text-align:left;font-family:'Inter',sans-serif;font-weight:600;font-size:0.8125rem;
  }
  .yt-thumb{width:84px;aspect-ratio:16/9;object-fit:cover;border-radius:4px;background:#000;flex-shrink:0;}
  .yt-thumb-list{display:flex;align-items:center;justify-content:center;color:var(--gold);font-size:1.25rem;}
  .yt-item-title{
    overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.35;
  }
  .yt-item-del{background:none;color:var(--muted);padding:0 14px;font-size:0.9rem;}
  .yt-item-del:hover{color:var(--danger);}
  .yt-player-wrap{margin-top:12px;}
  .yt-player-box{width:100%;aspect-ratio:16/9;background:#000;border-radius:6px;overflow:hidden;}
  .yt-player-box iframe{width:100%;height:100%;border:0;display:block;}
  .yt-player-tools{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:8px;}
  .yt-max-btn{background:transparent;border:1px solid var(--gold);color:var(--gold);padding:8px 12px;}
  .yt-open-link{font-size:0.7188rem;color:var(--teal);text-decoration:none;}
  .yt-max-bar{display:none;}
  /* Maximised: fills the whole screen; the video takes everything below a slim bar. */
  .yt-player-wrap.yt-max{
    position:fixed;inset:0;z-index:10;margin:0;background:#000;display:flex;flex-direction:column;
    padding-top:calc(env(safe-area-inset-top) + var(--status-h));padding-bottom:env(safe-area-inset-bottom);
  }
  .yt-player-wrap.yt-max .yt-max-bar{
    display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;
    background:#0b0912;color:var(--text);font-size:0.75rem;flex-shrink:0;
  }
  .yt-max-title{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-family:'Inter',sans-serif;}
  .yt-max-close{background:var(--gold);color:#1a1424;padding:7px 12px;flex-shrink:0;}
  .yt-player-wrap.yt-max .yt-player-box{flex:1;aspect-ratio:auto;border-radius:0;}
  .yt-player-wrap.yt-max .yt-player-tools{display:none !important;}

  /* Status row: badge first, then the date beaten to its right, sitting flush with the other values. */
  .modal-progress .status-val{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:4px 10px;}
  .modal-progress .beaten-date{white-space:nowrap;color:var(--teal);}

  /* About dialog */
  .about-links{display:flex;flex-direction:column;gap:1px;background:var(--border);border-radius:6px;overflow:hidden;}
  .about-link{
    background:var(--bg-alt);padding:11px 12px;display:flex;flex-direction:column;gap:2px;
    color:var(--text);text-decoration:none;font-size:0.8125rem;font-weight:700;
  }
  .about-link span{font-size:0.7rem;font-weight:400;color:var(--teal);word-break:break-all;}
  .about-credits{margin-top:18px;padding-top:14px;border-top:1px solid var(--border);}
  .about-credits-title{font-size:0.75rem;font-weight:700;color:var(--gold);letter-spacing:0.04em;text-transform:uppercase;margin-bottom:8px;}
  .about-credits p{font-size:0.75rem;color:var(--muted);line-height:1.6;margin:0 0 8px;}
  .about-credits a{color:var(--teal);text-decoration:none;}

  /* Small teal "RA" link on each achievement row -> that achievement's page on retroachievements.org */
  .ach-ra-link{
    flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;
    width:26px;padding:1px 0;border:1px solid var(--teal);border-radius:999px;box-sizing:border-box;
    color:var(--teal);font-size:0.7937rem;font-weight:700;letter-spacing:0;text-decoration:none;line-height:1.3;
  }
  .ach-ra-link:hover,.ach-ra-link:focus-visible{background:var(--teal);color:var(--bg);}

  /* Social */
  .dropdown-gold{color:var(--gold);font-weight:700;}
  .soc-list{border-top:1px solid var(--border);}
  .soc-row{
    display:flex;align-items:center;gap:10px;width:100%;text-align:left;background:transparent;border:none;
    border-bottom:1px solid var(--border);padding:10px 2px;color:var(--text);cursor:pointer;font-family:inherit;
  }
  .soc-row:hover{background:var(--bg-alt);}
  .soc-av-wrap{position:relative;width:36px;height:36px;flex-shrink:0;display:inline-block;}
  .soc-av-wrap.lg{width:52px;height:52px;}
  .soc-av,.soc-av-fallback{
    width:100%;height:100%;border-radius:50%;border:1px solid var(--border);background:var(--panel-2);object-fit:cover;
  }
  .soc-av-fallback{display:none;align-items:center;justify-content:center;color:var(--gold);font-size:0.75rem;font-weight:700;font-family:'Space Mono',monospace;}
  .soc-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;}
  .soc-name{font-family:'Space Mono',monospace;font-size:0.8125rem;font-weight:700;color:var(--text);}
  .soc-game{font-size:0.75rem;color:var(--text);margin:0;}
  .soc-console{color:var(--muted);}
  .soc-rp{font-size:0.6875rem;color:var(--muted);margin:2px 0 0;line-height:1.4;}
  .soc-main .soc-game,.soc-main .soc-rp{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .soc-status{font-size:0.6875rem;white-space:nowrap;color:var(--muted);flex-shrink:0;}
  .soc-status.playing{color:var(--teal);}
  .soc-dot{display:inline-block;width:7px;height:7px;border-radius:50%;margin-right:5px;}
  .soc-note{font-size:0.6875rem;color:var(--muted);margin:10px 0 0;}
  .soc-refresh{width:100%;margin-top:14px;}
  .soc-find{font-size:0.75rem;color:var(--muted);line-height:1.5;margin:14px 0 0;padding-top:12px;border-top:1px solid var(--border);}
  .soc-find a,.soc-back{color:var(--teal);text-decoration:none;}
  .soc-back{background:transparent;border:none;font-family:'Space Mono',monospace;font-size:0.8125rem;padding:0;margin:0 0 12px;cursor:pointer;}
  .soc-head{display:flex;align-items:center;gap:12px;margin-bottom:12px;}
  .soc-now{background:var(--bg-alt);border:1px solid var(--border);border-radius:var(--radius);padding:10px 12px;margin-bottom:12px;}
  .soc-now .soc-game{font-size:0.8125rem;font-weight:600;}
  .soc-profile-link{display:block;text-align:center;text-decoration:none;box-sizing:border-box;}
