/* Lyrivid Clash Royale editor: Royale Chess's own stylesheet, unchanged so the editor looks the same as there,
   then a few rules for the parts only Lyrivid has (card tiles without art, the "Your art" search, the error page). */
  /* Layout: full-bleed 3D arena behind everything; HUD pinned to top and bottom edges; menus float as sheets. */
  :root {
    --night: #121a35;
    --night-2: #1f2b57;
    --panel: #24346c;
    --panel-2: #1a2551;
    --line: #0b1024;
    --text: #ffffff;
    --muted: #b8c6f2;
    --gold: #ffcb3d;
    --gold-2: #f59e0b;
    --blue: #3f8ff0;
    --blue-2: #2a6fd0;
    --red: #e8483f;
    --red-2: #c3322b;
    --elixir: #e244dc;
    --elixir-2: #9a21b8;
    --good: #5fd068;
    --display: "Lilita One", "Arial Rounded MT Bold", "Arial Black", system-ui, sans-serif;
    --body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
    --outline: 0 2px 0 var(--line), 1.5px 0 0 var(--line), -1.5px 0 0 var(--line), 0 -1.5px 0 var(--line), 1px 1px 0 var(--line), -1px 1px 0 var(--line);
    color-scheme: dark;
  }
  html, body { height: 100%; }
  body {
    margin: 0; overflow: hidden; background: var(--night); color: var(--text);
    font: 700 15px/1.4 var(--body); -webkit-tap-highlight-color: transparent; user-select: none;
  }
  button { font: inherit; color: inherit; cursor: pointer; }
  button:disabled { cursor: default; }
  :focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

  #app {
    position: fixed; inset: 0; overflow: hidden;
    background:
      radial-gradient(120% 80% at 50% 38%, #2b3a72 0%, #1a2450 46%, #10173a 78%, #0b1029 100%);
  }
  #app::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
    background: repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 2px, transparent 2px 22px);
  }
  #stage { position: absolute; inset: 0; }
  #stage canvas { display: block; touch-action: none; }
  #overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
  body.home #overlay, body.home #hud-top, body.home #hud-bottom, body.home #info, body.home #hint { display: none; }
  body.home #stage { visibility: hidden; }

  .chunky { font-family: var(--display); font-weight: 400; letter-spacing: .02em; text-shadow: var(--outline); }

  /* ---------- buttons ---------- */
  .btn {
    --b1: #5aa8ff; --b2: #2f74e0;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 20px; border: 2.5px solid var(--line); border-radius: 13px;
    background: linear-gradient(180deg, var(--b1) 0%, var(--b2) 100%);
    box-shadow: inset 0 3px 0 rgba(255,255,255,.35), inset 0 -5px 0 rgba(0,0,0,.22), 0 4px 0 var(--line);
    font: 400 19px/1 var(--display); letter-spacing: .02em; color: #fff; text-shadow: var(--outline);
    transition: transform .08s ease, filter .15s ease, box-shadow .08s ease;
  }
  .btn:hover:not(:disabled) { filter: brightness(1.07); }
  .btn:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), inset 0 -3px 0 rgba(0,0,0,.22), 0 1px 0 var(--line); }
  .btn:disabled { filter: grayscale(.85) brightness(.7); }
  .btn-gold { --b1: #ffe066; --b2: #f7a90f; }
  .btn-red { --b1: #ff7a6b; --b2: #d6352c; }
  .btn-ghost { --b1: #3a4a86; --b2: #26336a; }
  .btn-xl { min-height: 62px; font-size: 26px; padding: 0 28px; border-radius: 16px; }
  .btn-lg { min-height: 54px; font-size: 22px; }
  .btn-sm { min-height: 36px; font-size: 15px; padding: 0 14px; border-radius: 10px; }
  .icon-btn {
    width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
    border: 2.5px solid var(--line); background: linear-gradient(180deg, #43579d, #2b3a76);
    box-shadow: inset 0 2px 0 rgba(255,255,255,.25), 0 3px 0 var(--line);
  }
  .icon-btn svg { width: 22px; height: 22px; fill: #fff; filter: drop-shadow(0 1.5px 0 var(--line)); }
  .icon-btn:disabled { opacity: .45; }
  .icon-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255,255,255,.25), 0 1px 0 var(--line); }

  /* ---------- HUD top ---------- */
  #hud-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 5;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    background: linear-gradient(to bottom, rgba(9,13,32,.75), rgba(9,13,32,0));
    pointer-events: none;
  }
  #hud-top > * { pointer-events: auto; }
  .opp { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .opp .avatar {
    flex: none; width: 40px; height: 40px; border-radius: 11px; border: 2.5px solid var(--line);
    background: linear-gradient(180deg, #ff7a6b, var(--red-2)); display: grid; place-items: center;
    box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 3px 0 var(--line);
  }
  .opp.blue .avatar { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); }
  .opp .avatar svg { width: 24px; height: 24px; fill: #fff; filter: drop-shadow(0 1.5px 0 var(--line)); }
  .opp .who { min-width: 0; }
  .opp b { display: block; font: 400 18px/1.05 var(--display); text-shadow: var(--outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .opp small { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 800; }
  .mini-drop { width: 11px; height: 11px; border-radius: 50% 0 50% 50%; transform: rotate(-45deg); background: radial-gradient(circle at 35% 35%, #ff9cf6, var(--elixir) 55%, var(--elixir-2)); border: 1.5px solid var(--line); display: inline-block; }
  .score { display: grid; justify-items: center; gap: 4px; }
  .crowns { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 14px; background: rgba(10,15,38,.72); border: 2.5px solid var(--line); }
  .crown { display: flex; align-items: center; gap: 3px; font: 400 22px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .crown svg { width: 24px; height: 24px; filter: drop-shadow(0 1.5px 0 var(--line)); }
  .crown.blue svg { fill: #6db4ff; } .crown.red svg { fill: #ff7a6b; }
  .round { font: 400 13px/1 var(--display); color: var(--muted); text-shadow: var(--outline); letter-spacing: .04em; padding: 0 4px; text-align: center; }
  .round b { color: #fff; font-weight: 400; }
  .badge { font: 400 13px/1 var(--display); padding: 5px 10px; border-radius: 999px; border: 2px solid var(--line); background: linear-gradient(180deg, #ff8af6, var(--elixir-2)); text-shadow: var(--outline); animation: pulse 1.4s ease-in-out infinite; }
  .actions { display: flex; justify-content: flex-end; gap: 8px; }
  .crown.pop { animation: pop .6s ease; }

  /* ---------- HUD bottom ---------- */
  #hud-bottom {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
    padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: linear-gradient(to top, rgba(9,13,32,.9) 30%, rgba(9,13,32,0));
    display: grid; justify-items: center; gap: 6px; pointer-events: none;
  }
  #hud-bottom > * { pointer-events: auto; }
  .turn-label { font: 400 15px/1 var(--display); letter-spacing: .04em; text-shadow: var(--outline); color: var(--muted); }
  .turn-label.mine { color: var(--gold); }
  .dock { display: grid; grid-template-columns: auto auto auto; grid-template-areas: "next hand end" "next elixir end"; gap: 8px 14px; align-items: end; max-width: 100%; }
  .next-card { grid-area: next; display: grid; justify-items: center; gap: 4px; align-self: center; }
  .next-card span { font: 400 12px/1 var(--display); color: var(--muted); text-shadow: var(--outline); }
  .next-card .card { width: 52px; height: 64px; pointer-events: none; }
  .next-card .card .cname { display: none; }
  .next-card .card .cost { width: 18px; height: 18px; font-size: 12px; top: -5px; left: -5px; }
  .hand { grid-area: hand; display: flex; gap: 8px; }
  .end-btn { grid-area: end; align-self: center; min-width: 116px; }
  .elixir-row { grid-area: elixir; display: flex; align-items: center; gap: 8px; }
  .drop {
    flex: none; width: 34px; height: 34px; border-radius: 50% 0 50% 50%; transform: rotate(-45deg);
    background: radial-gradient(circle at 35% 35%, #ffb3f8, var(--elixir) 50%, var(--elixir-2));
    border: 2.5px solid var(--line); display: grid; place-items: center; box-shadow: 0 3px 0 var(--line);
  }
  .drop span { transform: rotate(45deg); font: 400 19px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .elixir-bar { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 4px; border-radius: 10px; background: rgba(8,12,30,.85); border: 2.5px solid var(--line); min-width: 0; }
  .elixir-bar i { height: 14px; border-radius: 4px; background: rgba(255,255,255,.08); transition: background .25s ease; }
  .elixir-bar i.on { background: linear-gradient(180deg, #ff9cf6, var(--elixir) 60%, var(--elixir-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.35); }
  .elixir-bar i.want { background: linear-gradient(180deg, #fff3a6, #ffcb3d); }
  .elixir-inc { font: 400 12px/1 var(--display); color: var(--muted); text-shadow: var(--outline); white-space: nowrap; }

  /* ---------- cards ---------- */
  .card {
    --frame: #a9c6ea;
    position: relative; width: 82px; height: 102px; padding: 0; border-radius: 11px;
    border: 3px solid var(--frame); outline: 2.5px solid var(--line);
    background: radial-gradient(120% 90% at 50% 20%, #5c7fd1 0%, #33499a 60%, #22306b 100%);
    box-shadow: 0 4px 0 var(--line); transition: transform .14s ease, filter .2s ease, box-shadow .14s ease;
    overflow: visible;
  }
  .card.r-rare { --frame: #ffb43a; background: radial-gradient(120% 90% at 50% 20%, #e7a04c 0%, #a85b22 62%, #6e3714 100%); }
  .card.r-epic { --frame: #cf7af7; background: radial-gradient(120% 90% at 50% 20%, #b979e8 0%, #7a3aae 62%, #4c1f73 100%); }
  .card.r-legendary { --frame: #7ff0d8; background: radial-gradient(120% 90% at 50% 20%, #8be8ff 0%, #4a86c9 50%, #7b3fb0 100%); }
  .card img { position: absolute; inset: 2px 2px 16px; width: calc(100% - 4px); height: calc(100% - 18px); object-fit: contain; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
  .card .cname { position: absolute; left: 0; right: 0; bottom: 2px; font: 400 11px/1.1 var(--display); text-shadow: var(--outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; }
  .card .cost {
    position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; font: 400 16px/1 var(--display); text-shadow: var(--outline);
    background: radial-gradient(circle at 35% 30%, #ffb3f8, var(--elixir) 55%, var(--elixir-2)); border: 2.5px solid var(--line);
  }
  .hand .card:hover:not(:disabled) { transform: translateY(-4px); }
  .card.sel { transform: translateY(-14px) !important; box-shadow: 0 0 0 4px var(--gold), 0 10px 0 var(--line); }
  .card.poor { filter: grayscale(.75) brightness(.72); }
  .card:disabled { cursor: default; }
  .hand.locked .card { filter: grayscale(.5) brightness(.65); }
  .card.enter { animation: cardIn .35s ease; }

  /* ---------- info + hint ---------- */
  #info {
    position: absolute; z-index: 4; left: max(16px, env(safe-area-inset-left, 0px)); top: calc(76px + env(safe-area-inset-top, 0px));
    width: 250px; padding: 12px; border-radius: 16px; border: 2.5px solid var(--line);
    background: linear-gradient(180deg, rgba(43,60,120,.96), rgba(28,39,84,.96)); box-shadow: 0 5px 0 rgba(0,0,0,.35);
  }
  #info h3 { margin: 0; font: 400 20px/1.1 var(--display); text-shadow: var(--outline); text-wrap: balance; }
  #info .sub { margin: 2px 0 8px; font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
  #info p { margin: 8px 0 0; font-size: 13.5px; line-height: 1.4; color: #e3e9ff; font-weight: 700; }
  .stats { display: flex; flex-wrap: wrap; gap: 5px; }
  .stat { display: inline-flex; gap: 4px; align-items: baseline; padding: 3px 7px; border-radius: 8px; background: rgba(8,12,30,.55); font-size: 12px; color: var(--muted); font-weight: 800; }
  .stat b { color: #fff; font: 400 14px/1 var(--display); }
  .info-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
  .pattern { display: grid; gap: 2px; flex: none; padding: 3px; border-radius: 8px; background: rgba(8,12,30,.6); }
  .pattern i { width: 12px; height: 12px; border-radius: 3px; background: rgba(255,255,255,.07); position: relative; }
  .pattern i.mv { background: rgba(255,255,255,.75); }
  .pattern i.at { box-shadow: inset 0 0 0 2px #ff5a4f; }
  .pattern i.mv.at { background: rgba(255,255,255,.75); box-shadow: inset 0 0 0 2px #ff5a4f; }
  .pattern i.me { background: var(--gold); }
  .pattern i.ar { background: #ffa53d; }
  .legend { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 800; }
  .legend span { display: flex; align-items: center; gap: 5px; }
  .legend em { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  #hint {
    position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
    padding: 6px 14px; border-radius: 999px; background: rgba(8,12,30,.78); border: 2px solid var(--line);
    font-size: 13.5px; font-weight: 800; color: #e3e9ff; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
  }

  /* ---------- HP labels & floating numbers ---------- */
  .hp { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 3px; will-change: transform; font: 400 13px/1 var(--display); text-shadow: var(--outline); }
  .hp-bar { width: 32px; height: 7px; border-radius: 4px; background: rgba(9,13,32,.8); border: 1.5px solid var(--line); overflow: hidden; }
  .hp-bar i { display: block; height: 100%; background: linear-gradient(180deg, #8fd0ff, #3f8ff0); transition: width .25s ease; }
  .hp-red .hp-bar i { background: linear-gradient(180deg, #ff9a90, #e8483f); }
  .hp-big { font-size: 16px; }
  .hp-big .hp-bar { width: 58px; height: 10px; }
  .hp-tag { display: none; }
  .hp-tag.on { display: inline-block; font: 400 11px/1 var(--display); padding: 2px 4px; border-radius: 6px; border: 1.5px solid var(--line); }
  .hp-tag.t-sleep { background: #6b78a8; }
  .hp-tag.t-ice { background: #7fd6ff; }
  .hp-tag.t-charge { background: var(--gold-2); }
  .float { position: absolute; transform: translate(-50%, -50%); font: 400 22px/1 var(--display); text-shadow: var(--outline); animation: floatUp .95s ease-out forwards; pointer-events: none; white-space: nowrap; }
  .float.dmg { color: #fff; }
  .float.dmg-tower { color: #ffd84a; font-size: 26px; }
  .float.dmg-ice { color: #bdf0ff; }
  .float.wake { color: var(--gold); font-size: 34px; }

  /* ---------- banner + toast ---------- */
  .banner {
    position: absolute; z-index: 8; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.6);
    padding: 12px 34px; border-radius: 16px; border: 3px solid var(--line); opacity: 0; pointer-events: none;
    font: 400 34px/1 var(--display); text-shadow: var(--outline); white-space: nowrap;
    background: linear-gradient(180deg, #5aa8ff, var(--blue-2)); box-shadow: 0 6px 0 var(--line);
  }
  .banner.red { background: linear-gradient(180deg, #ff7a6b, var(--red-2)); }
  .banner.gold { background: linear-gradient(180deg, #ffe066, var(--gold-2)); }
  .banner.pink { background: linear-gradient(180deg, #ff9cf6, var(--elixir-2)); }
  .banner.show { animation: banner 1.25s ease forwards; }
  .toast {
    position: absolute; z-index: 9; left: 50%; top: calc(84px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -10px);
    padding: 9px 16px; border-radius: 12px; background: rgba(8,12,30,.92); border: 2.5px solid var(--line);
    font-weight: 800; opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  .played { position: absolute; z-index: 6; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(76px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 14px; background: rgba(8,12,30,.85); border: 2.5px solid var(--line); animation: slideIn .3s ease; pointer-events: none; }
  .played .card { width: 46px; height: 58px; }
  .played .card .cname { display: none; }
  .played .card .cost { width: 18px; height: 18px; font-size: 12px; top: -5px; left: -5px; }
  .played span { font: 400 14px/1.15 var(--display); text-shadow: var(--outline); }
  .played span small { display: block; font: 800 11px/1 var(--body); color: var(--muted); text-shadow: none; }

  /* ---------- loading screen + home: their own pages, the arena stays out of sight ---------- */
  .page-bg {
    background:
      radial-gradient(60% 50% at 78% 30%, rgba(122,92,255,.30), transparent 70%),
      radial-gradient(55% 45% at 12% 85%, rgba(63,143,240,.28), transparent 70%),
      radial-gradient(120% 90% at 50% 0%, #26357a 0%, #18214f 48%, #0d1333 100%);
  }
  .page-bg::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background: conic-gradient(from 45deg, rgba(255,255,255,.035) 0 25%, transparent 0 50%, rgba(255,255,255,.035) 0 75%, transparent 0) 0 0 / 64px 64px;
    -webkit-mask-image: radial-gradient(90% 70% at 50% 40%, #000 20%, transparent 80%); mask-image: radial-gradient(90% 70% at 50% 40%, #000 20%, transparent 80%);
  }
  .logo { margin: 0; display: grid; line-height: .86; font-family: var(--display); font-weight: 400; }
  .logo span { --o: var(--line); text-shadow: 0 6px 0 var(--o), 3px 0 0 var(--o), -3px 0 0 var(--o), 0 -3px 0 var(--o), 3px 3px 0 var(--o), -3px 3px 0 var(--o), 0 12px 22px rgba(0,0,0,.45); }
  .logo span:first-child { font-size: clamp(56px, 8.4vw, 92px); color: #ffd54a; }
  .logo span:last-child { font-size: clamp(48px, 7.2vw, 78px); color: #fff; padding-left: .55em; }

  #loader { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; transition: opacity .35s ease, visibility .35s; }
  #loader.gone { opacity: 0; visibility: hidden; pointer-events: none; }
  .ld-box { position: relative; width: min(420px, 100%); display: grid; justify-items: center; gap: 22px; text-align: center; }
  .ld-box .logo { justify-items: center; }
  .ld-box .logo span:last-child { padding-left: 0; }
  .ld-bar { width: 100%; height: 22px; padding: 4px; box-sizing: border-box; border-radius: 999px; background: rgba(6,9,24,.75); border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line); }
  .ld-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(180deg, #fff09a, var(--gold) 45%, var(--gold-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.5); transition: width .25s ease; }
  .ld-text { margin: -8px 0 0; font: 400 19px/1.2 var(--display); letter-spacing: .02em; text-shadow: var(--outline); }
  .ld-tip { margin: 0; max-width: 36ch; font-size: 14px; line-height: 1.45; color: var(--muted); min-height: 2.9em; }
  .ld-tip b { color: var(--gold); font-weight: 800; }

  #home { position: absolute; inset: 0; z-index: 10; overflow-y: auto; overflow-x: hidden; }
  .home-wrap { position: relative; min-height: 100%; box-sizing: border-box; max-width: 1180px; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto auto; gap: 26px;
    padding: calc(18px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
  .home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .brand { display: flex; align-items: center; gap: 10px; font: 400 20px/1 var(--display); text-shadow: var(--outline); letter-spacing: .02em; }
  .brand svg { width: 30px; height: 30px; fill: var(--gold); filter: drop-shadow(0 2px 0 var(--line)); }
  .home-top nav { display: flex; gap: 8px; }
  .pill-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 2.5px solid var(--line); background: rgba(8,12,30,.55); font: 400 15px/1 var(--display); letter-spacing: .02em; text-shadow: var(--outline); box-shadow: 0 3px 0 var(--line); }
  .pill-btn:hover { background: rgba(40,56,120,.8); }
  .pill-btn svg { width: 18px; height: 18px; fill: currentColor; }

  .home-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 40px; align-items: center; }
  .hero { display: grid; gap: 18px; justify-items: start; }
  .tagline { margin: 0; font-size: 18px; line-height: 1.5; color: #dfe6ff; max-width: 38ch; font-weight: 700; }
  .play-block { display: grid; gap: 12px; width: min(400px, 100%); margin-top: 6px; }
  .play-btn { min-height: 78px; border-radius: 20px; width: 100%; }
  .play-btn .pb { display: grid; gap: 6px; justify-items: center; }
  .play-btn .pb b { font: 400 34px/1 var(--display); }
  .play-btn .pb small { font: 800 13px/1 var(--body); text-shadow: none; color: #5a3a00; letter-spacing: .02em; }
  .levels { display: grid; grid-template-columns: auto 1fr 1fr 1fr; align-items: center; gap: 6px; padding: 5px; border-radius: 14px; background: rgba(6,9,24,.55); border: 2.5px solid var(--line); }
  .levels > span { padding: 0 8px 0 6px; font: 800 12px/1 var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
  .levels button { min-height: 36px; border-radius: 10px; border: 0; background: transparent; font: 400 16px/1 var(--display); text-shadow: var(--outline); letter-spacing: .02em; }
  .levels button:hover { background: rgba(255,255,255,.07); }
  .levels button[aria-pressed="true"] { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 2px 0 var(--line); }
  .play-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .play-row .btn { min-height: 52px; font-size: 19px; }
  .play-row .btn[hidden] { display: none; }
  .play-row.one { grid-template-columns: 1fr; }
  .link-btn { justify-self: center; border: 0; background: none; padding: 4px 6px; color: var(--muted); font: 800 14px/1 var(--body); text-decoration: underline; text-underline-offset: 3px; }
  .link-btn:hover { color: #fff; }

  .deck-panel { position: relative; display: grid; gap: 14px; padding: 18px; border-radius: 22px; border: 3px solid var(--line); background: linear-gradient(180deg, rgba(52,72,150,.92), rgba(30,42,92,.95)); box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .deck-panel header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .deck-panel h2 { margin: 0; font: 400 24px/1 var(--display); text-shadow: var(--outline); }
  .deck-panel .avg { font-size: 13px; }
  .deck-panel .avg b { font: 400 16px/1 var(--display); color: #fff; text-shadow: var(--outline); }
  .home-deck { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 10px; padding-top: 8px; }
  .home-deck .card { width: 100%; height: auto; aspect-ratio: 4 / 5; pointer-events: none; }
  .home-deck .card .cname { font-size: 10.5px; }
  .home-deck .card .cost { width: 22px; height: 22px; font-size: 13px; top: -7px; left: -7px; }
  .deck-panel .btn { width: 100%; }

  .tools-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
  .tools-head h2 { margin: 0; font: 400 20px/1 var(--display); text-shadow: var(--outline); letter-spacing: .02em; }
  .tools-head span { font-size: 13px; color: var(--muted); font-weight: 800; }
  .tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .tool { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 3px; align-items: center; text-align: left; padding: 14px; border-radius: 18px; border: 2.5px solid var(--line); background: rgba(16,24,58,.78); box-shadow: 0 5px 0 rgba(0,0,0,.35); transition: transform .12s ease, background .15s ease; }
  .tool:hover { background: rgba(36,52,112,.9); transform: translateY(-2px); }
  .ti { grid-row: 1 / 3; width: 48px; height: 48px; border-radius: 14px; border: 2.5px solid var(--line); display: grid; place-items: center; box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 3px 0 var(--line); }
  .ti svg { width: 26px; height: 26px; fill: #fff; filter: drop-shadow(0 1.5px 0 var(--line)); }
  .tool b, .friend-opt b { font: 400 18px/1.05 var(--display); text-shadow: var(--outline); letter-spacing: .02em; }
  .tool small, .friend-opt small { font-size: 13px; line-height: 1.3; color: var(--muted); font-weight: 700; }
  .ti-pink { background: linear-gradient(180deg, #ff8af6, #b02bd0); }
  .ti-blue { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); }
  .ti-green { background: linear-gradient(180deg, #7fe08a, #2e9e48); }
  .ti-gold { background: linear-gradient(180deg, #ffe066, #f7a90f); }
  .home-foot .fineprint { margin: 0; font-size: 11.5px; line-height: 1.45; color: #7f8cbc; font-weight: 700; max-width: 110ch; }

  .intro-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: st; }
  .intro-steps li { display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: rgba(8,12,30,.45); border: 2px solid var(--line); }
  .intro-steps li::before { counter-increment: st; content: counter(st); grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 400 24px/1 var(--display); text-shadow: var(--outline); background: linear-gradient(180deg, #ffe066, #f7a90f); border: 2.5px solid var(--line); box-shadow: 0 3px 0 var(--line); }
  .intro-steps b { font: 400 18px/1.1 var(--display); text-shadow: var(--outline); }
  .intro-steps span { font-size: 14px; line-height: 1.4; color: #e3e9ff; font-weight: 700; }
  @media (min-width: 900px) and (min-height: 720px) {
    .hand .card { width: 94px; height: 117px; }
    .hand .card .cname { font-size: 12px; }
    .next-card .card { width: 58px; height: 72px; }
  }
  /* the tools' screens share the home page's pieces: a title with its coloured tile, Home pill, and panel cards */
  .app-title { display: flex; align-items: center; gap: 10px; font: 400 22px/1 var(--display); text-shadow: var(--outline); letter-spacing: .02em; white-space: nowrap; }
  .app-title .ti { width: 38px; height: 38px; border-radius: 12px; }
  .app-title .ti svg { width: 21px; height: 21px; }
  .pill-btn.back svg { width: 16px; height: 16px; }
  .panel-card { border-radius: 22px; border: 3px solid var(--line); background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .seg-bar { display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: rgba(6,9,24,.72); border: 2.5px solid var(--line); }
  .seg-bar button { min-height: 34px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; font: 400 15px/1 var(--display); letter-spacing: .02em; text-shadow: var(--outline); }
  .seg-bar button:hover { background: rgba(255,255,255,.07); }
  .seg-bar button.on { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 2px 0 var(--line); }
  .friend-list { display: grid; gap: 10px; }
  .friend-opt { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 3px; align-items: center; text-align: left; padding: 12px; border-radius: 16px; border: 2.5px solid var(--line); background: rgba(8,12,30,.45); box-shadow: 0 4px 0 var(--line); }
  .friend-opt:hover:not(:disabled) { background: rgba(60,84,170,.6); }
  .friend-opt:disabled { opacity: .5; }

  /* ---------- sheets ---------- */
  .modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: rgba(6,9,24,.62); }
  .sheet { width: min(580px, 100%); max-height: 100%; display: flex; flex-direction: column; border-radius: 20px; border: 3px solid var(--line); background: linear-gradient(180deg, #2c3e7d, #1d2958); box-shadow: 0 10px 0 rgba(0,0,0,.4); overflow: hidden; animation: sheetIn .22s ease; }
  .sheet.wide { width: min(760px, 100%); }
  .sheet.narrow { width: min(420px, 100%); }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: linear-gradient(180deg, #4a63b8, #34479a); border-bottom: 3px solid var(--line); }
  .sheet-head h2 { margin: 0; font: 400 26px/1 var(--display); text-shadow: var(--outline); }
  .x { width: 38px; height: 38px; border-radius: 11px; border: 2.5px solid var(--line); background: linear-gradient(180deg, #ff7a6b, var(--red-2)); font: 400 22px/1 var(--display); text-shadow: var(--outline); box-shadow: 0 3px 0 var(--line); display: grid; place-items: center; }
  .sheet-body { padding: 16px; overflow-y: auto; display: grid; gap: 16px; }
  .sheet-foot { padding: 14px 16px; border-top: 3px solid var(--line); background: rgba(8,12,30,.35); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
  .sheet-foot .btn { flex: 1 1 auto; }
  .field { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
  .field legend { padding: 0; margin-bottom: 8px; font: 400 16px/1 var(--display); text-shadow: var(--outline); letter-spacing: .03em; display: flex; gap: 8px; align-items: center; }
  .avg { font: 800 12px/1 var(--body); color: var(--muted); text-shadow: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 4px; }
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
  .seg.three { grid-template-columns: repeat(3, 1fr); }
  .seg label { position: relative; }
  .seg input { position: absolute; opacity: 0; pointer-events: none; }
  .seg span { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 2.5px solid var(--line); background: rgba(8,12,30,.45); box-shadow: 0 3px 0 var(--line); cursor: pointer; height: 100%; box-sizing: border-box; }
  .seg span b { font: 400 16px/1.1 var(--display); text-shadow: var(--outline); }
  .seg span small { font-size: 12px; color: var(--muted); font-weight: 800; line-height: 1.25; }
  .seg input:checked + span { background: linear-gradient(180deg, #ffe066, #f7a90f); }
  .seg input:checked + span small { color: #4a2d00; }
  .seg input:focus-visible + span { outline: 3px solid #fff; outline-offset: 2px; }
  .seg input:disabled + span { opacity: .45; cursor: not-allowed; }
  .note { margin: 0; font-size: 13px; color: #ffd9a8; font-weight: 800; }
  .deck-mini { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .deck-mini .card { width: 100%; height: auto; aspect-ratio: 4 / 5; pointer-events: none; }
  .deck-mini .card .cname { display: none; }
  .deck-mini .card .cost { width: 18px; height: 18px; font-size: 11px; top: -5px; left: -5px; border-width: 2px; }
  .deck-mini .card img { inset: 2px; height: calc(100% - 4px); }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .chip { padding: 7px 11px; border-radius: 999px; border: 2px solid var(--line); background: rgba(8,12,30,.5); font-weight: 800; font-size: 13px; }
  .chip.on { background: linear-gradient(180deg, #ffe066, #f7a90f); color: #3d2600; }
  .deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 14px 10px; padding-top: 6px; }
  .deck-grid .card { width: 100%; height: auto; aspect-ratio: 4 / 5; }
  .deck-grid .card.in::after { content: ""; position: absolute; right: -7px; top: -7px; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); background: var(--good) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
  .deck-grid .card:not(.in) { filter: saturate(.55) brightness(.8); }
  .deck-detail { min-height: 110px; padding: 12px; border-radius: 14px; background: rgba(8,12,30,.45); border: 2px solid var(--line); }
  .deck-detail h3 { margin: 0; font: 400 20px/1.1 var(--display); text-shadow: var(--outline); }
  .deck-detail p { margin: 6px 0 0; font-size: 14px; color: #e3e9ff; }
  .deck-detail .sub { margin: 2px 0 8px; font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
  .rules { display: grid; gap: 14px; }
  .rules section { display: grid; gap: 4px; }
  .rules h3 { margin: 0; font: 400 18px/1.15 var(--display); text-shadow: var(--outline); color: var(--gold); }
  .rules p { margin: 0; font-size: 14.5px; line-height: 1.5; color: #e3e9ff; max-width: 65ch; }
  .rules .pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
  .piece { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(8,12,30,.45); }
  .piece b { display: block; font: 400 14px/1.1 var(--display); text-shadow: var(--outline); }
  .piece small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 800; line-height: 1.25; }
  kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 5px; border: 2px solid var(--line); background: #3a4a86; font: 800 12px/1.3 var(--body); text-align: center; }
  .code-box { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
  .code { font: 400 46px/1 var(--display); letter-spacing: .16em; text-shadow: var(--outline); padding: 10px 18px; border-radius: 14px; background: rgba(8,12,30,.6); border: 2.5px solid var(--line); user-select: all; }
  .muted { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.5; }
  .status { display: flex; align-items: center; gap: 10px; font-weight: 800; }
  .spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--gold); animation: spin .8s linear infinite; }
  .code-input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; border: 2.5px solid var(--line); background: rgba(8,12,30,.6); color: #fff; font: 400 34px/1 var(--display); letter-spacing: .2em; text-transform: uppercase; text-align: center; user-select: text; }
  .err { margin: 0; color: #ffb4a8; font-weight: 800; font-size: 14px; }
  .toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(8,12,30,.45); font-weight: 800; cursor: pointer; }
  .toggle input { width: 22px; height: 22px; accent-color: var(--gold); }
  .menu-list { display: grid; gap: 10px; }
  .result { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 6px 0; }
  .result h2 { margin: 0; font: 400 52px/1 var(--display); text-shadow: 0 5px 0 var(--line), 3px 0 0 var(--line), -3px 0 0 var(--line), 0 -3px 0 var(--line); color: var(--gold); }
  .result.lose h2 { color: #c9d3f5; }
  .result .big-crowns { display: flex; align-items: center; gap: 18px; }
  .result .big-crowns .crown { font-size: 40px; }
  .result .big-crowns .crown svg { width: 44px; height: 44px; }

  /* ---------- studio ---------- */
  .btn-pink { --b1: #ff8af6; --b2: #b02bd0; }
  body.studio #hud-top, body.studio #hud-bottom, body.studio #info, body.studio #hint { display: none; }
  #studio { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
  #studio > * { pointer-events: auto; }
  .st-top {
    position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 22px max(16px, env(safe-area-inset-left, 0px));
    background: linear-gradient(to bottom, rgba(13,19,51,.96) 0%, rgba(13,19,51,.82) 60%, rgba(13,19,51,0) 100%); pointer-events: none;
  }
  .st-top > * { pointer-events: auto; }
  .st-tools { flex-wrap: wrap; justify-content: center; margin: 0 auto; }
  .st-actions { display: flex; align-items: center; gap: 8px; }
  .st-panel {
    position: absolute; top: calc(80px + env(safe-area-inset-top, 0px)); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); width: 272px; box-sizing: border-box;
    overflow-y: auto; padding: 16px; display: grid; align-content: start; gap: 0; scrollbar-width: thin;
  }
  .st-left { left: max(14px, env(safe-area-inset-left, 0px)); }
  .st-right { right: max(14px, env(safe-area-inset-right, 0px)); }
  .st-panel section { display: grid; gap: 10px; min-width: 0; padding: 16px 0; border-top: 2px solid rgba(8,12,30,.35); }
  .st-panel section:first-child { padding-top: 0; border-top: 0; }
  .st-panel section:last-child { padding-bottom: 0; }
  .st-panel section:empty { display: none; }
  .st-panel h4 { margin: 0; font: 400 19px/1 var(--display); text-shadow: var(--outline); color: #fff; letter-spacing: .02em; display: flex; align-items: baseline; }
  .st-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 6px; padding-top: 4px; }
  .st-cards .card { width: 100%; height: auto; aspect-ratio: 4 / 5; }
  .st-cards .card .cname { font-size: 9px; }
  .st-cards .card .cost { width: 18px; height: 18px; font-size: 11px; top: -5px; left: -5px; border-width: 2px; }
  .st-cards .card.sel { transform: none !important; box-shadow: 0 0 0 3px var(--gold), 0 4px 0 var(--line); }
  .seg.sm span { padding: 7px 8px; justify-items: center; text-align: center; }
  .seg.sm span b { font-size: 14px; }
  .seg.two { grid-template-columns: repeat(2, 1fr); }
  .seg.four { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .seg.four span { padding: 7px 2px; }
  .st-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; cursor: pointer; line-height: 1.3; color: #e3e9ff; }
  .st-check input { width: 18px; height: 18px; flex: none; accent-color: var(--gold); }
  .st-btns { display: flex; flex-wrap: wrap; gap: 6px; }
  .st-btns .btn { flex: 1 1 auto; }
  .st-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .st-grid2 .btn { min-width: 0; padding: 0 8px; }
  .st-row { display: grid; gap: 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
  .st-row b { color: #fff; }
  .st-row input[type="range"] { width: 100%; accent-color: var(--gold); }
  .st-muted { margin: 0; font-size: 13px; color: #c3cff5; line-height: 1.4; font-weight: 700; }
  .st-selname { display: flex; align-items: center; gap: 8px; font: 400 17px/1.15 var(--display); text-shadow: var(--outline); }
  .st-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid var(--line); }
  .st-dot.blue { background: var(--blue); } .st-dot.red { background: var(--red); }
  .st-shot { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; }
  .st-shot span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .st-shot .chip { padding: 4px 9px; }
  .st-select { width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 12px; border-radius: 12px; border: 2.5px solid var(--line); background: rgba(6,9,24,.62); color: #fff; font: 800 14px/1.2 var(--body); user-select: text; }
  .st-name-row { display: flex; gap: 6px; }
  .st-name-row .btn { flex: none; }
  .st-hint { position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: rgba(13,19,51,.92); border: 2.5px solid var(--line); box-shadow: 0 3px 0 var(--line); font-size: 13.5px; font-weight: 800; color: #e3e9ff; width: max-content; max-width: min(620px, calc(100% - 32px)); text-align: center; box-sizing: border-box; }
  .st-show { position: absolute; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transition: opacity .6s ease; }
  .st-show.idle { opacity: 0; }
  .st-show:hover, .st-show:focus-visible { opacity: 1; }
  body:not(.studio-clean) .st-show { display: none; }
  body.studio-clean .st-top, body.studio-clean .st-panel, body.studio-clean .st-hint, body.studio-clean .toast { display: none; }
  #st-open-left, #st-open-right { display: none; }
  #rec-frame { position: absolute; z-index: 6; pointer-events: none; box-shadow: 0 0 0 200vmax rgba(5,8,20,.74); outline: 2px dashed rgba(255,255,255,.5); }
  body.studio-clean #rec-frame { outline-color: transparent; }
  .tag3d { position: absolute; left: 0; top: 0; pointer-events: none; font: 400 22px/1 var(--display); color: #fff; text-shadow: var(--outline); }
  #overlay.no-hp .hp { display: none; }
  .img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
  .img-cell { padding: 8px; border-radius: 12px; background: rgba(8,12,30,.45); display: grid; gap: 6px; justify-items: center; text-align: center; align-content: start; }
  .img-cell.custom { box-shadow: inset 0 0 0 2px var(--good); }
  .img-cell b { font: 400 14px/1.1 var(--display); text-shadow: var(--outline); }
  .img-pic { width: 100%; height: 104px; display: grid; place-items: center; border-radius: 10px; background: radial-gradient(circle at 50% 70%, rgba(255,255,255,.12), rgba(255,255,255,0) 70%); }
  .img-pic img { width: 100%; height: 100%; object-fit: contain; }
  .img-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .img-size { display: flex; align-items: center; gap: 6px; width: 100%; font-size: 12px; font-weight: 800; color: var(--muted); }
  .img-size input { flex: 1; min-width: 0; accent-color: var(--gold); }
  @media (max-width: 900px) {
    .st-title { display: none; }
    #st-exit span { display: none; }
    #st-open-left, #st-open-right { display: inline-flex; }
    .st-panel { display: none; top: auto; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; max-height: 58vh; }
    .st-panel.open { display: grid; }
    .st-top { flex-wrap: wrap; }
    .st-tools { order: 5; width: 100%; box-sizing: border-box; }
    .st-tools button { padding: 0 7px; font-size: 13px; flex: 1 1 auto; }
  }
  @media (max-width: 600px) {
    .st-tools { flex-wrap: nowrap; gap: 2px; padding: 4px; }
    .st-tools button { min-width: 0; padding: 0 2px; font-size: 12px; }
  }

  /* ---------- real card art ---------- */
  .card.art { border: 0; outline: 0; background: none; box-shadow: none; border-radius: 9px; }
  .card.art img { inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 0 rgba(11,16,36,.85)); }
  .card.art .cname { display: none; }
  .card .cost { z-index: 2; }
  .card.art .cost { top: -7px; left: -7px; }
  .card.art.sel { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255,203,61,.6); }
  .deck-grid .card.art .cname, .st-cards .card.art .cname { display: block; bottom: -22px; font-size: 10.5px; color: #dfe6ff; }
  .deck-grid { gap: 30px 10px; }
  .st-cards { gap: 26px 6px; padding-bottom: 14px; }
  .deck-mini .card.art .cost, .next-card .card.art .cost, .played .card.art .cost { top: -5px; left: -5px; }
  #info p.real, .deck-detail p.real { color: #ffd98a; font-size: 12.5px; }
  .deck-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .seg.five { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .seg.five span { padding: 7px 2px; }
  .st-count { font: 800 12px/1 var(--body); color: var(--muted); text-shadow: none; letter-spacing: 0; margin-left: 6px; }
  .hp-barOnly .hp-num { display: none; }
  /* ---------- studio playback dock + elixir bar ---------- */
  .st-dock {
    position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 20px; border: 3px solid var(--line);
    background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12);
  }
  .st-playbtn { min-width: 112px; min-height: 44px; font-size: 21px; }
  .st-rates { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: rgba(6,9,24,.62); border: 2px solid var(--line); }
  .st-rates button { padding: 6px 9px; border: 0; border-radius: 8px; background: transparent; font: 400 14px/1 var(--display); text-shadow: var(--outline); }
  .st-rates button.on { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3); }
  .st-clock { min-width: 44px; text-align: center; font: 400 18px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  body.studio .st-hint { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  body.studio-clean .st-dock { display: none; }
  .st-elixir { position: absolute; z-index: 6; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(520px, calc(100% - 32px)); display: flex; align-items: center; gap: 8px; pointer-events: none; }
  body.studio:not(.studio-clean) .st-elixir { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); }
  #rec-frame:not([hidden]) ~ .st-elixir { transform: none; }
  .st-elixir-bar { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 4px; border-radius: 9px; background: rgba(28,18,40,.9); border: 2.5px solid var(--line); }
  .st-elixir-bar i { --fill: 0%; height: 13px; border-radius: 3px; background: linear-gradient(90deg, #ff4f9a var(--fill), rgba(255,255,255,.08) var(--fill)); }
  .st-elixir-bar i.on { background: linear-gradient(180deg, #ff8ac0, #f0367f 60%, #b81d5d); box-shadow: inset 0 2px 0 rgba(255,255,255,.35); }
  .st-elixir .drop { background: radial-gradient(circle at 35% 35%, #ffb3d4, #f0367f 50%, #9c1450); }
  @media (max-width: 900px) {
    .st-dock { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); gap: 6px; padding: 5px 8px; }
    .st-playbtn { min-width: 86px; }
    body.studio .st-hint { display: none; }
  }

  /* ---------- video editor ---------- */
  body.editor #hud-top, body.editor #hud-bottom, body.editor #info, body.editor #hint, body.editor #overlay, body.editor #banner { display: none; }
  #editor {
    position: absolute; inset: 0; z-index: 8; display: grid; gap: 14px;
    grid-template-columns: 300px minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top top" "add view insp" "tl tl tl";
    padding: 0 max(14px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  }
  #editor[hidden] { display: none; }
  #editor > :not(.ed-sheet) { position: relative; z-index: 1; } /* over the page's diamond pattern */
  .ed-top {
    grid-area: top; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 0 0;
  }
  .ed-top .ti { width: 38px; height: 38px; border-radius: 12px; flex: none; }
  .ed-top .ti svg { width: 21px; height: 21px; }
  .ed-top .btn svg { width: 18px; height: 18px; fill: #fff; filter: drop-shadow(0 1.5px 0 var(--line)); }
  .ed-name { flex: 0 1 320px; min-width: 0; padding: 7px 10px; border-radius: 10px; border: 2px solid transparent; background: transparent; color: #fff; font: 400 21px/1.1 var(--display); text-shadow: var(--outline); user-select: text; }
  .ed-name:hover { border-color: rgba(255,255,255,.18); }
  .ed-name:focus { outline: none; border-color: var(--gold); background: rgba(8,12,30,.5); }
  .ed-saved { font-size: 12.5px; font-weight: 800; color: var(--muted); white-space: nowrap; }
  .ed-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
  .icon-btn.flip svg { transform: scaleX(-1); }
  .ed-panel { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
  .ed-add { grid-area: add; display: flex; flex-direction: column; overflow: hidden; }
  .ed-tabs { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin: 14px 14px 0; padding: 5px; border-radius: 14px; background: rgba(6,9,24,.72); border: 2.5px solid var(--line); }
  .ed-tabs button { min-height: 32px; padding: 0 2px; border: 0; border-radius: 9px; background: transparent; font: 400 13.5px/1 var(--display); text-shadow: var(--outline); }
  .ed-tabs button:hover { background: rgba(255,255,255,.07); }
  .ed-tabs button.on { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 2px 0 var(--line); }
  .ed-tabbody { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: 14px; display: grid; gap: 10px; align-content: start; }
  .ed-tool { display: grid; gap: 3px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: linear-gradient(180deg, #3a4f98, #2b3c7c); box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 3px 0 var(--line); }
  .ed-tool b { font: 400 16px/1.1 var(--display); text-shadow: var(--outline); }
  .ed-tool small { font-size: 12.5px; color: #d6defa; font-weight: 700; line-height: 1.35; }
  .ed-tool:hover { filter: brightness(1.08); }
  .ed-tool:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 1px 0 var(--line); }
  .ed-h { margin: 8px 0 0; font: 400 18px/1 var(--display); color: #fff; text-shadow: var(--outline); letter-spacing: .02em; }
  .ed-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .ed-grid2 .btn { min-width: 0; padding: 0 8px; }
  .ed-opts { display: grid; gap: 8px; }
  .ed-f { display: grid; gap: 4px; font-size: 12.5px; font-weight: 800; color: var(--muted); min-width: 0; }
  .ed-f.inline { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
  .ed-f b { color: #fff; }
  .ed-f input[type="number"], .ed-f input[type="text"], .ed-f textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: rgba(8,12,30,.6); color: #fff; font: 800 14px/1.3 var(--body); user-select: text; }
  .ed-f textarea { resize: vertical; min-height: 58px; }
  .ed-f input:focus, .ed-f textarea:focus, .st-select:focus { outline: none; border-color: var(--gold); }
  .ed-f small { font-weight: 700; color: var(--muted); }
  .ed-f input[type="range"] { width: 100%; accent-color: var(--gold); }
  .ed-sfx { display: grid; gap: 6px; }
  .ed-sfx-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(8,12,30,.4); }
  .ed-file { position: relative; overflow: hidden; }
  .ed-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
  .ed-view { grid-area: view; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .ed-stagewrap { flex: 1; min-height: 0; align-self: stretch; display: grid; place-items: center; }
  .ed-preview { position: relative; background: #0a0f28; border-radius: 16px; box-shadow: 0 0 0 3px var(--line), 0 8px 0 rgba(0,0,0,.35); overflow: hidden; max-width: 100%; }
  .ed-gl, .ed-comp { position: absolute; inset: 0; }
  .ed-gl canvas { display: block; touch-action: none; cursor: grab; }
  .ed-preview.armed .ed-gl canvas { cursor: crosshair; }
  .ed-comp { width: 100%; height: 100%; pointer-events: none; }
  .ed-busy { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: rgba(8,12,30,.85); font-size: 12.5px; font-weight: 800; }
  .ed-busy[hidden], .ed-armed[hidden], .ed-custom[hidden] { display: none; }
  /* one fixed line under Play for the tip, the placing hint or the camera notice: never over the preview, and the
     preview never changes size when one appears */
  .ed-status { height: 30px; max-width: 100%; display: flex; align-items: center; justify-content: center; margin-top: -4px; }
  .ed-status:has(> .ed-armed:not([hidden]), > .ed-custom:not([hidden])) .ed-tip { display: none; }
  .ed-status > .ed-armed:not([hidden]) ~ .ed-custom { display: none; }
  .ed-armed, .ed-custom { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
  .ed-armed { color: var(--gold); }
  .ed-custom { color: #9fe9ff; }
  .ed-armed span, .ed-custom span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .ed-armed .chip, .ed-custom .chip { flex: none; padding: 4px 10px; }
  .ed-transport { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 8px 14px; border-radius: 20px; max-width: 100%; box-sizing: border-box; }
  .ed-play { min-width: 104px; min-height: 42px; font-size: 19px; }
  .ed-time { font: 400 20px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
  .ed-dur { font: 800 13px/1 var(--body); color: var(--muted); font-variant-numeric: tabular-nums; }
  .ed-tip { margin: 0; font-size: 12.5px; color: var(--muted); font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ed-inspect { grid-area: insp; padding: 16px; display: grid; gap: 12px; align-content: start; }
  .ed-ihead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .ed-ih { margin: 0; font: 400 22px/1.1 var(--display); text-shadow: var(--outline); }
  .ed-track-dot { width: 14px; height: 14px; flex: none; border-radius: 4px; border: 2px solid var(--line); background: var(--clip); }
  .ed-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ed-deck { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
  .ed-deck .st-select { padding: 6px 8px; font-size: 12.5px; }
  .ed-ifoot { padding-top: 10px; border-top: 2px solid rgba(255,255,255,.08); }
  .ed-keys { line-height: 2.1; }
  /* timeline */
  .ed-timeline { grid-area: tl; height: clamp(220px, 32vh, 320px); display: flex; flex-direction: column; overflow: hidden; }
  .ed-tl-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; font-size: 12.5px; font-weight: 800; color: var(--muted); border-bottom: 2.5px solid var(--line); }
  .ed-tl-bar b { font: 400 18px/1 var(--display); color: #fff; text-shadow: var(--outline); letter-spacing: .02em; }
  .ed-tl-bar label { display: flex; align-items: center; gap: 6px; }
  .ed-tl-bar input { width: 120px; accent-color: var(--gold); }
  .ed-tl-help { margin-left: auto; }
  .ed-tl-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; scrollbar-width: thin; overscroll-behavior: contain; background: rgba(8,12,30,.38); }
  .ed-tl-inner { position: relative; min-height: 100%; }
  .ed-ruler { position: sticky; top: 0; z-index: 5; display: flex; height: 24px; background: #1b2557; border-bottom: 2px solid var(--line); cursor: ew-resize; }
  .ed-ruler-name { position: sticky; left: 0; z-index: 2; flex: none; width: 92px; box-sizing: border-box; padding: 5px 8px; background: #1b2557; border-right: 2px solid var(--line); font: 800 11px/14px var(--body); color: var(--muted); font-variant-numeric: tabular-nums; cursor: default; }
  .ed-ruler-ticks { position: relative; flex: none; height: 100%; background-image: linear-gradient(90deg, rgba(255,255,255,.2) 1px, transparent 1px); background-size: var(--pps) 6px; background-repeat: repeat-x; background-position: 0 100%; }
  .ed-ruler-ticks span { position: absolute; top: 3px; padding-left: 4px; border-left: 1px solid rgba(255,255,255,.55); height: 18px; box-sizing: border-box; font: 800 10.5px/12px var(--body); color: #c8d3f7; font-variant-numeric: tabular-nums; }
  .ed-end { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); }
  .ed-track { display: flex; border-bottom: 1px solid rgba(255,255,255,.07); }
  .ed-track-name { position: sticky; left: 0; z-index: 3; flex: none; width: 92px; box-sizing: border-box; padding: 6px 10px; background: #22306b; border-right: 2px solid var(--line); font: 400 14px/1 var(--display); text-shadow: var(--outline); }
  .ed-lanes { position: relative; flex: none; }
  .ed-clip { --clip: #3f86e8; position: absolute; height: 21px; box-sizing: border-box; display: flex; align-items: center; padding: 0 8px; border-radius: 7px; border: 2px solid var(--line); background: var(--clip); box-shadow: inset 0 2px 0 rgba(255,255,255,.28); color: #fff; font: 800 11.5px/1 var(--body); text-shadow: 0 1px 0 rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; cursor: grab; touch-action: none; }
  .ed-clip span { overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
  .ed-clip.point { border-radius: 11px; max-width: 86px; padding: 0 7px; }
  .ed-clip.sel { box-shadow: 0 0 0 2px var(--gold), inset 0 2px 0 rgba(255,255,255,.28); z-index: 2; }
  .ed-clip.dragging { cursor: grabbing; opacity: .9; z-index: 3; }
  .ed-marquee { position: absolute; z-index: 7; border: 2px solid var(--gold); background: rgba(255,203,61,.14); border-radius: 4px; pointer-events: none; }
  .ed-clip.missing { background: repeating-linear-gradient(135deg, #6b6f85 0 6px, #575b70 6px 12px); }
  .ed-clip .rz { position: absolute; right: 0; top: 0; bottom: 0; width: 9px; cursor: ew-resize; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35)); }
  .t-battle { --clip: #3f86e8; } .ed-clip.t-battle.red { --clip: #dd4a42; } .t-cards { --clip: #9353d3; } .t-camera { --clip: #23a08f; }
  .t-text { --clip: #d79a1c; } .t-fx { --clip: #d4508c; } .t-sound { --clip: #4ea85a; }
  .ed-playhead { position: absolute; left: 0; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--gold); z-index: 6; pointer-events: none; }
  .ed-playhead i { position: absolute; top: 0; left: -6px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 10px solid var(--gold); }
  /* the phone-only pieces: on wider screens the sheet is no box at all, so its two panels sit in the grid */
  .ed-sheet { display: contents; }
  .ed-sheet > .ed-panel { position: relative; z-index: 1; }
  .ed-sheet-head, .ed-tools, .ed-m-undo, .ed-time-total, .ed-play svg { display: none; }
  .ed-clock { order: 3; display: flex; align-items: baseline; gap: 4px; }
  .ed-towers { display: grid; gap: 6px; }
  .ed-tw { display: grid; grid-template-columns: minmax(0, 1fr) 64px auto 64px; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 800; color: var(--muted); }
  .ed-tw b { color: #fff; font-weight: 800; }
  .ed-tw .st-check { grid-column: 2 / -1; font-size: 12.5px; }
  .ed-tw input[type="number"] { width: 100%; box-sizing: border-box; padding: 5px 6px; border-radius: 8px; border: 2px solid var(--line); background: rgba(8,12,30,.6); color: #fff; font: 800 13px/1.2 var(--body); user-select: text; }
  .ed-tw input:disabled { opacity: .45; }
  /* imported matches */
  .mt-list { display: grid; gap: 16px; }
  .mt-group { display: grid; gap: 8px; }
  .mt-ghead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .mt-ghead b { font: 400 20px/1.1 var(--display); text-shadow: var(--outline); }
  .mt-ghead small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .mt-ghead .chip { margin-left: auto; }
  .mt-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(8,12,30,.45); }
  .mt-res { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; border: 2px solid var(--line); font: 400 14px/1 var(--display); text-shadow: var(--outline); background: #4b5784; }
  .mt-res b { font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
  .mt-res.win { background: linear-gradient(180deg, #5aa8ff, var(--blue-2)); }
  .mt-res.loss { background: linear-gradient(180deg, #ff7a6b, var(--red-2)); }
  .mt-main { display: grid; gap: 5px; min-width: 0; }
  .mt-main > b { font: 400 16px/1.15 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .mt-main > small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .mt-deck { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; padding: 3px 5px; border-radius: 9px; width: max-content; max-width: 100%; box-sizing: border-box; }
  .mt-deck.blue { background: rgba(63,143,240,.22); }
  .mt-deck.red { background: rgba(232,72,63,.22); }
  .mt-deck img { width: 30px; height: 37px; object-fit: contain; }
  .mt-deck img.evo { filter: drop-shadow(0 0 4px #d56bff); }
  .mt-unknown { font-size: 10.5px; font-weight: 800; color: var(--muted); padding: 2px 4px; }
  .mt-empty { display: grid; gap: 6px; padding: 14px; border-radius: 12px; background: rgba(8,12,30,.45); }
  .mt-empty b { font: 400 18px/1.1 var(--display); text-shadow: var(--outline); }
  @media (max-width: 600px) { .mt-row { grid-template-columns: 64px minmax(0, 1fr); } .mt-row .btn { grid-column: 1 / -1; } }
  /* project list + export */
  .ed-proj-list { display: grid; gap: 8px; }
  .ed-proj { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: rgba(8,12,30,.45); }
  .ed-proj.cur { box-shadow: inset 0 0 0 2px var(--gold); }
  .ed-proj-name { flex: 1 1 180px; min-width: 0; display: grid; gap: 2px; }
  .ed-proj-name b { font: 400 17px/1.15 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .ed-proj-name small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .ed-proj-acts { display: flex; gap: 6px; }
  .ex-summary { margin: 0; font: 400 18px/1.2 var(--display); text-shadow: var(--outline); }
  .ex-bar { height: 16px; border-radius: 999px; border: 2.5px solid var(--line); background: rgba(8,12,30,.6); overflow: hidden; }
  .ex-bar i { display: block; height: 100%; width: 0; background: linear-gradient(180deg, #ffe066, #f7a90f); transition: width .2s ease; }
  .ex-label { margin: 8px 0 0; font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; }
  .ex-video { display: block; width: 100%; max-height: 46vh; border-radius: 10px; border: 2.5px solid var(--line); background: #000; }
  @media (max-width: 1180px) { #editor { grid-template-columns: 260px minmax(0, 1fr) 272px; } .ed-tip { visibility: hidden; } }
  /* ---------- phones: laid out like CapCut ----------
     One screen that never scrolls: the project bar, the preview as big as it fits, the playback row, the timeline with
     its playhead fixed in the middle (swipe the clips under it), and the tool bar along the bottom. A tool opens its
     panel as a sheet over the timeline; a selected clip turns the tool bar into its actions. */
  @media (max-width: 900px) {
    #editor { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
    .ed-top { flex: none; flex-wrap: nowrap; gap: 6px; padding: calc(6px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px)); }
    .ed-top .back { min-width: 0; width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
    .ed-top .back svg { margin: 0; }
    .ed-top .ti, .ed-saved, #ed-undo, #ed-redo, #ed-projects, #ed-art { display: none; }
    .ed-name { flex: 1 1 auto; font-size: 18px; padding: 6px 8px; }
    .ed-top-actions { margin-left: 0; flex: none; }
    #ed-export { min-height: 38px; padding: 0 14px; font-size: 16px; }
    .ed-view { flex: 1 1 auto; min-height: 0; gap: 0; position: relative; padding: 0 10px; }
    .ed-stagewrap { flex: 1 1 auto; min-height: 120px; }
    .ed-preview { border-radius: 12px; box-shadow: 0 0 0 2px var(--line); }
    /* the placing hint or the camera notice floats over the top of the preview; the desktop tip is for mice */
    .ed-status { position: absolute; top: 8px; left: 18px; right: 18px; height: auto; margin: 0; pointer-events: none; z-index: 4; }
    .ed-status .ed-tip { display: none; }
    .ed-armed, .ed-custom { pointer-events: auto; padding: 7px 8px 7px 12px; border-radius: 999px; background: rgba(8,12,30,.88); box-shadow: 0 0 0 2px var(--line); font-size: 13px; }
    .ed-transport { flex: none; display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 8px; width: 100%; padding: 6px 2px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
    .ed-clock { order: 0; grid-column: 1; justify-self: start; }
    .ed-time { min-width: 0; font-size: 16px; text-align: left; }
    .ed-time-total { display: inline; font: 800 12px/1 var(--body); color: var(--muted); font-variant-numeric: tabular-nums; }
    #ed-start { grid-column: 2; width: 38px; height: 38px; }
    .ed-play { grid-column: 3; min-width: 0; width: 52px; height: 52px; min-height: 0; padding: 0; border-radius: 50%; font-size: 0; display: grid; place-items: center; }
    .ed-play svg { display: block; width: 24px; height: 24px; fill: #2a1c00; }
    .ed-play span { display: none; }
    .ed-m-undo { grid-column: 5; justify-self: end; display: flex; gap: 6px; }
    .ed-m-undo .icon-btn { width: 38px; height: 38px; }
    .ed-timeline { flex: none; height: clamp(150px, 27dvh, 230px); border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
    .ed-tl-bar { padding: 5px 10px; gap: 8px; flex-wrap: nowrap; border-bottom-width: 2px; }
    .ed-tl-bar b, .ed-tl-help { display: none; }
    .ed-tl-bar label { margin-left: auto; }
    .ed-tl-bar input { width: 110px; }
    /* the playhead stays in the middle; time 0 starts there, so the track names sit just before it */
    .ed-tl-scroll { overflow-y: auto; touch-action: pan-x pan-y; scrollbar-width: none; }
    .ed-tl-scroll::-webkit-scrollbar { display: none; }
    .ed-ruler { cursor: default; }
    .ed-ruler-name, .ed-track-name { position: static; width: var(--name-w); background: transparent; border-right: 0; color: transparent; }
    .ed-track-name { padding: 0 10px 0 0; display: flex; align-items: center; justify-content: flex-end; color: rgba(255,255,255,.55); font: 800 12px/1 var(--body); text-shadow: none; }
    .ed-clip { height: calc(var(--lane-h) - 3px); border-radius: 8px; font-size: 12.5px; touch-action: pan-x pan-y; }
    .ed-clip.point { border-radius: 13px; }
    .ed-clip.lifted { transform: scale(1.06); box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0,0,0,.45); z-index: 4; }
    .ed-clip .rz { width: 16px; }
    .ed-tools { flex: none; display: block; padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); background: #10173d; border-top: 2px solid var(--line); }
    .ed-tools-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
    .ed-tools-row::-webkit-scrollbar { display: none; }
    .ed-tools-row[hidden] { display: none; }
    .ed-tb { flex: 1 0 64px; display: grid; justify-items: center; gap: 4px; padding: 7px 4px 6px; border: 0; border-radius: 12px; background: transparent; color: #e6ecff; font: 800 11.5px/1 var(--body); }
    .ed-tb svg { width: 24px; height: 24px; fill: currentColor; }
    .ed-tb.on { background: rgba(109,180,255,.18); color: #fff; }
    .ed-tb:active { background: rgba(255,255,255,.1); }
    .ed-tb-back { flex: 0 0 56px; color: var(--muted); }
    .ed-tb-del { color: #ff9a90; }
    /* the sheet: over the timeline and the tool bar, the preview above it stays live (tap the arena to place) */
    .ed-sheet { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: min(62dvh, 560px); padding-bottom: env(safe-area-inset-bottom, 0px); border-radius: 22px 22px 0 0; background: linear-gradient(180deg, #2c3d85, #1d2a63); box-shadow: 0 -2px 0 var(--line), 0 -14px 30px rgba(0,0,0,.45); transform: translateY(calc(100% + 20px)); transition: transform .24s cubic-bezier(.2,.8,.2,1); visibility: hidden; }
    #editor[data-sheet="add"] .ed-sheet, #editor[data-sheet="edit"] .ed-sheet { transform: none; visibility: visible; }
    #editor[data-sheet="add"] .ed-inspect, #editor[data-sheet="edit"] .ed-add, #editor[data-sheet=""] .ed-sheet > .ed-panel { display: none; }
    .ed-sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 8px; position: relative; }
    .ed-sheet-head::before { content: ''; position: absolute; top: 5px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: rgba(255,255,255,.3); }
    .ed-sheet-head b { font: 400 20px/1.1 var(--display); text-shadow: var(--outline); }
    .ed-sheet > .ed-panel { flex: 1 1 auto; min-height: 0; overflow-y: auto; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
    .ed-sheet .ed-tabs { margin: 0 14px; }
    .ed-sheet .ed-tabbody { overflow: visible; padding-bottom: 18px; }
    .ed-sheet .ed-inspect { padding: 4px 16px 18px; }
    .ed-tip { visibility: hidden; }
  }
  @media (max-width: 900px) and (prefers-reduced-motion: reduce) { .ed-sheet { transition: none; } }

  /* ---------- player search ---------- */
  body.players #hud-top, body.players #hud-bottom, body.players #info, body.players #hint, body.players #overlay, body.players #banner { display: none; }
  #players { position: absolute; inset: 0; z-index: 8; overflow-y: auto; }
  #players[hidden] { display: none; }
  .pl-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px)); background: linear-gradient(180deg, rgba(20,28,70,.97) 0%, rgba(20,28,70,.9) 65%, rgba(20,28,70,0) 100%); }
  .pl-title { margin: 0; }
  .pl-main { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: 4px max(16px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .pl-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 18px; background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .pl-form label { font: 400 22px/1 var(--display); color: #fff; text-shadow: var(--outline); letter-spacing: .02em; }
  .pl-row { display: flex; gap: 10px; }
  .pl-row .btn { min-height: 54px; font-size: 21px; padding: 0 24px; }
  .pl-row input { flex: 1; min-width: 0; box-sizing: border-box; min-height: 54px; padding: 10px 16px; border-radius: 14px; border: 2.5px solid var(--line); background: rgba(6,9,24,.62); color: #fff; font: 400 24px/1 var(--display); letter-spacing: .03em; user-select: text; }
  .pl-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 8px; }
  .pl-name { display: grid; gap: 3px; justify-items: start; text-align: left; min-width: 0; padding: 12px 16px; border-radius: 16px; border: 2.5px solid var(--line); background: rgba(16,24,58,.82); box-shadow: 0 4px 0 rgba(0,0,0,.35); color: #fff; cursor: pointer; transition: transform .12s ease, background .15s ease; }
  .pl-name:hover, .pl-name:focus-visible { background: rgba(36,52,112,.92); transform: translateY(-2px); outline: none; }
  .pl-name b { font: 400 18px/1.15 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .pl-name small { color: var(--muted); font-weight: 800; font-size: 12.5px; overflow-wrap: anywhere; }
  .pl-name small em { font-style: normal; color: var(--gold); }
  .pl-name.as-tag { border-style: dashed; background: rgba(8,12,30,.45); }
  .pl-helper { padding: 12px 16px; border-radius: 16px; background: rgba(6,9,24,.55); border: 2.5px solid #5fe0ff; line-height: 1.5; font-size: 14px; color: #e3e9ff; }
  .pl-helper summary { cursor: pointer; font-weight: 800; color: #fff; }
  .pl-helper ol { margin: 8px 0 0; padding-left: 20px; }
  .pl-helper code { font: 700 13px/1.4 ui-monospace, Consolas, monospace; color: #fff; overflow-wrap: anywhere; user-select: text; }
  .pl-link { justify-self: start; max-width: 100%; padding: 0; border: 0; background: none; color: #fff; font: 400 16px/1.15 var(--display); text-shadow: var(--outline); text-align: left; overflow-wrap: anywhere; cursor: pointer; }
  .pl-link:hover, .pl-link:focus-visible { color: var(--gold); text-decoration: underline; outline: none; }
  .pl-rp-status { margin: 0; font-weight: 800; font-size: 13.5px; color: #ffe08a; }
  .pl-rp-status .spinner { margin-right: 8px; }
  .pl-other summary { cursor: pointer; font-weight: 800; color: var(--muted); font-size: 13px; }
  .pl-other[open] { display: grid; gap: 8px; }
  .pl-row input:focus { outline: none; border-color: var(--gold); }
  .pl-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; color: #c3cff5; }
  .pl-recent:empty { display: none; }
  .pl-setup { display: grid; gap: 8px; padding: 16px 18px; border-radius: 18px; background: rgba(6,9,24,.55); border: 2.5px solid #5fe0ff; }
  .pl-setup b { font: 400 18px/1.15 var(--display); text-shadow: var(--outline); }
  .pl-setup p, .pl-setup ol { margin: 0; line-height: 1.5; font-size: 14px; color: #e3e9ff; }
  .pl-setup ol { padding-left: 20px; }
  .pl-setup code { font: 700 13px/1.4 ui-monospace, Consolas, monospace; color: #fff; overflow-wrap: anywhere; }
  .pl-snippet { margin: 0; padding: 10px 12px; border-radius: 10px; background: #0a0f28; border: 2px solid var(--line); font: 700 12.5px/1.45 ui-monospace, Consolas, monospace; color: #dff6ff; overflow-x: auto; user-select: text; }
  .pl-setup .chip { justify-self: start; }
  .pl-profile { display: grid; gap: 14px; padding: 18px; background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .pl-card-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .pl-card-head h2 { margin: 0; font: 400 32px/1 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .pl-card-head small, .pl-trophy small { color: var(--muted); font-weight: 800; font-size: 13px; }
  .pl-trophy { display: grid; justify-items: end; }
  .pl-trophy b { font: 400 34px/1 var(--display); color: var(--gold); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .pl-stats { display: flex; flex-wrap: wrap; gap: 8px; }
  .pl-stats span { display: grid; gap: 3px; padding: 9px 14px; border-radius: 14px; background: rgba(6,9,24,.5); border: 2px solid var(--line); font-size: 12px; font-weight: 800; color: #c3cff5; }
  .pl-stats b { font: 400 19px/1 var(--display); color: #fff; text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .pl-cur { display: grid; gap: 6px; }
  .pl-cur small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .pl-bhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .pl-bhead h3 { margin: 0; font: 400 24px/1 var(--display); text-shadow: var(--outline); letter-spacing: .02em; }
  .pl-bhead small { color: var(--muted); font-weight: 800; font-size: 13px; }
  .pl-filter { margin-left: auto; display: flex; gap: 4px; padding: 4px; border-radius: 13px; background: rgba(6,9,24,.72); border: 2.5px solid var(--line); }
  .pl-filter .chip { border: 0; background: transparent; padding: 7px 14px; font: 400 15px/1 var(--display); text-shadow: var(--outline); border-radius: 9px; color: #fff; }
  .pl-filter .chip.on { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3); color: #fff; }
  .pl-battles { display: grid; gap: 12px; }
  .pl-battle { --edge: #6b7397; display: grid; gap: 10px; padding: 14px 16px 14px 20px; background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); border: 3px solid var(--line); border-radius: 22px; box-shadow: inset 7px 0 0 var(--edge), 0 6px 0 rgba(0,0,0,.35); }
  .pl-battle.win { --edge: var(--blue); }
  .pl-battle.loss { --edge: var(--red); }
  .pl-battle header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .pl-res { font: 400 19px/1 var(--display); text-shadow: var(--outline); }
  .pl-battle.win .pl-res { color: #8fd0ff; }
  .pl-battle.loss .pl-res { color: #ff9a90; }
  .pl-res b { font-weight: 400; color: #fff; font-variant-numeric: tabular-nums; }
  .pl-battle header small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .pl-acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
  .pl-side { display: grid; grid-template-columns: minmax(130px, 190px) auto 1fr; align-items: center; gap: 8px 14px; padding: 10px 12px; border-radius: 14px; }
  .pl-side.blue { background: rgba(63,143,240,.18); }
  .pl-side.red { background: rgba(232,72,63,.18); }
  .pl-who { display: grid; gap: 2px; min-width: 0; }
  .pl-who > b { font: 400 16px/1.15 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .pl-who small { color: var(--muted); font-weight: 800; font-size: 12px; }
  .pl-who small b { font: 800 12px/1 var(--body); text-shadow: none; }
  .pl-who small b.up { color: #7fd889; }
  .pl-who small b.dn { color: #ff9a90; }
  .pl-deck { display: flex; flex-wrap: wrap; gap: 4px; }
  .pl-card { position: relative; width: 38px; height: 47px; display: grid; place-items: center; }
  .pl-card img { width: 100%; height: 100%; object-fit: contain; }
  .pl-card.evo img { filter: drop-shadow(0 0 4px #d56bff); }
  .pl-card i { position: absolute; right: -3px; bottom: -3px; min-width: 16px; padding: 1px 3px; box-sizing: border-box; border-radius: 6px; background: #0b1024; color: #fff; font: 800 10px/1.2 var(--body); font-style: normal; text-align: center; }
  .pl-card.unknown { border-radius: 7px; background: rgba(255,255,255,.08); }
  .pl-card.unknown em { font: 800 8.5px/1.1 var(--body); font-style: normal; color: var(--muted); text-align: center; padding: 2px; }
  .pl-towers { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
  .pl-towers span { padding: 3px 8px; border-radius: 8px; background: rgba(8,12,30,.5); font: 800 12px/1.2 var(--body); font-variant-numeric: tabular-nums; }
  .pl-towers span.down { color: #ff9a90; text-decoration: line-through; opacity: .8; }
  .pl-leak { grid-column: 1 / -1; color: var(--muted); font-weight: 800; font-size: 11.5px; }
  @media (max-width: 760px) {
    .pl-side { grid-template-columns: 1fr; }
    .pl-towers { justify-content: flex-start; }
    .pl-acts { margin-left: 0; width: 100%; }
    .pl-acts .btn { flex: 1 1 auto; }
    .pl-filter { margin-left: 0; }
  }
  @media (max-width: 600px) {
    .pl-form { padding: 16px; }
    .pl-form label { font-size: 19px; }
    .pl-row .btn { padding: 0 14px; font-size: 18px; }
    .pl-row input { padding: 10px 12px; font-size: 20px; }
  }

  /* ---------- replays in player search ---------- */
  .pl-replays { display: grid; gap: 10px; padding: 16px 18px; border-radius: 22px; background: linear-gradient(180deg, rgba(128,46,170,.55), rgba(70,28,110,.6)); border: 3px solid var(--line); box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.1); }
  .pl-replays > div { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .pl-replays b { font: 400 20px/1.1 var(--display); text-shadow: var(--outline); }
  .pl-replays small { color: #d9c8f5; font-weight: 800; font-size: 12.5px; }
  .pl-replays p { margin: 0; font-size: 13.5px; line-height: 1.5; color: #e3e9ff; max-width: 80ch; }
  .pl-replays p b { font: 800 13.5px/1.5 var(--body); text-shadow: none; }
  .pl-replays .ed-file { justify-self: start; }
  .pl-steps { margin: 0; padding-left: 22px; display: grid; gap: 7px; font-size: 13.5px; line-height: 1.55; color: #e3e9ff; max-width: 84ch; }
  .pl-steps b { font: 800 13.5px/1.5 var(--body); text-shadow: none; }
  .pl-steps span { color: var(--gold); font-weight: 800; }
  .pl-steps a { color: #9fd3ff; font-weight: 800; }
  .pl-steps .chip { margin-left: 4px; vertical-align: 1px; }
  .pl-steps a.pl-bm { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--gold); color: #2a1a00; text-decoration: none; cursor: grab; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
  .pl-rp-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .pl-paste { width: 100%; max-width: 520px; height: 64px; box-sizing: border-box; border-radius: 10px; border: 2px dashed var(--gold); background: rgba(0,0,0,.3); color: #fff; font: 12px/1.4 ui-monospace, monospace; padding: 8px 10px; resize: vertical; }
  .pl-paste::placeholder { color: #ffe9a6; font: 800 14px var(--body); }
  .pl-replays.flash { animation: plFlash 1s ease 2; }
  @keyframes plFlash { 50% { box-shadow: 0 0 0 4px var(--gold); } }
  #players.dropping { outline: 4px dashed var(--gold); outline-offset: -10px; }

  /* ---------- watch replay ---------- */
  body.replay #hud-top, body.replay #hud-bottom, body.replay #info, body.replay #hint, body.replay #overlay, body.replay #banner { display: none; }
  #replay { position: absolute; inset: 0; z-index: 8; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px;
    padding: 0 max(14px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); }
  #replay[hidden] { display: none; }
  #replay > * { position: relative; z-index: 1; } /* over the page's diamond pattern */
  .rp-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: calc(12px + env(safe-area-inset-top, 0px)) 0 0; }
  .rp-title { display: grid; gap: 2px; min-width: 0; }
  .rp-title b { font: 400 21px/1.1 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .rp-title small { color: var(--muted); font-weight: 800; font-size: 12.5px; }
  .rp-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; min-height: 0; }
  .rp-stage { min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; }
  .rp-board { position: relative; max-width: 100%; background: #0a0f28; border-radius: 16px; overflow: hidden; box-shadow: 0 0 0 3px var(--line), 0 8px 0 rgba(0,0,0,.35); }
  .rp-gl, .rp-comp { position: absolute; inset: 0; }
  .rp-gl canvas { display: block; touch-action: none; cursor: grab; }
  .rp-comp { width: 100%; height: 100%; pointer-events: none; }
  .rp-clock { position: absolute; top: 10px; right: 10px; display: grid; justify-items: end; padding: 6px 12px; border-radius: 12px; background: rgba(8,12,30,.78); border: 2px solid var(--line); pointer-events: none; }
  .rp-clock small { font: 800 11px/1.2 var(--body); color: var(--muted); }
  .rp-clock b { font: 400 28px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .rp-feed { position: absolute; left: 10px; top: 10px; display: grid; gap: 4px; pointer-events: none; }
  .rp-chip { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; border-radius: 10px; background: rgba(8,12,30,.8); border: 2px solid var(--line); font-weight: 800; font-size: 12.5px; }
  .rp-chip.blue { box-shadow: inset 4px 0 0 var(--blue); } .rp-chip.red { box-shadow: inset 4px 0 0 var(--red); }
  .rp-chip img { width: 24px; height: 30px; object-fit: contain; }
  .rp-chip em { font-style: normal; } .rp-chip small { color: var(--muted); font-variant-numeric: tabular-nums; }
  .rp-result { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: grid; justify-items: center; padding: 8px 18px; border-radius: 14px; background: rgba(8,12,30,.86); border: 2.5px solid var(--line); pointer-events: none; }
  .rp-result[hidden] { display: none; }
  .rp-result small { font: 800 12px/1.2 var(--body); color: var(--muted); }
  .rp-result b { font: 400 28px/1.05 var(--display); text-shadow: var(--outline); }
  .rp-result b.win { color: #8fd0ff; } .rp-result b.loss { color: #ff9a90; }
  .rp-busy { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: rgba(8,12,30,.85); font-size: 12.5px; font-weight: 800; }
  .rp-busy[hidden] { display: none; }
  .rp-sound .rp-snd-off, .snd-btn .rp-snd-off, .rp-sound.off .rp-snd-on, .snd-btn.off .rp-snd-on { display: none; }
  .rp-sound.off .rp-snd-off, .snd-btn.off .rp-snd-off { display: inline; }
  .rp-sound.off, .snd-btn.off { opacity: .6; }
  .rp-side { min-height: 0; overflow-y: auto; padding: 16px; display: grid; align-content: start; gap: 12px; scrollbar-width: thin; background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .rp-player { display: grid; gap: 6px; padding: 12px; border-radius: 16px; }
  .rp-player.blue { background: rgba(63,143,240,.2); } .rp-player.red { background: rgba(232,72,63,.2); }
  .rp-who b { display: block; font: 400 17px/1.15 var(--display); text-shadow: var(--outline); overflow-wrap: anywhere; }
  .rp-who small { color: var(--muted); font-weight: 800; font-size: 12px; }
  .rp-ex { display: flex; align-items: center; gap: 8px; }
  .rp-ex b { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50% 0 50% 50%; rotate: -45deg; background: radial-gradient(circle at 35% 35%, #ffb3f8, var(--elixir) 50%, var(--elixir-2)); border: 2px solid var(--line); font: 400 14px/1 var(--display); text-shadow: var(--outline); }
  .rp-ex span { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 3px; border-radius: 8px; background: rgba(8,12,30,.7); border: 2px solid var(--line); }
  .rp-ex i { --f: 0; height: 10px; border-radius: 3px; background: linear-gradient(90deg, #e244dc calc(var(--f) * 100%), rgba(255,255,255,.08) calc(var(--f) * 100%)); }
  .rp-st { color: var(--muted); font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; }
  .rp-deck { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .rp-card { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 5; }
  .rp-card img { width: 100%; height: 100%; object-fit: contain; }
  .rp-card.evo img { filter: drop-shadow(0 0 4px #d56bff); }
  .rp-card em { font: 800 9px/1.1 var(--body); font-style: normal; color: var(--muted); text-align: center; }
  .rp-card i { position: absolute; right: -2px; top: -4px; padding: 1px 5px; border-radius: 7px; background: #0b1024; font: 800 11px/1.3 var(--body); font-style: normal; }
  .rp-bottom { padding: 12px 16px; display: grid; gap: 8px; background: linear-gradient(180deg, rgba(52,72,150,.95), rgba(30,42,92,.97)); border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.12); }
  .rp-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .rp-play { min-width: 96px; min-height: 40px; font-size: 18px; }
  .rp-speed { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: rgba(6,9,24,.62); border: 2px solid var(--line); }
  .rp-speed button { padding: 6px 9px; border: 0; border-radius: 8px; background: transparent; font: 400 14px/1 var(--display); text-shadow: var(--outline); }
  .rp-speed button.on { background: linear-gradient(180deg, #6db4ff, var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.3); }
  .rp-time { font: 400 18px/1 var(--display); text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
  .rp-cams { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
  .rp-tl { overflow: hidden; }
  .rp-tl-track { position: relative; margin: 0 14px; cursor: ew-resize; touch-action: none; }
  .rp-ruler { position: relative; height: 18px; border-bottom: 1px solid rgba(255,255,255,.18); }
  .rp-ruler span { position: absolute; top: 0; transform: translateX(-50%); font: 800 10.5px/1 var(--body); color: var(--muted); font-variant-numeric: tabular-nums; }
  .rp-row { position: relative; height: 54px; border-radius: 6px; margin-top: 4px; }
  .rp-row.blue { background: rgba(63,143,240,.18); } .rp-row.red { background: rgba(232,72,63,.18); }
  .rp-ic { position: absolute; top: 3px; width: 22px; height: 27px; transform: translateX(-50%); cursor: pointer; opacity: .45; transition: opacity .15s ease; }
  .rp-ic.l2 { top: 24px; }
  .rp-ic.done { opacity: 1; }
  .rp-ic img { width: 100%; height: 100%; object-fit: contain; }
  .rp-ic em { font: 800 11px/27px var(--body); font-style: normal; }
  .rp-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--gold); pointer-events: none; }
  .rp-note { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; }
  @media (max-width: 900px) {
    /* one scrolling column: board, then the controls right under it, then the players. Nothing is squeezed,
       so the board can't spill over the Play and speed buttons. */
    #replay { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
    #replay > *, .rp-body > * { flex-shrink: 0; }
    .rp-body { display: contents; }
    .rp-top { order: 1; }
    .rp-stage { order: 2; height: min(calc(100vw - 24px), 62vh); }
    .rp-bottom { order: 3; }
    .rp-side { order: 4; overflow: visible; }
    .rp-cams { margin-left: 0; }
  }

  /* ---------- motion ---------- */
  @keyframes floatUp { 0% { transform: translate(-50%, -30%) scale(.5); opacity: 0; } 15% { transform: translate(-50%, -70%) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -230%) scale(1); opacity: 0; } }
  @keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } 22% { transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(.96); } }
  @keyframes pulse { 50% { filter: brightness(1.25); } }
  @keyframes pop { 30% { transform: scale(1.5); } }
  @keyframes cardIn { from { transform: translateY(30px) scale(.8); opacity: 0; } }
  @keyframes sheetIn { from { transform: translateY(14px) scale(.97); opacity: 0; } }
  @keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
  .shake { animation: shake .25s ease 2; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  }

  /* ---------- small screens ---------- */
  @media (max-width: 900px) {
    .home-main { grid-template-columns: 1fr; gap: 24px; }
    .hero { justify-items: center; text-align: center; }
    .hero .logo { justify-items: center; }
    .hero .logo span:last-child { padding-left: 0; }
    .play-block { width: min(440px, 100%); }
    .deck-panel { width: min(440px, 100%); box-sizing: border-box; justify-self: center; }
    .tool-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 760px) {
    #info { top: auto; bottom: calc(196px + env(safe-area-inset-bottom, 0px)); width: auto; right: max(16px, env(safe-area-inset-right, 0px)); padding: 10px; }
    #info p { font-size: 13px; }
    #info { max-height: 34vh; overflow-y: auto; }
    #info .legend { display: none; }
    .played { top: calc(110px + env(safe-area-inset-top, 0px)); }
  }
  @media (max-width: 600px) {
    .dock { grid-template-columns: 1fr auto; grid-template-areas: "hand hand" "elixir end"; gap: 8px 10px; width: 100%; }
    .next-card { display: none; }
    .hand { justify-content: center; gap: 6px; }
    .hand .card { width: min(78px, calc((100vw - 56px) / 4)); height: auto; aspect-ratio: 4 / 5; }
    .end-btn { min-width: 0; padding: 0 14px; min-height: 42px; font-size: 17px; }
    .elixir-inc { display: none; }
    #hud-top { grid-template-columns: 1fr auto; }
    #hud-top .score { grid-row: 2; grid-column: 1 / -1; }
    .opp b { font-size: 16px; }
    .icon-btn { width: 38px; height: 38px; }
    .deck-mini { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .banner { font-size: 26px; padding: 10px 22px; }
    .code { font-size: 36px; }
  }

  /* ---------- Lyrivid additions ---------- */
  /* Royale Chess's page host wraps the page in these rules; its sheets and panels rely on them */
  img { max-width: 100%; }
  [hidden] { display: none !important; }
  /* card tiles without art (the public site): the card's initials over its rarity colours */
  .card .cinit { position: absolute; inset: 12px 2px 18px; display: grid; place-items: center; font: 400 24px/1 var(--display); text-shadow: var(--outline); pointer-events: none; }
  .img-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
  .img-ph { font: 400 34px/1 var(--display); color: var(--muted); text-shadow: var(--outline); }
  .ed-fail { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--night); }
  .ed-fail[hidden] { display: none; }
  .ed-fail div { display: grid; justify-items: center; gap: 14px; max-width: 440px; }
  .ed-fail h1 { margin: 0; font: 400 30px/1.1 var(--display); text-shadow: var(--outline); }
  .ed-fail p { margin: 0; color: var(--muted); font-size: 15px; font-weight: 700; }
