:root {
  --bg: #0e1117;
  --panel: #161b24;
  --panel2: #1d2330;
  --line: #262d3b;
  --text: #e8ebf1;
  --muted: #8b94a7;
  --accent: #ffd166;
  --good: #7ed491;
  --bad: #ff6b6b;
  --top: #4cc9f0;
  --right: #f4a261;
  --bottom: #90be6d;
  --left: #c77dff;
  --stone: #2c3240;
  --stone2: #242938;
  --card-bg: #f8f4ea;
  --card-red: #c8323a;
  --card-black: #1c1c22;
  --cell: 56px;
  --wall-tb: 84px;
  --wall-lr: 124px;
  --cols: 6;
  --rows: 6;
  --it: 0; --ir: 0; --ib: 0; --il: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #3a4358; background: #232a3a; }
button.primary { background: var(--accent); color: #1a1400; border-color: transparent; font-weight: 700; }
button.primary:hover { background: #ffdc85; }
button.on { background: #24352a; border-color: var(--good); color: var(--good); }
.lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 900; letter-spacing: .12em; font-size: 18px; }
.brand .tag { font-weight: 500; letter-spacing: .02em; font-size: 11px; color: var(--muted); margin-left: 8px; }
.topstats { display: flex; gap: 18px; }
.tstat { display: flex; flex-direction: column; line-height: 1.1; }
.tstat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.topbtns { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- layout ---------- */
.layout { display: flex; gap: 20px; padding: 16px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.arena-wrap { display: flex; justify-content: center; }

/* ---------- arena ---------- */
.arena {
  position: relative;
  width: calc(var(--cols) * var(--cell) + 2 * var(--wall-lr));
  height: calc(var(--rows) * var(--cell) + 2 * var(--wall-tb));
  background: #0c0f15;
  border-radius: 14px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.grid, .fx {
  position: absolute;
  left: var(--wall-lr);
  top: var(--wall-tb);
  width: calc(var(--cols) * var(--cell));
  height: calc(var(--rows) * var(--cell));
}
.grid { z-index: 1; background: #10131a; }
.fx { z-index: 2; pointer-events: none; }

.cell, .ghost {
  position: absolute;
  left: calc(var(--c) * var(--cell));
  top: calc(var(--r) * var(--cell));
  width: var(--cell);
  height: var(--cell);
  padding: 3px;
}
.cell-inner {
  position: relative; width: 100%; height: 100%; border-radius: 7px;
  background: #171c26; box-shadow: inset 0 0 0 1px #242a37;
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow .12s;
}
.cell.crushed .cell-inner { background: #0e1016; box-shadow: none; }
.cell.empty.open { cursor: pointer; }
.cell.empty.open .cell-inner::after {
  content: attr(data-ghost);
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--cell) * 0.34);
  color: var(--card-black); background: var(--card-bg); border-radius: 7px;
  opacity: 0; transition: opacity .12s; pointer-events: none;
}
.cell.empty.open .cell-inner.ghost-red::after { color: var(--card-red); }
.cell.empty.open:hover .cell-inner::after { opacity: .55; }
.cell.hint1 .cell-inner { box-shadow: inset 0 0 0 2px var(--accent), 0 0 10px rgba(255,209,102,.35); }
.cell.hint2 .cell-inner { box-shadow: inset 0 0 0 3px var(--bad), 0 0 14px rgba(255,107,107,.5); }
.cell.cursor .cell-inner { outline: 2px dashed #fff; outline-offset: -3px; }
.cell.wardable { cursor: pointer; }
.cell.wardable .curse { box-shadow: inset 0 0 0 2px var(--accent), 0 0 16px rgba(255,209,102,.55); animation: none; }
.cell.pop .cell-inner { animation: pop .3s cubic-bezier(.2,1.4,.4,1); }
.cell.shake { animation: shake .45s; }

.card {
  width: 100%; height: 100%; border-radius: 7px;
  background: var(--card-bg); color: var(--card-black);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 4px 5px; font-weight: 800; line-height: 1;
  box-shadow: 0 2px 5px rgba(0,0,0,.45);
}
.card.red { color: var(--card-red); }
.card .rank { font-size: calc(var(--cell) * 0.32); }
.card .suit { font-size: calc(var(--cell) * 0.38); align-self: flex-end; }
.bigcard { width: 88px; height: 122px; --cell: 90px; }
.smallcard { width: 40px; height: 56px; --cell: 42px; }
.placeholder { width: 88px; height: 122px; border-radius: 8px; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }

.curse {
  width: 100%; height: 100%; border-radius: 7px;
  background: radial-gradient(circle at 50% 35%, #55207a, #1d0a2c 72%);
  box-shadow: inset 0 0 0 1px #a86ee8, 0 0 12px rgba(168,110,232,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * 0.5); color: #e9d5ff;
  animation: cursePulse 2.2s ease-in-out infinite;
}
.bigcard.curse { width: 88px; height: 122px; font-size: 36px; }
.smallcard.curse { width: 40px; height: 56px; font-size: 18px; }

.ghost.clear { animation: ghostClear .65s ease-out forwards; }
.ghost.crush { animation: ghostCrush .6s ease-in forwards; }
.ghost.poof { animation: ghostPoof .5s ease-out forwards; }

.pops { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.pop {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 22px; color: var(--accent);
  text-shadow: 0 2px 6px rgba(0,0,0,.85); white-space: nowrap;
  animation: popUp 1.1s ease-out forwards;
}
.pop.big { font-size: 30px; color: #fff; }

/* ---------- walls ---------- */
.wall {
  position: absolute; z-index: 3;
  background: repeating-linear-gradient(135deg, var(--stone) 0 8px, var(--stone2) 8px 16px);
  transition: width .5s cubic-bezier(.2,.9,.3,1), height .5s cubic-bezier(.2,.9,.3,1), top .5s cubic-bezier(.2,.9,.3,1);
}
.wall-top { left: 0; top: 0; width: 100%; height: calc(var(--wall-tb) + var(--it) * var(--cell)); box-shadow: inset 0 -3px 0 var(--top), 0 4px 14px rgba(0,0,0,.55); }
.wall-bottom { left: 0; bottom: 0; width: 100%; height: calc(var(--wall-tb) + var(--ib) * var(--cell)); box-shadow: inset 0 3px 0 var(--bottom), 0 -4px 14px rgba(0,0,0,.55); }
.wall-left, .wall-right {
  top: calc(var(--wall-tb) + var(--it) * var(--cell));
  height: calc((var(--rows) - var(--it) - var(--ib)) * var(--cell));
}
.wall-left { left: 0; width: calc(var(--wall-lr) + var(--il) * var(--cell)); box-shadow: inset -3px 0 0 var(--left), 4px 0 14px rgba(0,0,0,.55); }
.wall-right { right: 0; width: calc(var(--wall-lr) + var(--ir) * var(--cell)); box-shadow: inset 3px 0 0 var(--right), -4px 0 14px rgba(0,0,0,.55); }
.wall.hit { animation: wallHit .5s; }
.wall.cleared .goal { animation: goalClear .6s; }
.wall.expired .goal { animation: goalExpire .6s; }

.goal {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 3px; padding: 6px 10px; border-radius: 8px;
}
.wall-top .goal, .wall-bottom .goal {
  height: calc(var(--wall-tb) - 3px);
  left: calc(var(--wall-lr) + (var(--il) + (var(--cols) - var(--il) - var(--ir)) / 2) * var(--cell));
  transform: translateX(-50%);
  width: max(250px, calc((var(--cols) - var(--il) - var(--ir)) * var(--cell)));
  transition: left .5s cubic-bezier(.2,.9,.3,1), width .5s cubic-bezier(.2,.9,.3,1);
}
.wall-top .goal { bottom: 3px; }
.wall-bottom .goal { top: 3px; }
.wall-left .goal, .wall-right .goal {
  width: calc(var(--wall-lr) - 3px); top: 50%; transform: translateY(-50%); height: max(150px, 100%); padding: 6px 6px;
}
.wall-left .goal { right: 3px; }
.wall-right .goal { left: 3px; }
.goal-side { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.goal-name { font-weight: 800; font-size: 17px; line-height: 1.1; }
.wall-left .goal-name, .wall-right .goal-name { font-size: 14px; }
.wall-top .goal-name { color: var(--top); }
.wall-right .goal-name { color: var(--right); }
.wall-bottom .goal-name { color: var(--bottom); }
.wall-left .goal-name { color: var(--left); }
.goal-desc { font-size: 11.5px; color: #c9cfdb; line-height: 1.25; }
.wall-left .goal-desc, .wall-right .goal-desc { font-size: 10.5px; }
.goal-meta { display: flex; gap: 10px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.goal-meta .pts { color: var(--accent); font-weight: 700; }
.goal-bar { width: 100%; height: 5px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; }
.goal-bar-fill { height: 100%; width: 100%; border-radius: 3px; transition: width .2s linear; }
.wall-top .goal-bar-fill { background: var(--top); }
.wall-right .goal-bar-fill { background: var(--right); }
.wall-bottom .goal-bar-fill { background: var(--bottom); }
.wall-left .goal-bar-fill { background: var(--left); }
.goal.danger .goal-bar-fill { background: var(--bad) !important; }
.goal.danger { animation: danger .7s infinite alternate; }
.goal.none { opacity: .6; }
.arena.narrow .goal-desc { display: none; }
.arena.narrow .goal-name { font-size: 13px; }
.arena.narrow .wall-left .goal-name, .arena.narrow .wall-right .goal-name { font-size: 11.5px; overflow-wrap: anywhere; }

/* ---------- goal popup ---------- */
.goal { cursor: pointer; }
.goal-pop {
  position: absolute; z-index: 6; width: min(320px, calc(100% - 24px));
  background: rgba(18, 22, 31, .97); border: 2px solid var(--accent); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 12px 34px rgba(0,0,0,.65); cursor: pointer;
  animation: toastIn .18s ease-out; text-align: left;
}
.goal-pop.from-top { top: calc(var(--wall-tb) + var(--it) * var(--cell) + 10px); left: 50%; transform: translateX(-50%); }
.goal-pop.from-bottom { bottom: calc(var(--wall-tb) + var(--ib) * var(--cell) + 10px); left: 50%; transform: translateX(-50%); }
.goal-pop.from-left { left: calc(var(--wall-lr) + var(--il) * var(--cell) + 10px); top: 50%; transform: translateY(-50%); }
.goal-pop.from-right { right: calc(var(--wall-lr) + var(--ir) * var(--cell) + 10px); top: 50%; transform: translateY(-50%); }
.goal-pop.centered { left: 50% !important; right: auto !important; top: 50% !important; bottom: auto !important; transform: translate(-50%, -50%) !important; }
.goal-pop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.goal-pop-name { font-weight: 800; font-size: 16px; }
.goal-pop-meta { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.goal-pop-body { font-size: 13px; line-height: 1.4; }
.goal-pop-notes { margin: 6px 0 0; padding-left: 16px; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.goal-pop-notes:empty { display: none; }
.goal-pop-hint { margin-top: 6px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: right; }

/* ---------- goal reference list (rules) ---------- */
.help-body h4 { margin: 12px 0 4px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.goal-list { margin: 0; }
.goal-list dt { font-weight: 700; margin-top: 8px; }
.goal-list dt .pts { color: var(--accent); font-weight: 700; font-size: 12px; margin-left: 6px; }
.goal-list dt .offtag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }
.goal-list dd { margin: 2px 0 0; color: #c9cfdb; font-size: 13px; line-height: 1.45; }
.goal-list dt.off, .goal-list dd.off { opacity: .5; }

/* ---------- hud ---------- */
.hud {
  width: 300px; flex: 0 0 auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.hand { display: flex; gap: 16px; align-items: flex-start; }
.current { margin-top: 6px; }
.upcoming { display: flex; gap: 6px; margin-top: 6px; min-height: 56px; }
.hint-text { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.3; }
.mini-bar { height: 5px; background: rgba(0,0,0,.4); border-radius: 3px; overflow: hidden; margin-top: 6px; width: 88px; }
.mini-bar .fill { height: 100%; background: var(--bad); width: 100%; transition: width .15s linear; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 9px; background: var(--panel2); border-radius: 8px; min-width: 0; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat.wide { grid-column: 1 / -1; }
.stat.warn b { color: var(--bad); }
.stat.seed b { font-size: 12px; font-family: ui-monospace, monospace; cursor: pointer; }
.log { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); max-height: 170px; overflow: auto; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.log li.good { color: var(--good); }
.log li.bad { color: var(--bad); }
.log li.great { color: var(--accent); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,8,14,.74); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(100%, 940px); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-box.small { width: min(100%, 540px); padding: 22px; overflow: auto; display: block; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { overflow: auto; padding: 14px 18px; }
.modal-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.modal-box.small h2 { margin: 0 0 6px; font-size: 24px; }
.modal-box.small .reason { color: var(--muted); margin: 0 0 12px; }
.over-score { font-size: 40px; font-weight: 900; color: var(--accent); line-height: 1; margin: 6px 0 4px; }
.over-best { color: var(--good); font-weight: 700; margin-bottom: 10px; }
.over-stats { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; }
.over-stats td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.over-stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.over-goals { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 8px 0 12px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.help-body h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
.help-body ul { margin: 0; padding-left: 18px; line-height: 1.5; }
.help-body p { line-height: 1.5; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, monospace; font-size: 12px; }

/* ---------- settings form ---------- */
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 14px; padding: 8px 14px 10px; min-width: 0; }
legend { padding: 0 6px; font-weight: 700; color: var(--accent); }
.setting { display: grid; grid-template-columns: 1fr minmax(180px, 280px); gap: 4px 14px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.setting:last-child { border-bottom: 0; }
.setting[hidden] { display: none; }
.setting label { font-size: 14px; }
.setting .ctl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.setting .ctl input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.setting .ctl input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.setting .ctl .val { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.setting .ctl select, .setting .ctl input[type=text], .setting .ctl input[type=number], .simrow input, .simrow select {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit;
}
.setting .help { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.presets select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; }
.presets .note { font-size: 12px; color: var(--muted); flex-basis: 100%; }
.help-p { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
table.goals { width: 100%; border-collapse: collapse; font-size: 13px; }
table.goals th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px; }
table.goals td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.goals tr.cat td { color: var(--accent); font-weight: 700; padding-top: 12px; border-top: 0; }
table.goals .name { font-weight: 700; white-space: nowrap; }
table.goals .desc { color: #c9cfdb; }
table.goals input.pts { width: 72px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; }
table.goals input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.goal-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.goal-tools button { padding: 4px 9px; font-size: 12px; }
.simrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 8px; }
.simrow label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.simrow input { width: 90px; }
.sim-progress { font-size: 13px; color: var(--muted); margin: 6px 0; }
table.sim { border-collapse: collapse; font-size: 13px; margin: 8px 0; width: 100%; }
table.sim th, table.sim td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.sim th:first-child, table.sim td:first-child { text-align: left; }
table.sim th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.sim-wrap { overflow-x: auto; }
textarea.json { width: 100%; min-height: 130px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font: 12px ui-monospace, monospace; padding: 8px; }
.btnrow.tight { margin-top: 8px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; align-items: center; width: max-content; max-width: 94vw; }
.toast { background: rgba(20,24,33,.96); border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: toastIn .2s ease-out; text-align: center; }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }
.toast.great { border-color: var(--accent); color: var(--accent); }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(.5); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px) rotate(-3deg); } 40% { transform: translateX(5px) rotate(3deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes cursePulse { 0%, 100% { box-shadow: inset 0 0 0 1px #a86ee8, 0 0 8px rgba(168,110,232,.25); } 50% { box-shadow: inset 0 0 0 1px #c9a0f5, 0 0 18px rgba(168,110,232,.6); } }
@keyframes ghostClear { 0% { transform: scale(1); filter: brightness(1.8); opacity: 1; } 60% { transform: scale(1.25); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes ghostCrush { to { transform: scale(.4) rotate(12deg); opacity: 0; } }
@keyframes ghostPoof { to { transform: scale(1.6); opacity: 0; filter: blur(3px); } }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -170%) scale(1); } }
@keyframes wallHit { 0% { filter: brightness(1.8); } 100% { filter: none; } }
@keyframes goalClear { 0% { background: rgba(126,212,145,.45); transform: translateX(-50%) scale(1.06); } 100% { background: transparent; } }
@keyframes goalExpire { 0% { background: rgba(255,107,107,.45); } 100% { background: transparent; } }
@keyframes danger { from { background: transparent; } to { background: rgba(255,107,107,.18); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wall-left.cleared .goal, .wall-right.cleared .goal { animation-name: goalClearSide; }
@keyframes goalClearSide { 0% { background: rgba(126,212,145,.45); } 100% { background: transparent; } }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { flex-direction: column; align-items: center; }
  .hud { width: min(100%, 560px); }
  .topbtns { margin-left: 0; }
}
@media (max-width: 520px) {
  .topbar { padding: 8px 10px; gap: 10px; }
  .layout { padding: 8px; gap: 12px; }
  .setting { grid-template-columns: 1fr; }
  .setting .ctl { justify-content: flex-start; }
  .brand { font-size: 15px; }
}
