/* Automatic platform theme. Game art keeps its authored palette; the Arcade
   shell, collections, rankings and profile follow the device in real time. */
:root { color-scheme:dark; }
html.kids-touch-guard, html.kids-touch-guard body { overscroll-behavior:none; }
html.kids-touch-guard #kids-frame-shell { overscroll-behavior:none; }
.arcade-icon-definitions { position:absolute; width:0; height:0; overflow:hidden; pointer-events:none; }
.arcade-light-icon { display:none; }
.classic-cartridge-sticker.cartridge-art-label { position:relative; z-index:1; padding:0; display:block; overflow:hidden; background:#10232c; }
.classic-cartridge-sticker.cartridge-art-label img { max-height:none; object-fit:contain; aspect-ratio:1.5; }
.topbar > .topbar-actions { min-width:0; flex:0 1 auto; }

/* Mobile: a photo/name is one target, not a circle inside a second plate.
   A dedicated row leaves comfortable space between profile, presence and menu. */
@media (max-width:600px) {
  html[data-arcade-home-view] body[data-arcade-screen] .topbar { flex-wrap:wrap; align-items:center; gap:12px; }
  html[data-arcade-home-view] body .topbar > .brand { flex:1 0 100%; }
  html[data-arcade-home-view] body .topbar > .brand > span:last-child { display:inline; }
  html[data-arcade-home-view] body .topbar > .topbar-actions {
    display:flex; flex:1 0 100%; width:100%; min-width:0;
    justify-content:space-between; gap:16px; flex-wrap:nowrap;
  }
  .topbar-actions > .arcade-account-summary { flex:1 1 auto; }
  #account-button.arcade-account-chip {
    flex:0 1 auto; width:auto; max-width:100%; min-width:44px;
    min-height:46px; padding:0; gap:8px; border:0; border-radius:0;
    background:transparent; box-shadow:none;
  }
  #account-button.arcade-account-chip:hover,#account-button.arcade-account-chip:active {
    background:transparent; box-shadow:none;
  }
  #account-button #account-avatar { width:40px; height:40px; flex:0 0 40px; box-shadow:none; }
  #account-button #account-avatar img { width:100%; height:100%; object-fit:cover; mix-blend-mode:normal; }
  #account-button-label { display:block; max-width:15ch; font-size:13px; }
  .topbar-actions > .arcade-presence-chip { flex:0 0 auto; }
  .topbar-actions > .arcade-quick-menu-wrap { flex:0 0 auto; }
}

