/* Rule Zero front end. Colours come from CSS variables set by core.js (palette + dark/light). */
:root { --bg:#12141a; --bar:#171a22; --panel:#1b1e27; --card:#1f232d; --inset:#0c0e12; --line:#2c303b; --text:#ece9e2; --text2:#c9c6bf; --muted:#9aa0ad; --chip:#262a36; --track:#262a36; --onAccent:#17130a; --accent:#b794f4; --sec:#e3b55c; --secBg:#e3b55c29; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font-family: inherit; cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text], input[type=search], input[type=password], textarea, select { font-family: inherit; color: var(--text); background: var(--inset); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 0 14px; font-size: 14px; }
textarea { padding: 12px 14px; min-height: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; margin: 0; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .acc { color: var(--accent); } .bold { font-weight: 700; }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .col { display: flex; flex-direction: column; gap: 8px; } .grow { flex: 1 1 0; min-width: 0; } .gap12 { gap: 12px; } .gap16 { gap: 16px; } .between { justify-content: space-between; }
#app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; position: relative; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--bar); }
.logo { background: none; border: 0; padding: 0 4px; min-height: 40px; color: var(--accent); display: flex; align-items: center; }
nav.menu { display: flex; flex-wrap: wrap; gap: 4px; }
.navbtn { min-height: 40px; padding: 0 16px; border-radius: 10px; border: 0; background: transparent; color: var(--text2); font-size: 14px; font-weight: 600; }
.navbtn.on { background: var(--accent); color: var(--onAccent); }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 14px; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.primary { background: var(--accent); color: var(--onAccent); border-color: transparent; font-weight: 700; }
.btn.outline { border-color: var(--accent); color: var(--accent); }
.btn.sec { border-color: var(--sec); color: var(--sec); }
.btn.danger { border-color: #e0605a; color: #e0605a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 17px; font-weight: 700; font-family: Georgia, serif; font-style: italic; }
.iconbtn.on { background: var(--accent); color: var(--onAccent); }
.chip { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line); background: transparent; font-size: 13px; color: var(--text2); display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--sec); background: var(--secBg); color: var(--sec); }
.chip.small { min-height: 30px; font-size: 12px; padding: 0 10px; color: var(--muted); }
.seg { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); align-items: center; }
.seg .lbl { font-size: 12px; color: var(--muted); padding: 0 8px; }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; font-size: 14px; color: var(--text2); }
.seg button.on { background: var(--accent); color: var(--onAccent); font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--chip); font-size: 12px; }
.tag.green { background: #3fae6a26; color: #3fae6a; } .tag.amber { background: #e3b55c26; color: #c8962e; } .tag.red { background: #e0605a26; color: #e0605a; }
.pip { display: inline-block; border-radius: 50%; background-repeat: no-repeat; background-position: center; background-size: 64%; flex: 0 0 auto; }
.box { border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 14px 16px; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; } .bar > div { height: 100%; border-radius: 3px; background: var(--accent); }
.page { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 18px 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.page.narrow > .inner { max-width: 1000px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; gap: 12px; } .grid.cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } .grid.decks { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tile { text-align: left; padding: 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: row; align-items: center; gap: 16px; min-height: 120px; transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.tiletext { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile b { font-size: 18px; color: var(--accent); } .tile span { font-size: 14px; color: var(--muted); line-height: 1.5; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabbtn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; color: var(--text2); display: inline-flex; align-items: center; gap: 8px; }
.tabbtn.on { border-color: var(--accent); background: var(--panel); color: var(--accent); }
.tabbtn .ok { color: #3fae6a; }
/* filter bar */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 20px; min-height: 44px; border-bottom: 1px solid var(--line); background: var(--bg); }
.filterbar .fbtn { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--text2); font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.filterbar .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--chip); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.fchip { min-height: 32px; padding: 0 10px; border-radius: 16px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.fchip b { font-weight: 400; color: var(--text2); } .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.fpanel { padding: 12px 20px 14px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 12px; max-height: 46%; overflow-y: auto; }
.rule { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 6px 10px; border-radius: 10px; background: var(--card); }
.tierbtn { min-height: 38px; padding: 0 10px; border-radius: 8px; font-size: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.themelist { max-height: 250px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.themerow { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 6px 12px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.themerow.on { background: var(--secBg); }
.check { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.themerow.on .check { background: var(--sec); border-color: var(--sec); color: var(--bg); }
/* build layout */
.buildrow { flex: 1 1 0; display: flex; min-height: 0; min-width: 0; overflow: hidden; }
.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.handle { flex: 0 0 14px; width: 14px; cursor: col-resize; touch-action: none; display: flex; align-items: center; justify-content: center; z-index: 6; }
.handle span { width: 4px; height: 56px; border-radius: 2px; background: var(--line); } .handle:hover span { background: var(--accent); }
.chat { border: 1px solid var(--accent); border-radius: 16px; background: var(--bar); overflow: hidden; margin: 14px 0 14px 16px; }
.chat .head { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: var(--panel); text-align: center; }
.chat .msgs { flex: 1 1 0; min-height: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.msg { max-width: 90%; padding: 10px 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--secBg); border: 1px solid var(--sec); border-radius: 14px 14px 4px 14px; }
.msg.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; }
.chat .input { display: flex; gap: 8px; align-items: center; padding: 8px; border-top: 1px solid var(--line); background: var(--panel); }
.chat .input input { flex: 1 1 0; min-width: 0; border: 0; background: transparent; }
.avatar { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--accent); background: radial-gradient(circle at 50% 40%, #3a2c52, #12141a); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.avatar.talk { animation: breathe 1.1s ease-in-out infinite; }
.suggest { padding: 14px 8px 14px 8px; overflow-y: auto; align-items: stretch; }
.deckpane { border-left: 1px solid var(--line); background: var(--bar); padding: 14px 18px; overflow-y: auto; gap: 14px; position: relative; }
.pilewrap { width: 100%; max-width: 780px; margin: 0 auto; position: relative; padding-bottom: 10px; }
.pilewrap .back1 { position: absolute; left: 14px; right: 14px; top: 10px; bottom: 0; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.pilewrap .back2 { position: absolute; left: 7px; right: 7px; top: 5px; bottom: 5px; border-radius: 16px; background: var(--bar); border: 1px solid var(--line); }
.pilecard { position: relative; display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; border-radius: 16px; border: 2px solid transparent; }
.pilecard .art { flex: 0 0 250px; width: 250px; max-width: 100%; height: auto; align-self: flex-start; aspect-ratio: 488 / 680; border-radius: 12px; border: 3px solid transparent; overflow: hidden; background: #1f2b4a; cursor: pointer; }
.pilecard .art img { display: block; width: 100%; height: 100%; object-fit: fill; border-radius: 9px; }
.grade { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #12141a; border-radius: 10px; }
.grade.big { width: 56px; height: 56px; font-size: 26px; border-radius: 14px; } .grade.sm { min-width: 34px; height: 34px; font-size: 15px; }
.gem { display: inline-block; width: 10px; height: 10px; transform: rotate(45deg); margin-right: 6px; }
.fx { position: absolute; pointer-events: none; }
.oracle { font-size: 13px; line-height: 1.45; padding: 8px 10px; border-radius: 8px; background: var(--inset); color: var(--text2); white-space: pre-wrap; }
.actions { display: flex; gap: 8px; margin-top: auto; }
.actions .btn { min-height: 52px; font-size: 15px; border-radius: 12px; }
.listrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.drawer-bg { position: absolute; inset: 0; background: #0009; z-index: 50; display: flex; justify-content: flex-end; }
.drawer { width: min(720px, 100%); height: 100%; background: var(--bar); border-left: 1px solid var(--accent); overflow-y: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.modal { position: absolute; inset: 0; z-index: 60; background: #000a; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal > div { width: min(560px, 100%); max-height: 90%; overflow-y: auto; background: var(--card); border: 1px solid var(--accent); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.help-card { position: absolute; right: 16px; bottom: 16px; z-index: 40; width: 360px; max-width: calc(100% - 32px); max-height: 70%; overflow-y: auto; padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--accent); box-shadow: 0 10px 40px #0008; display: flex; flex-direction: column; gap: 10px; }
.help-card .n { flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--onAccent); font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
[data-help] { position: relative; }
.banner { position: relative; display: flex; align-items: stretch; min-height: 104px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.banner .tiles { position: absolute; inset: 0; display: flex; gap: 6px; padding: 8px 8px 8px 306px; overflow-x: auto; }
.banner .tile2 { position: relative; flex: 0 0 auto; width: 96px; border-radius: 8px; overflow: hidden; border: 1px solid #e0605a88; background: linear-gradient(160deg, #3a2c52, #1f2b4a); }
.banner .tile2 img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 14%; opacity: .55; }
.banner .tile2 span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(transparent, #000c); }
.banner .tile2 button { position: absolute; right: 2px; top: 2px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: #000a; color: #fff; }
.banner .search { position: relative; z-index: 2; flex: 0 0 296px; padding: 12px; display: flex; flex-direction: column; justify-content: center; gap: 6px; background: linear-gradient(90deg, var(--card) 86%, transparent); }
.setstrip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.settile { flex: 0 0 auto; width: 210px; scroll-snap-align: start; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 72px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.settile.on { border-color: var(--accent); background: var(--panel); } .settile.upcoming { border-style: dashed; } .settile.waiting { opacity: .45; cursor: not-allowed; }
.settile img { width: 34px; height: 34px; object-fit: contain; flex: 0 0 34px; }
.invert-dark img.icon { filter: invert(1); } .light img.icon { filter: none; }
.precon { display: flex; flex-direction: column; width: 168px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; }
.precon img { display: block; width: 100%; height: 168px; object-fit: contain; background: #0d0f14; }
.accordion { border-radius: 14px; background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.accordion > button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 14px; border: 0; background: transparent; text-align: left; }
.thumb { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 8px; background: var(--chip) center / cover; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); }
.rec { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.rec img.cardimg { flex: 0 0 64px; width: 64px; height: auto; aspect-ratio: 488 / 680; border-radius: 6px; display: block; cursor: pointer; }
.cardimg { display: block; border-radius: 8px; aspect-ratio: 488 / 680; width: 100%; background: #1f2b4a; }
.combo { padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.combo .imgs { display: flex; gap: 8px; flex-wrap: wrap; } .combo .imgs img { width: 86px; border-radius: 6px; cursor: pointer; aspect-ratio: 488 / 680; }
.quiz button.ans { min-height: 72px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 15px; line-height: 1.35; }
.spinner { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; } .table td, .table th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes talk { 0%,100% { transform: scaleY(.2); } 50% { transform: scaleY(1); } }
@keyframes breathe { 0%,100% { box-shadow: 0 0 0 0 #b794f433; } 50% { box-shadow: 0 0 16px 4px #b794f466; } }
@keyframes shine { 0% { transform: translateX(-150%) skewX(-20deg); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateX(450%) skewX(-20deg); opacity: 0; } }
@keyframes ring { 0% { transform: translate(-50%,-50%) scale(0); opacity: .95; } 100% { transform: translate(-50%,-50%) scale(5); opacity: 0; } }
@keyframes ember { 0% { transform: translateY(0) scale(1); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-200px) translateX(24px) scale(.2); opacity: 0; } }
@keyframes reveal-common { 0% { transform: perspective(900px) rotateY(-85deg) scale(.82); opacity: 0; box-shadow: 0 0 0 0 #aab0bd; } 35% { transform: perspective(900px) rotateY(10deg) scale(1.05); opacity: 1; box-shadow: 0 0 30px 4px #aab0bd; } 55% { transform: perspective(900px) rotateY(-4deg) scale(1.01); } 75% { transform: perspective(900px) rotateY(1deg) scale(1); } 100% { transform: perspective(900px) rotateY(0) scale(1); box-shadow: 0 0 0 0 transparent; } }
@keyframes reveal-uncommon { 0% { transform: perspective(900px) rotateY(-85deg) scale(.82); opacity: 0; box-shadow: 0 0 0 0 #dfe6f0; } 35% { transform: perspective(900px) rotateY(10deg) scale(1.05); opacity: 1; box-shadow: 0 0 50px 10px #dfe6f0; } 55% { transform: perspective(900px) rotateY(-4deg) scale(1.01); } 75% { transform: perspective(900px) rotateY(1deg) scale(1); } 100% { transform: perspective(900px) rotateY(0) scale(1); box-shadow: 0 0 0 0 transparent; } }
@keyframes reveal-rare { 0% { transform: perspective(900px) rotateY(-85deg) scale(.82); opacity: 0; box-shadow: 0 0 0 0 #f0c24f; } 35% { transform: perspective(900px) rotateY(10deg) scale(1.05); opacity: 1; box-shadow: 0 0 80px 20px #f0c24f; } 55% { transform: perspective(900px) rotateY(-4deg) scale(1.01); } 75% { transform: perspective(900px) rotateY(1deg) scale(1); } 100% { transform: perspective(900px) rotateY(0) scale(1); box-shadow: 0 0 0 0 transparent; } }
@keyframes reveal-mythic { 0% { transform: perspective(900px) rotateY(-85deg) scale(.82); opacity: 0; box-shadow: 0 0 0 0 #d9772b; } 35% { transform: perspective(900px) rotateY(10deg) scale(1.05); opacity: 1; box-shadow: 0 0 120px 32px #d9772b; } 55% { transform: perspective(900px) rotateY(-4deg) scale(1.01); } 75% { transform: perspective(900px) rotateY(1deg) scale(1); } 100% { transform: perspective(900px) rotateY(0) scale(1); box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .pilecard, .fx, .avatar.talk { animation: none !important; } }

.listrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; width: 100%; }
.listrow2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.linkbtn { background: none; border: 0; padding: 4px 0; text-align: left; color: var(--text); font-size: 14px; min-height: 36px; }
.linkbtn:hover { color: var(--accent); }
/* v3 additions */
.drawer > * { flex-shrink: 0; }
.printgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.printcell { display: flex; flex-direction: column; gap: 3px; } .printcell img { width: 100%; height: auto; aspect-ratio: 488 / 680; } .printcell.pick img { cursor: pointer; }
.sym { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 800; vertical-align: -0.2em; margin: 0 1px; font-family: system-ui, sans-serif; line-height: 1; box-shadow: 0 0 0 1px #0004; }
.symrow { display: inline-flex; gap: 2px; align-items: center; }
.oracle .pip, .oracle .sym { vertical-align: -0.28em; }
.hint { display: inline-block; position: relative; } .hint summary { list-style: none; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.hint summary::-webkit-details-marker { display: none; } .hint[open] summary { background: var(--accent); color: var(--onAccent); border-color: transparent; }
.hint > div { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--inset); border: 1px solid var(--line); font-size: 12px; line-height: 1.55; color: var(--text2); font-weight: 400; }
.artthumb { flex: 0 0 auto; display: inline-block; border-radius: 5px; background-repeat: no-repeat; background-color: #1f2b4a; cursor: pointer; border: 1px solid var(--line); }
.btn.rej { border-color: color-mix(in srgb, #e0605a 45%, var(--line)); background: color-mix(in srgb, #e0605a 9%, transparent); color: color-mix(in srgb, #e0605a 80%, var(--text)); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transform: scale(1.6); transform-origin: 50% 0; display: block; }
.avatarbtn { padding: 0; cursor: pointer; flex: 0 0 80px; } .avatarbtn[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--secBg); border-color: var(--sec); }
.tagsrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pilecard .artcol { flex: 0 0 250px; width: 250px; max-width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; align-self: flex-start; }
.pilecard .artcol .art { flex: none; width: 100%; }
.typeline { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.deckrow { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 6px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.deckrow .linkbtn { flex: 1 1 0; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtabs { display: flex; gap: 6px; padding: 8px 20px 0; }
.mini { font-size: 12px; color: var(--muted); }
.gradecell { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; } .table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); } .table td { padding: 6px 8px; border-bottom: 1px solid var(--line); } .table td.r, .table th.r { text-align: right; }
/* v4 */
.page > * { flex-shrink: 0; }
.pip { background-size: 100%; background-color: transparent; border-radius: 50%; }
.symimg { display: inline-block; vertical-align: -0.28em; margin: 0 1px; }
.flipbtn { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; border: 2px solid #fff8; background: color-mix(in srgb, var(--accent) 82%, #000); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px #0008; padding: 0; z-index: 3; }
.flipbtn:hover { background: var(--accent); }
.printbar { display: flex; align-items: center; gap: 6px; width: 100%; } .printbar .btn { min-height: 40px; min-width: 40px; padding: 0; font-size: 20px; line-height: 1; }
.priceline { font-size: 17px; text-align: center; }
.hintblock { display: block; width: 100%; } .hintblock summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.hintblock summary::-webkit-details-marker { display: none; }
.hintblock .q { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.hintblock[open] .q { background: var(--accent); color: var(--onAccent); border-color: transparent; }
.hintbox { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--inset); border: 1px solid var(--line); font-size: 12px; line-height: 1.55; color: var(--text2); font-weight: 400; }
.hint > .hintbox { position: absolute; z-index: 20; left: 0; top: 24px; width: 280px; max-width: 70vw; box-shadow: 0 8px 24px #0006; }
.setstrip, [data-drag] { scrollbar-width: none; cursor: grab; } .setstrip::-webkit-scrollbar, [data-drag]::-webkit-scrollbar { display: none; }
.setstrip.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; } .setstrip.dragging * { pointer-events: none; }
.iconbtn2 { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.iconbtn2[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); } .iconbtn2:hover { color: var(--text); } .iconbtn2.x:hover { color: #e0605a; border-color: #e0605a; }
.sevenbars { display: grid; gap: 8px; }
/* v5 */
.thinking { display: flex; align-items: center; gap: 18px; border-color: var(--accent); }
.orbit { position: relative; width: 64px; height: 64px; flex: 0 0 64px; }
.orbit span { position: absolute; border-radius: 50%; }
.orbit .o1 { inset: 0; border: 2px solid var(--accent); border-right-color: transparent; border-bottom-color: transparent; animation: spin 1.3s linear infinite; }
.orbit .o2 { inset: 9px; border: 2px solid var(--sec); border-left-color: transparent; border-top-color: transparent; animation: spin 1.9s linear infinite reverse; }
.orbit .o3 { inset: 18px; border: 2px solid var(--accent); border-bottom-color: transparent; animation: spin .9s linear infinite; }
.orbit .core { inset: 27px; background: var(--sec); animation: breathe 1.1s ease-in-out infinite; }
.thinkfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--sec)); border-radius: 3px; animation-name: thinkgrow; animation-timing-function: cubic-bezier(.2,.6,.3,1); animation-fill-mode: forwards; }
@keyframes thinkgrow { from { width: 2%; } to { width: 92%; } }
@media (prefers-reduced-motion: reduce) { .orbit span { animation: none !important; } }
.col3 { display: grid; grid-template-columns: minmax(250px, 300px) minmax(260px, 1fr) minmax(300px, 1.2fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .col3 { grid-template-columns: 1fr 1fr; } .col3 > :last-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .col3 { grid-template-columns: 1fr; } }
.benchrow { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; text-align: left; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.benchrow[aria-pressed="true"] { border-color: var(--accent); background: var(--panel); }
.addrow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; min-height: 54px; }
.addrow:hover, .addrow.on { background: var(--secBg); }
.ranktag { font-size: 11px; }
.deckview { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .deckview { grid-template-columns: 1fr; } }
.usagegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }

/* grade badges with a hover/focus explanation */
.grade.tipped { position: relative; cursor: help; }
.grade.tipped::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 8px); z-index: 60; width: 260px; max-width: 70vw; padding: 9px 11px; border-radius: 10px; background: var(--inset); border: 1px solid var(--line); color: var(--text2); font-size: 12px; font-weight: 400; line-height: 1.5; text-align: left; white-space: normal; box-shadow: 0 8px 24px #0006; opacity: 0; pointer-events: none; transition: opacity .12s; }
.grade.tipped:hover::after, .grade.tipped:focus-visible::after { opacity: 1; }
/* deck page: search results float over the card list; card rows show everything */
.searchbox { position: relative; }
.themelist.overlay { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; margin-top: 4px; max-height: 70vh; box-shadow: 0 12px 32px #000a; }
.cardrow { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }

/* home: recent decks with the commander's art fading in from the right */
.pickrow { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 2px; width: 100%; min-height: 84px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; font-size: 16px; }
.pickart { position: absolute; top: 0; right: 0; bottom: 0; width: 75%; background-size: 100% auto; background-position: 50% 31%; background-repeat: no-repeat; -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 85%); mask-image: linear-gradient(to right, transparent 0%, #000 85%); transition: opacity .15s; opacity: .9; }
.pickrow:hover .pickart { opacity: 1; } .pickrow:hover { border-color: var(--accent); }
.pickname, .pickmeta { position: relative; text-shadow: 0 1px 6px var(--panel), 0 0 14px var(--panel); }
.pickmeta { color: var(--text2); font-size: 13px; }

/* fields stand out from the panels */
input[type=text], input[type=search], input[type=password], textarea, select { border-color: color-mix(in srgb, var(--muted) 55%, var(--line)); }

/* ================= phones (up to 700px wide). Tablets and desktops are untouched. ================= */
@media (max-width: 700px) {
  #app { height: 100vh; height: 100dvh; }
  header.top { padding: 6px 12px; gap: 6px 8px; }
  .logo { min-height: 36px; padding: 0; } .logo svg { width: 88px; height: auto; }
  nav.menu { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -4px; }
  nav.menu::-webkit-scrollbar { display: none; }
  .navbtn { flex: 0 0 auto; white-space: nowrap; padding: 0 14px; }
  header.top > .grow { flex: 1 1 0; }
  header.top .btn, header.top .iconbtn { min-height: 38px; font-size: 13px; }
  header.top .btn { padding: 0 10px; }
  .page { padding: 12px 12px 24px; gap: 12px; }
  .filterbar { flex-wrap: nowrap; overflow-x: auto; padding: 4px 12px; scrollbar-width: none; }
  .filterbar::-webkit-scrollbar { display: none; }
  .filterbar > * { flex: 0 0 auto; }
  .fpanel { padding: 10px 12px 12px; max-height: 62vh; max-height: 62dvh; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: 0 0 auto; padding: 0 12px; }
  .tabs, .dtabs { max-width: 100%; }
  /* build: one pane at a time with a tab bar at the bottom */
  .buildrow.mob { flex-direction: column; }
  .buildrow.mob > .handle, .buildrow.mob > .pane { display: none; }
  .buildrow.mob-chat > .chat, .buildrow.mob-cards > .suggest, .buildrow.mob-deck > .deckpane { display: flex; flex: 1 1 0 !important; width: auto !important; min-height: 0; }
  .chat { margin: 8px; } .chat .head { padding: 10px 12px 8px; }
  .suggest { padding: 8px; }
  .deckpane { border-left: 0; padding: 12px; }
  .mobtabs { flex: 0 0 auto; display: flex; border-top: 1px solid var(--line); background: var(--bar); padding-bottom: env(safe-area-inset-bottom); }
  .mobtabs button { flex: 1 1 0; min-height: 52px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; border-top: 3px solid transparent; }
  .mobtabs button.on { color: var(--accent); border-top-color: var(--accent); background: var(--panel); }
  .pilecard { padding: 12px; gap: 12px; }
  .pilecard .art { flex: 0 0 auto; width: min(260px, 72vw); margin: 0 auto; }
  .artcol { align-items: center; width: 100%; }
  .actions .btn { min-height: 54px; }
  .drawer { padding: 14px 14px 28px; }
  .modal { padding: 10px; } .modal > div { padding: 14px; }
  .banner { flex-direction: column; min-height: 0; }
  .banner .tiles { position: relative; inset: auto; padding: 8px; order: 2; }
  .banner .search { flex: 0 0 auto; background: var(--card); }
  .tile { min-height: 0; padding: 14px; }
  .cardrow { gap: 10px; padding: 8px 10px; }
  .grid.decks { grid-template-columns: 1fr; }
  .grid.cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .table { font-size: 13px; } .table td, .table th { padding: 5px 6px; }
  .themelist.overlay { max-height: 60vh; }
  .settile { width: 180px; } .precon { width: 140px; } .precon img { height: 140px; }
  .combo .imgs img { width: 72px; }
  .listrow, .pickrow { padding-left: 12px; padding-right: 12px; }
  .pickart { width: 90%; }
  input[type=text], input[type=search], input[type=password], textarea, select { font-size: 16px; } /* stops iOS zooming into fields */
}
@media (max-width: 700px) { .deckview.sel > :first-child { order: 2; } }
@media (max-width: 700px) {
  .fpanel > * { flex-shrink: 0; }
  [style*="minmax(420px"], [style*="minmax(340px"], [style*="minmax(300px"] { grid-template-columns: 1fr !important; }
  .rule .row { flex-wrap: wrap; }
  .suggest { min-width: 0 !important; }
}
@media (max-width: 700px) {
  .hint { position: static; }
  .hint > .hintbox { position: fixed; left: 12px; right: 12px; top: auto; bottom: 64px; width: auto; max-width: none; z-index: 90; max-height: 50vh; overflow-y: auto; }
}

/* home carousel */
.hero { position: relative; height: 200px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.hero .slide { position: absolute; inset: 0; opacity: 0; transition: opacity .7s ease; pointer-events: none; }
.hero .slide.on { opacity: 1; pointer-events: auto; }
.hero .slideart { position: absolute; inset: 0; background-size: 120% auto; background-position: 50% 31%; background-repeat: no-repeat; }
.hero .slide::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 80%, transparent) 38%, transparent 82%); }
.hero .slidetext { position: absolute; z-index: 2; left: 0; top: 0; bottom: 0; width: min(62%, 460px); padding: 18px 22px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.hero .slidetext h2 { font-size: 24px; color: var(--accent); } .hero .slidetext p { font-size: 15px; line-height: 1.45; color: var(--text2); }
.hero .dots { position: absolute; z-index: 3; right: 12px; bottom: 8px; display: flex; gap: 2px; }
.hero .dots button { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.hero .dots button::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); opacity: .55; }
.hero .dots button[aria-current="true"]::before { background: var(--accent); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .hero .slide { transition: none; } }
@media (max-width: 700px) { .hero { height: 168px; } .hero .slidetext { width: 78%; padding: 12px 16px; } .hero .slidetext h2 { font-size: 19px; } .hero .slidetext p { font-size: 13px; } }
@media (max-width: 700px) { .hero .slideart { background-position-y: 27%; } .hero .slide:first-child .slideart { background-position-y: 0; } }

/* match log */
.matchrow { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.placebadge { flex: 0 0 auto; min-width: 46px; height: 46px; padding: 0 6px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #12141a; }
@media (min-width: 701px) and (max-width: 1100px) { .navbtn { padding: 0 10px; } nav.menu { gap: 2px; } header.top { gap: 8px 8px; } }

/* the deck paste field must be impossible to miss */
.pastezone { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 2px dashed var(--accent); border-radius: 12px; background: var(--panel); }
.pastezone textarea { display: block; width: 100%; height: 240px; min-height: 240px; resize: vertical; background: var(--inset); color: var(--text); border: 1px solid #8a90a0; border-radius: 8px; font-family: ui-monospace, monospace; }
input[type=text], input[type=search], input[type=password], textarea, select { border-color: #6f7685; }
@supports (color: color-mix(in srgb, red 50%, blue)) { input[type=text], input[type=search], input[type=password], textarea, select { border-color: color-mix(in srgb, var(--muted) 55%, var(--line)); } }

/* blog list rows: picture on the left, date top right */
.postrow { flex-wrap: nowrap; align-items: flex-start; text-align: left; gap: 12px; }
.postthumb { flex: 0 0 auto; width: 120px; height: 80px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 700px) { .postthumb { width: 84px; height: 60px; } .postrow { padding: 10px; } }

/* profile picture in the top bar */
.acctbtn { display: inline-flex; align-items: center; gap: 8px; }
.topavatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; border: 1px solid var(--accent); display: block; }
.topavatar.big { width: 44px; height: 44px; }

/* account panel: slides in from the right */
.acct-bg { position: absolute; inset: 0; z-index: 70; background: #0008; display: flex; justify-content: flex-end; }
.acct-panel { width: min(360px, 92vw); height: 100%; overflow-y: auto; background: var(--bar); border-left: 1px solid var(--accent); padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 14px; animation: acctin .22s ease-out; box-shadow: -10px 0 40px #0008; }
.acct-av { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); display: block; }
.acct-av.ph { display: flex; align-items: center; justify-content: center; background: var(--chip); font-size: 36px; font-weight: 800; color: var(--accent); }
@keyframes acctin { from { transform: translateX(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .acct-panel { animation: none; } }

/* page banner under the menu: picture on the left, title and one line, the guide on the right */
header.top { position: relative; z-index: 60; }
.pagehead { position: relative; z-index: 60; display: flex; align-items: center; gap: 20px; height: 108px; overflow: hidden; padding: 16px 24px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 9%, var(--panel)) 0%, var(--bg) 70%); }
.pagehead-art { flex: 0 0 76px; width: 76px; height: 76px; color: var(--accent); opacity: .7; }
.pagehead-art svg { width: 100%; height: 100%; display: block; }
.pagehead-art.photo { opacity: 1; border-radius: 16px; border: 2px solid var(--accent); background-size: cover; background-position: 50% 8%; }
.pagehead-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pagehead-text b { color: var(--accent); font-size: 21px; line-height: 1.2; } .pagehead-text span { color: var(--text2); font-size: 14px; line-height: 1.45; }
.tourcard { position: absolute; z-index: 5; left: 12px; top: 8px; bottom: 8px; width: min(920px, calc(100% - 24px)); display: flex; align-items: center; gap: 14px; padding: 8px 12px; overflow: hidden; border-radius: 14px; border: 1px solid var(--accent); background: var(--card); box-shadow: 0 8px 28px #0007; }
.tc-main { flex: 1 1 auto; min-width: 0; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.tc-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tc-text { font-size: 15.5px; line-height: 1.4; color: var(--text); } .tc-text b { color: var(--accent); }
.tc-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.tourcard.float { position: fixed; left: auto; top: auto; right: 16px; bottom: 16px; z-index: 61; width: min(420px, calc(100vw - 32px)); height: auto; flex-direction: column; align-items: stretch; padding: 10px 14px 12px; }
.tourcard.float .tc-btns { justify-content: flex-end; }
.tour-hl { position: fixed; z-index: 50; pointer-events: none; border-radius: 12px; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(4, 6, 10, .62), 0 0 22px 4px color-mix(in srgb, var(--accent) 55%, transparent); transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease; }
@media (prefers-reduced-motion: reduce) { .tour-hl { transition: none; } }

/* header: logo left, menu centred, then guide, theme and profile on the right */
.hdr-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.iconbtn.glow { animation: iglow 1.6s ease-in-out infinite; border-color: var(--accent); color: var(--accent); }
@keyframes iglow { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .iconbtn.glow { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } }
@media (min-width: 1101px) { header.top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); } header.top .logo { justify-self: start; } nav.menu { justify-self: center; } .hdr-actions { justify-self: end; } }
@media (max-width: 700px) {
  .pagehead { flex-wrap: wrap; align-content: center; height: 144px; padding: 10px 14px; gap: 6px 12px; }
  .pagehead-art { flex-basis: 48px; width: 48px; height: 48px; } .pagehead-text b { font-size: 18px; } .pagehead-text span { font-size: 13px; }
  .tourcard { left: 8px; right: 8px; top: 6px; bottom: 6px; width: auto; padding: 6px 10px; }
  .tourcard { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; }
  .tc-main { display: contents; } .tc-label { grid-column: 1; grid-row: 1; } .tc-btns { grid-column: 2; grid-row: 1; justify-content: flex-end; } .tc-text { grid-column: 1 / -1; grid-row: 2; font-size: 14px; line-height: 1.35; max-height: 100%; overflow-y: auto; }
  .tourcard.float { left: 8px; right: 8px; bottom: 8px; width: auto; }
}

/* colour theme chooser: opens to the left of its button, as a small overlay on the header */
.themewrap { position: relative; display: flex; align-items: center; }
.themebtn { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.themebtn .themedot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.themebtn.open { min-width: 44px; justify-content: center; border-color: var(--accent); color: var(--accent); }
.themex { font-size: 18px; line-height: 1; font-weight: 700; }
.theme-pop { position: absolute; z-index: 70; right: calc(100% + 8px); top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 14px; padding: 2px 10px; border-radius: 14px; border: 1px solid var(--accent); background: var(--bar); box-shadow: -8px 6px 28px #0009; white-space: nowrap; animation: themein .22s ease-out; }
@keyframes themein { from { clip-path: inset(-20px -20px -20px 100%); opacity: .2; } to { clip-path: inset(-20px -20px -20px -20px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .theme-pop { animation: none; } }
@media (max-width: 700px) { .themewrap { position: static; } .theme-pop { position: fixed; right: 8px; left: 8px; top: 58px; transform: none; flex-wrap: wrap; white-space: normal; justify-content: center; padding: 10px 12px; animation: none; } }
/* inside the theme popover the choices need no second frame */
.theme-pop .seg { border: 0; background: transparent; padding: 0; gap: 2px; }

/* home tiles: a symbol that breathes a little, and a lift on hover */
.tileicon { flex: 0 0 64px; width: 64px; height: 64px; color: var(--accent); opacity: .85; animation: tilefloat 6s ease-in-out infinite; animation-delay: calc(var(--n, 0) * -1.1s); transition: opacity .18s ease, transform .18s ease; }
.tileicon svg { width: 100%; height: 100%; display: block; }
.tileicon.photo { border-radius: 16px; border: 2px solid var(--accent); background-size: cover; background-position: 50% 8%; }
@keyframes tilefloat { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(-1.5deg); } }
@media (prefers-reduced-motion: reduce) { .tileicon { animation: none; } .tile, .tileicon { transition: none; } }

/* hover: every clickable thing answers a little, a notch softer than the "selected" look */
@media (hover: hover) {
  .tile:hover { transform: translateY(-3px); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--card)); box-shadow: 0 10px 26px #0006; }
  .tile:hover .tileicon { opacity: 1; animation-duration: 2.4s; transform: scale(1.06); }
  .navbtn:not(.on):hover { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
  .seg button:not(.on):hover { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--text); }
  .tabbtn:not(.on):hover, .chip:not(.on):hover, .fchip:hover, .filterbar .fbtn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
  .btn:not(.primary):not(:disabled):hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
  .btn.primary:not(:disabled):hover { filter: brightness(1.1); }
  .iconbtn:not(.on):hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
  .listrow:hover, .settile:not(.on):not(.waiting):hover, .accordion > button:hover, .themerow:not(.on):hover, .quiz button.ans:hover { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
  .pip:hover { transform: scale(1.08); }
}
.tile .tileicon { color: var(--accent); font-size: inherit; }

/* ===== phone: the card builder ===== */
@media (max-width: 700px) {
  .pagehead { display: none; }
  /* header and filters take less room */
  header.top { padding: 4px 10px; gap: 4px 8px; }
  .navbtn { min-height: 34px; }
  .filterbar .fchip, .filterbar > a, .filterbar > button.linkbtn, .filterbar .clearall { display: none; }
  .filterbar { min-height: 40px; padding: 2px 10px; }
  /* Tamiyo: a one-line header so the conversation gets the room */
  .chat { margin: 6px; }
  .chat .head { flex-direction: row; justify-content: flex-start; text-align: left; gap: 10px; padding: 8px 12px; }
  .chat .head .avatar { width: 40px; height: 40px; flex: 0 0 40px; border-width: 2px; }
  .chat .head .row[aria-hidden="true"], .chat .head > span.small { display: none; }
  .chat .input { padding: 6px; } .chat .input input { min-height: 44px; }
  /* cards: a smaller picture, the three decisions always in reach */
  .suggest { padding: 6px; }
  .pilewrap { padding-bottom: 0; } .pilewrap .back1, .pilewrap .back2 { display: none; }
  .pilecard { padding: 10px; gap: 8px; border-radius: 14px; }
  .pilecard .art { width: min(210px, 56vw); }
  .artcol { gap: 6px; }
  .printbar .btn { min-height: 38px; }
  .pilecard .oracle { font-size: 13px; }
  .pilecard .actions { position: sticky; bottom: 0; z-index: 8; margin: 6px -10px -10px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, color-mix(in srgb, var(--card) 0%, transparent), var(--card) 28%); border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .pilecard .actions .btn { min-height: 56px; font-size: 15px; }
  .view-toggle, .suggest .row.wrap { margin-top: 6px; }
  /* the Deck tab */
  .deckpane { gap: 10px; padding: 10px; }
  .deckpane .cardimg { width: 96px !important; flex-basis: 96px !important; }
  .mobtabs button { min-height: 54px; }
}
@media (max-width: 700px) { .pilecard .artcol { width: 100%; align-items: center; } .pilecard .art { margin: 0 auto; flex: 0 0 auto; } }
@media (max-width: 700px) { .pilecard .artcol { flex: 0 0 100%; width: 100%; } .pilecard .artcol .art { width: min(210px, 56vw); } }

#updatebar { position: fixed; z-index: 200; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 16px; border-radius: 12px; border: 1px solid var(--accent); background: var(--card); box-shadow: 0 8px 30px #000a; font-size: 14px; max-width: calc(100vw - 16px); }

/* phone menu: edge fades and arrows when the menu overflows */
.menuwrap { display: contents; } .menuarrow { display: none; }
@media (max-width: 700px) {
  .menuwrap { display: block; position: relative; order: 3; flex: 0 0 100%; min-width: 0; margin: 0 -4px; }
  .menuwrap nav.menu { order: 0; flex: none; width: 100%; margin: 0; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 var(--fl, 0px), #000 calc(100% - var(--fr, 0px)), transparent 100%); }
  .menuarrow { position: absolute; top: 0; bottom: 0; width: 22px; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; line-height: 1; color: var(--accent); pointer-events: none; opacity: 0; transition: opacity .15s ease; }
  .menuarrow.l { left: 0; } .menuarrow.r { right: 0; }
  .menuwrap.more-l .menuarrow.l, .menuwrap.more-r .menuarrow.r { opacity: 1; }
  .menuwrap.more-r .menuarrow.r { animation: nudge 1.8s ease-in-out infinite; } .menuwrap.more-l .menuarrow.l { animation: nudgel 1.8s ease-in-out infinite; }
}
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
@keyframes nudgel { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }
@media (prefers-reduced-motion: reduce) { .menuarrow { animation: none !important; } }