@media (prefers-color-scheme:light) {
  :root {
    color-scheme:light;
    --ink:#142d3a;
    --muted:#526d7a;
    --navy:#f4f8fb;
    --navy-2:#e7f0f5;
    --line:rgba(24,70,91,.18);
    --aqua:#087c82;
    --coral:#b84f31;
    --gold:#896000;
    --arcade-cyan:#087c82;
  }

  body {
    color:var(--ink);
    background:
      radial-gradient(circle at 15% 0%,rgba(69,184,192,.2) 0,transparent 30rem),
      radial-gradient(circle at 90% 100%,rgba(80,132,190,.16) 0,transparent 28rem),
      #f4f8fb;
  }

  .brand,.game-header h1,.hero h1 { color:#102b3a; }
  .brand-mark { border-color:#5e9fbb; background:#fff; box-shadow:0 5px 14px rgba(28,91,120,.15); }
  .hero-copy,.privacy-note,.instruction,.game-message,.collection-navigation { color:#526d7a; }

  .arcade-account-chip,.arcade-presence-chip,.arcade-menu-trigger {
    border-color:#b5ced9;
    color:#173949;
    background:#fff;
    box-shadow:0 7px 18px rgba(26,73,94,.09);
  }
  .arcade-account-chip:hover,.arcade-menu-trigger:hover,.arcade-menu-trigger[aria-expanded="true"] {
    border-color:#4a9ba0;
    background:#edf8f7;
  }
  .arcade-presence-chip>img,.arcade-menu-trigger>img { display:none; }
  .arcade-light-icon {
    display:block; flex:none; width:32px; height:32px; padding:3px;
    fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round;
    stroke-linejoin:round; color:#087c82; pointer-events:none;
  }
  /* Menu artwork is shared by both themes; only the surrounding surface changes. */
  .arcade-menu-item>.arcade-light-icon { display:none; }
  .arcade-presence-text strong { color:#087c72; }
  .arcade-presence-text>span { color:#5e7480; }

  #arcade-quick-menu.arcade-menu-panel {
    border-color:#bfd1da;
    color:#17323f;
    background:#fff;
    box-shadow:0 20px 52px rgba(31,66,82,.2);
    scrollbar-color:#9bb5c1 transparent;
  }
  .arcade-menu-heading { color:#637d89; }
  .arcade-menu-panel .arcade-menu-item { color:#17323f; }
  .arcade-menu-panel .arcade-menu-item:hover { border-color:#c5dde2; background:#edf7f7; }
  .arcade-menu-panel .arcade-menu-item:active { background:#dceeee; }
  .arcade-menu-item>img { mix-blend-mode:normal; filter:url(#menu-light-art); }
  .arcade-menu-panel .arcade-menu-item:focus-visible { outline:3px solid #087c82; outline-offset:2px; }
  .arcade-menu-text small { color:#607d89; }
  .arcade-menu-divider { background:#dbe6eb; }

  #home .game-card,.game-card {
    border-color:#c5d8df;
    color:#17323f;
    background:rgba(255,255,255,.9);
    box-shadow:0 16px 36px rgba(37,81,100,.1),inset 0 1px #fff;
  }
  #home .game-card h2,.game-card h2 { color:#17323f; }
  #home .game-card p:not(.eyebrow),.game-card p:not(.eyebrow) { color:#58717d; }
  #home .game-card .eyebrow,.game-card .eyebrow { color:#087c82; }

  .play-area,.leaderboards-area,.achievements-area {
    border-color:#c4d8df;
    color:#17323f;
    background:rgba(255,255,255,.9);
    box-shadow:0 20px 46px rgba(33,75,93,.11);
  }
  .leaderboard-panel,.achievement-group,.achievements-intro,
  .achievement-showcase,.arcade-profile-card {
    border-color:#c7dbe2;
    color:#17323f;
    background:#f8fbfc;
    box-shadow:none;
  }
  .global-leaderboard { border-color:#d3c6df; background:#fbf8fd; }
  .leaderboard-panel h2,.achievement-group-header h2,.achievement-card h3,
  .achievements-intro h2,.arcade-profile-card h3 { color:#17323f; }
  .leaderboard-row,.achievement-card {
    border-color:#d3e1e6;
    color:#17323f;
    background:#fff;
  }
  .leaderboard-row strong { color:#17323f; }
  .leaderboard-identity small,.achievement-card p,.achievements-intro p:last-child,
  .global-leaderboard-status,.achievement-card.is-locked h3,
  .achievement-card.is-locked p { color:#607985; }
  .leaderboard-value,.achievement-card-state { color:#087c82; }
  .leaderboard-select-label,.progress-toolbar label { color:#375d6d; }
  .leaderboard-source-pill { border-color:#75b9b4; color:#176b67; background:#dff3ef; }
  .leaderboard-storage-note { color:#087c82; }
  .leaderboard-select-label select,.progress-toolbar select,.score-entry-panel input {
    border-color:#abcbd2;
    color:#17323f;
    background:#fff;
  }
  .achievements-intro .eyebrow,.achievement-group-header span { color:#795700; }
  .achievement-card[class*="achievement-tier-"] .achievement-card-state { color:#087c82; }
  .achievement-card[class*="achievement-tier-"].is-locked .achievement-card-state { color:#526d7a; }
  footer { color:#526d7a; }

  .arcade-dialog,.fish-howto-dialog { background:rgba(219,231,237,.83); }
  .dialog-panel,.fish-howto-panel {
    border-color:#bcd2dc;
    color:#17323f;
    background:#fff;
    box-shadow:0 22px 55px rgba(28,67,84,.22);
  }
  .dialog-panel :is(h1,h2,h3),.fish-howto-panel :is(h1,h2,h3) { color:#17323f; }
  .dialog-panel p,.account-privacy-copy,.account-message { color:#58717d; }
  /* The 2048 recovery offer needs its own light surface/text pair; its
     authored pale-gold copy is intended for the dark result dialog only. */
  #arcade-dialog #undo-2048-copy { border-color:#c99b43; background:#fff6df; }
  #arcade-dialog #undo-2048-copy p { color:#654b16; }
  #arcade-dialog #dialog-restart { color:#fff; background:#087c82; }
  #arcade-dialog #dialog-restart:not(:disabled):hover { background:#06666c; }
  #arcade-dialog #dialog-restart:not(:disabled):active { background:#054f55; }
  #arcade-dialog :is(#dialog-restart,#dialog-undo-2048):focus-visible { outline:3px solid #087c82; outline-offset:3px; }
  .account-panel>p:not(.eyebrow):not(.account-message),
  .account-panel .account-privacy-copy { color:#526d7a; }
  .account-panel .piscisauth-vinculo small,
  .account-panel .account-notify small,
  .account-panel .piscis-register-hint { color:#526d7a; }
  .account-panel .piscisauth-desvincular {
    min-height:44px; padding:8px 12px; border-radius:10px; color:#245164;
  }
  .account-panel .piscisauth-desvincular:hover,
  .account-panel .piscisauth-desvincular:focus-visible {
    color:#075a61; background:#e8f4f5;
  }
  .account-panel .piscisauth-desvincular:active { color:#03474d; background:#cce4eb; }
  .account-panel .piscisauth-desvincular:focus-visible { outline:3px solid #087c82; outline-offset:2px; }
  .account-panel .account-notify { border-color:#c4d8df; background:#f6fafb; }
  .account-panel .piscis-signin-form label { color:#375d6d; }
  .account-panel .piscis-signin-form input { border-color:#91b3c2; color:#17323f; background:#fff; }
  .account-panel .piscis-signin-form input:focus-visible { outline:3px solid #087c82; }
  .account-panel .account-message.is-error { color:#a12f35; }
  .arcade-profile-card .eyebrow { color:#087c82; }
  .arcade-profile-card h3 { color:#17323f; }
  .arcade-profile-card p:last-child { color:#58717d; }
  .dialog-close { border-color:#abcbd2; color:#245164; background:#edf6f8; }
  .dialog-close:hover { border-color:#087c82; color:#fff; background:#087c82; }

  /* Friends has its own dark cards and form styles in styles.css. Keep these
     overrides scoped so the multiplayer game pickers retain their artwork. */
  .friends-panel .friend-add-form label { color:#375d6d; }
  .friends-panel .friend-add-form input {
    border-color:#91b3c2; color:#17323f; background:#fff;
  }
  .friends-panel .friend-add-form input::placeholder { color:#526d7a; opacity:1; }
  .friends-panel .friend-add-form input:focus {
    border-color:#087c82; box-shadow:0 0 0 3px rgba(8,124,130,.18);
  }
  .friends-panel .friend-add-form input::-webkit-search-cancel-button { filter:none; }
  .friends-panel .friends-section { border-color:#c4d8df; }
  .friends-panel .friend-suggestions-section { background:#f2f7fa; }
  .friends-panel .friend-row,.friends-panel .friend-row.is-suggestion {
    border-color:#c4d8df; background:#fff;
  }
  .friends-panel .friend-row-copy strong { color:#17323f; }
  .friends-panel .friend-row-copy small,.friends-panel .friend-empty { color:#526d7a; }
  .friends-panel .friend-empty { border-color:#a9c3cf; background:#f8fbfc; }
  .friends-panel .friend-row-actions button {
    min-height:44px; border-color:#91b3c2; color:#17485a; background:#edf6f8;
  }
  .friends-panel .friend-row-actions button:is([data-friend-action="reject"],[data-friend-action="remove"]) { color:#a12f35; }
  .friends-panel .friend-row-actions button[data-friend-action="accept"],
  .friends-panel .primary-button { border-color:#087c82; color:#fff; background:#087c82; }
  .friends-panel .friend-row-actions button:not(:disabled):hover { background:#dceeee; border-color:#087c82; }
  .friends-panel .friend-row-actions button[data-friend-action="accept"]:not(:disabled):hover,
  .friends-panel .primary-button:not(:disabled):hover { color:#fff; background:#06666c; }
  .friends-panel .friend-row-actions button:not(:disabled):active { background:#cce4eb; }
  .friends-panel .friend-row-actions button[data-friend-action="accept"]:not(:disabled):active,
  .friends-panel .primary-button:not(:disabled):active { color:#fff; background:#054f55; }
  .friends-panel button:focus-visible { outline:3px solid #087c82; outline-offset:3px; }
  .friends-panel .friend-row-actions button:disabled {
    opacity:1; color:#526d7a; border-color:#c4d8df; background:#e7eef2;
  }

  .back-link,.platform-back-link {
    border-color:#77aebc !important;
    color:#17485a !important;
    background:linear-gradient(180deg,#fff,#e8f3f6) !important;
    box-shadow:0 7px 15px rgba(30,81,101,.13),inset 0 1px #fff !important;
  }
  .back-link::before,.platform-back-link::before { border-color:currentColor; }
  .back-link:hover,.platform-back-link:hover,
  .back-link:focus-visible,.platform-back-link:focus-visible {
    color:#123c4d !important;
    border-color:#3f889b !important;
    background:#dff0f3 !important;
    filter:none;
  }
  .back-link:focus-visible,.platform-back-link:focus-visible {
    outline:3px solid #087c82;
    outline-offset:3px;
  }
  .back-link:active,.platform-back-link:active {
    color:#123c4d !important;
    border-color:#3f889b !important;
    background:#cce4eb !important;
    filter:none;
  }

  .score-box,.level-box { background:rgba(8,124,130,.1); }
  .score-box span,.level-box span { color:#5d7580; }
  .score-box strong,.level-box strong { color:#087c82; }

  .achievement-toast {
    border-color:#c89c36;
    color:#17323f;
    background:rgba(255,251,237,.98);
    box-shadow:0 18px 42px rgba(36,71,86,.2);
  }
  .achievement-toast-copy strong { color:#17323f; }
  .achievement-toast-copy em { color:#607985; }

  .arcade-avatar-option {
    border-color:#c4d8df;
    background:#edf4f7;
  }
  .arcade-avatar-option:hover,.arcade-avatar-option.is-selected {
    border-color:#4a9ba0;
    background:#dff1f0;
  }
  .provider-avatar-button {
    border-color:#bfd5dc;
    color:#17323f;
    background:#f4f8fa;
  }
  .provider-avatar-button:hover,.provider-avatar-button.is-selected { border-color:#4a9ba0; background:#e1f1f0; }
  .achievement-showcase article {
    border-color:#c9dce3;
    background:#fff;
  }
  .achievement-showcase small { color:#5f7884; }
  .achievement-showcase strong { color:#17323f; }
  .platinum-shelf {
    border-color:#cadce4;
    background:#f5f9fb;
  }
  .platinum-shelf .eyebrow { color:#527181; }
  .platinum-shelf h2 { color:#17323f; }
  .platinum-badge { border-color:#c6d7df; color:#6f8792; background:#eaf1f4; }

  /* The cabinet showcase and game-authored canvases remain deliberately dark:
     they are artwork, not application chrome. */
  .fliperama-home-showcase { color:#eef9ff; color-scheme:dark; }
}

/* Desktop collection titles follow the page theme without an individual chip. */
@media (min-width:621px) {
  #leaderboards .game-header,
  #achievements .game-header { align-items:center; flex-wrap:wrap; }
  #leaderboards .game-header > div:first-child,
  #achievements .game-header > div:first-child {
    display:flex;
    align-items:center;
    gap:18px;
    min-width:0;
  }
  #leaderboards .game-header .back-link,
  #achievements .game-header .back-link { flex:0 0 auto; margin:0; }
}

/* Collection pages share one mobile heading instead of two touching chips.
   The dark surface stays readable if Android changes the page backdrop. */
@media (max-width:620px) {
  #leaderboards .game-header,
  #achievements .game-header { flex-wrap:wrap; align-items:center; gap:10px; }
  #leaderboards .game-header > div:first-child,
  #achievements .game-header > div:first-child {
    display:flex;
    align-items:center;
    gap:10px;
    width:100%;
    min-width:0;
    padding:5px 14px 5px 5px;
    border:1px solid #527684;
    border-radius:17px;
    background:linear-gradient(115deg,#173b4d,#215263);
    box-shadow:0 8px 18px rgba(9,47,65,.18);
  }
  #leaderboards .game-header .back-link,
  #achievements .game-header .back-link {
    flex:0 0 auto;
    min-width:0;
    min-height:44px;
    margin:0;
    padding:0 10px;
    border:0 !important;
    border-right:1px solid rgba(232,250,255,.28) !important;
    border-radius:0;
    color:#f3fcff !important;
    background:transparent !important;
    box-shadow:none !important;
  }
  #leaderboards .game-header .back-link:hover,
  #achievements .game-header .back-link:hover,
  #leaderboards .game-header .back-link:active,
  #achievements .game-header .back-link:active { color:#fff !important; background:rgba(255,255,255,.1) !important; }
  #leaderboards .game-header h1,
  #achievements .game-header h1 {
    display:block;
    min-width:0;
    margin:0;
    padding:0;
    border-radius:0;
    color:#f3fcff;
    background:transparent;
    font-size:clamp(1.4rem,6vw,2rem);
    line-height:1.15;
    letter-spacing:-.04em;
  }
}
