@font-face {
  font-family: "Tiny5";
  src: url("/fonts/tiny5-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #111;
  --paper: #fff;
  --bg: #e4e4e4;
  --gray-1: #555;
  --gray-2: #aaa;
  --accent: #ee7942;
  --accent-press: #d9662f;
  --line: 3px;
  --gap: 12px;
  --font: "Tiny5", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.35;
  font-synthesis: none;
}
b, strong, h1, h2, h3 { font-weight: 400; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
[hidden] { display: none !important; }
a { color: inherit; }

/* The "device": a light-gray screen with a dark frame around it. */
.shell {
  max-width: 720px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  border-left: 6px solid #2a2a2a;
  border-right: 6px solid #2a2a2a;
  padding: var(--gap);
  padding-bottom: calc(var(--gap) * 3 + env(safe-area-inset-bottom));
}
@media (min-width: 900px) {
  .shell { max-width: 1040px; }
}
@media (max-width: 480px) {
  .shell { border: 0; padding: 10px; }
  body { font-size: 17px; }
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 22px;
}
.brand { text-decoration: none; }
.coins { white-space: nowrap; }
.coins::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 6px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--paper) inset;
  vertical-align: -1px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: var(--gap) 0;
  flex-wrap: wrap;
}
.tabs a {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: var(--line) solid var(--ink);
  background: var(--paper);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.tabs .push { margin-left: auto; }
.tabs .tabbtn { min-height: 0; padding: 6px 12px; flex: 0 0 auto; }

main:focus { outline: none; }

/* Panels: white boxes with chunky square borders. */
.panel {
  background: var(--paper);
  border: var(--line) solid var(--ink);
  padding: 14px 16px;
  margin-bottom: var(--gap);
}
.panel h1, .panel h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.2; }
.panel p { margin: 0 0 10px; }
.panel p:last-child { margin-bottom: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); flex-wrap: wrap; }
.muted { color: var(--gray-1); }
.small { font-size: 15px; }

.divider { border: 0; border-top: 4px dashed var(--ink); margin: 16px 0; }

/* Forms */
label { display: block; margin-bottom: 12px; }
label > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: var(--line) solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

/* Buttons */
.btn {
  display: inline-block;
  font: inherit;
  padding: 10px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  min-height: 46px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translate(1px, 1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-width: 4px;
  width: 100%;
  font-size: 20px;
}
.btn.primary:active:not(:disabled) { background: var(--accent-press); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.block { width: 100%; }

.error {
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  margin-bottom: 12px;
}
.error::before { content: "! "; color: var(--accent); }

.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: clamp(16px, 5.2vw, 26px);
  letter-spacing: 1px;
  white-space: nowrap;
  text-align: center;
  padding: 16px 8px;
  border: var(--line) dashed var(--ink);
  background: var(--bg);
  margin: 12px 0;
  user-select: all;
}

.form-narrow { max-width: 460px; margin: 0 auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border: var(--line) solid var(--paper);
  outline: var(--line) solid var(--ink);
  padding: 10px 16px;
  z-index: 50;
  max-width: calc(100vw - 32px);
}

@media (max-width: 480px) {
  .tabs { gap: 6px; }
  .tabs a, .tabs .tabbtn { padding: 5px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Paintings ---------- */
canvas.art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: var(--paper);
}
.center { text-align: center; }

.titlebar.sub { font-size: 18px; padding: 6px 12px; margin-bottom: 0; }

.claim { border-color: var(--ink); }
.claim .btn.primary { width: auto; font-size: 18px; }

/* Gallery */
.filters { display: grid; gap: 10px; }
.filters .row { flex-wrap: nowrap; }
.filters select { flex: 1; min-width: 0; }
.filters .check { margin: 0; white-space: nowrap; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card-body { padding: 6px 8px 8px; }
  .card-title { font-size: 16px; }
  .filters .row { flex-wrap: wrap; }
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  text-decoration: none;
  min-width: 0;
}
.card:hover .card-title { text-decoration: underline; }
.card-art { border-bottom: var(--line) solid var(--ink); }
.card-body { padding: 8px 10px 10px; display: grid; gap: 2px; min-width: 0; }
.card-body > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-weight: 700; font-size: 18px; }
.price { margin-top: 6px; font-weight: 700; }
.price::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 6px;
  background: var(--accent);
  border: 2px solid var(--ink);
  vertical-align: -1px;
}
.price.off { font-weight: 400; color: var(--gray-1); }
.price.off::before { background: var(--gray-2); }
.price.auction::before { background: var(--paper); box-shadow: inset 0 0 0 2px var(--accent); }
.card-foot .price.auction { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Auctions */
.auction-panel { border-color: var(--ink); display: grid; gap: 6px; }
.auction-head { flex-wrap: wrap; gap: 6px 12px; }

.countdown { font-weight: 700; font-variant-numeric: tabular-nums; }
.countdown.soon { background: var(--accent); color: var(--ink); padding: 0 4px; }
.leading { border-color: var(--accent); }

/* Painting page */
.painting-page { max-width: 680px; margin: 0 auto; }
.art-panel canvas.art { margin-top: 8px; }
.art-head { flex-wrap: nowrap; align-items: flex-start; }
.art-head > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.panel.line { padding: 10px 16px; }

/* Studio */
.studio { max-width: 680px; margin: 0 auto; }
.canvas-frame {
  border: var(--line) solid var(--ink);
  border-top: 0;
  background: var(--paper);
  padding: 8px;
}
.studio-canvas {
  touch-action: none;
  cursor: crosshair;
  outline: 1px solid var(--gray-2);
  -webkit-user-select: none;
  user-select: none;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: var(--gap);
}
.tool-group { display: flex; gap: 6px; }
.btn.tool { min-height: 44px; min-width: 44px; padding: 6px 10px; }
.btn.tool[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.dot { display: inline-block; background: currentColor; vertical-align: middle; }
.dot.s { width: 6px; height: 6px; }
.dot.l { width: 14px; height: 14px; }
.dot.xl { width: 24px; height: 24px; }
.auction-toggle { margin-bottom: 4px; }
.swatch {
  width: 44px; height: 44px;
  border: var(--line) solid var(--ink);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
}
.swatch.shade-0 { background: #fff; }
.swatch.shade-1 { background: #aaa; }
.swatch.shade-2 { background: #555; }
.swatch.shade-3 { background: #111; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }

/* Dialog */
.dialog {
  border: var(--line) solid var(--ink);
  border-radius: 0;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}
.dialog::backdrop { background: rgba(17, 17, 17, .6); }
.dialog-title { background: var(--ink); color: var(--paper); padding: 8px 14px; font-weight: 700; font-size: 20px; }
.dialog-body { padding: 14px; }
.dialog-body p { margin: 0 0 8px; }
.dialog-actions { display: grid; gap: 8px; padding: 0 14px 14px; }

select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h5v1H4v1H3v1H2V2H1V1H0z' fill='%23111'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 9px;
  cursor: pointer;
}

/* Buy / sell */
.painting-page > div > .btn.primary { margin-bottom: var(--gap); }
.receipt { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.receipt td { padding: 4px 0; }
.receipt td:last-child { text-align: right; }
.receipt tr.total td { border-top: 3px solid var(--ink); padding-top: 8px; font-size: 20px; }
.owner .btn.primary { margin-top: 4px; }
.spaced { margin-top: 8px; }
a.btn.primary { display: block; }

/* Profiles */
.profile-head { display: flex; gap: 16px; align-items: center; }
.avatar { flex: 0 0 132px; border: var(--line) solid var(--ink); background: var(--paper); }
.avatar a { display: block; }
.avatar-empty {
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  background: var(--bg);
  font-size: 48px;
}
.profile-info { min-width: 0; }
.profile-info h1 { overflow-wrap: anywhere; margin-bottom: 4px; }
.profile-info p { margin: 0 0 6px; }
.tag { font-size: 14px; background: var(--ink); color: var(--paper); padding: 2px 6px; margin-left: 8px; vertical-align: middle; }
.small-btn { min-height: 0; padding: 4px 10px; font-size: 15px; }
.section-bar { margin-top: 18px; margin-bottom: var(--gap); }
.section-empty { margin-bottom: var(--gap); }
@media (max-width: 480px) {
  .profile-head { flex-direction: column; align-items: stretch; text-align: center; }
  .avatar { flex: none; width: 60%; margin: 0 auto; }
}

/* History */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 0; border-top: 2px dashed var(--gray-2); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.history li:first-child { border-top: 0; padding-top: 0; }
.history .when { color: var(--gray-1); font-size: 15px; white-space: nowrap; }
.avatar-control { margin-bottom: var(--gap); }
.avatar-control p { margin: 6px 0 0; }
.report-row { text-align: right; }
.report-btn { min-height: 0; padding: 4px 10px; font-size: 15px; background: transparent; border-width: 2px; }

/* Admin */
.section-bar.first { margin-top: 0; }
.admin-list { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.admin-item { display: flex; gap: 14px; margin: 0; }
.admin-thumb { flex: 0 0 160px; border: 2px solid var(--ink); align-self: flex-start; }
.admin-body { min-width: 0; display: grid; gap: 4px; }
.strong { color: var(--ink); }
.report-list { margin: 2px 0 6px; padding-left: 18px; color: var(--gray-1); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions .btn { min-height: 40px; padding: 6px 12px; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.admin-table th, .admin-table td { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--bg); white-space: nowrap; }
.admin-table th { border-bottom: 3px solid var(--ink); }
.admin-table tr.banned td { color: var(--gray-1); }
@media (max-width: 480px) {
  .admin-item { flex-direction: column; }
  .admin-thumb { flex: none; width: 100%; }
}

/* Polish */
.loading { text-align: center; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 480px) {
  .tabs .wide-only { display: none; }
  .profile-actions { justify-content: center; }
}


/* Title bar buttons: notifications + sound (pixel icons drawn as tiny SVGs) */
.bar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 32px; height: 32px;
  border: 2px solid var(--paper);
  background-color: var(--ink);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px 20px;
  image-rendering: pixelated;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.icon-btn:active { background-color: #333; }
.icon-bell { position: relative; display: inline-block; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' shape-rendering='crispEdges' fill='%23fff'%3E%3Cpath d='M4 1h2v1H4zM3 2h4v1H3zM2 3h6v3H2zM1 6h8v2H1zM4 8h2v1H4z'/%3E%3C/svg%3E"); }
/* New notification: the bell blinks three times, on/off like an old handheld. No movement. */
.icon-bell.ringing { animation: blink .3s steps(1) 3; }
@keyframes blink { 50% { background-color: var(--accent); } }
.badge {
  position: absolute; top: -9px; right: -9px;
  min-width: 18px; height: 18px; padding: 0 3px;
  background: var(--accent); color: var(--ink);
  border: 2px solid var(--paper);
  font-size: 13px; line-height: 14px; text-align: center;
}
.coins.bump { animation: bump .3s steps(1) 2; }
@keyframes bump { 50% { background: var(--accent); color: var(--ink); } }
.icon-sound-on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' shape-rendering='crispEdges' fill='%23fff'%3E%3Cpath d='M1 4h2v2H1zM3 3h1v4H3zM4 2h1v6H4zM6 4h1v2H6zM7 2h1v1H7zM8 3h1v4H8zM7 7h1v1H7z'/%3E%3C/svg%3E"); }
.icon-sound-off { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' shape-rendering='crispEdges' fill='%23fff'%3E%3Cpath d='M1 4h2v2H1zM3 3h1v4H3zM4 2h1v6H4zM6 3h1v1H6zM8 3h1v1H8zM7 4h1v2H7zM6 6h1v1H6zM8 6h1v1H8z'/%3E%3C/svg%3E"); }
@media (max-width: 480px) {
  .titlebar { font-size: 18px; padding: 7px 10px; }
  .bar-right { gap: 6px; }
  .icon-btn { width: 30px; height: 30px; background-size: 18px 18px; }
}


/* Likes */
.heart {
  display: inline-block;
  width: 14px; height: 13px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges' fill='%23111'%3E%3Cpath d='M1 0h2v1h1V0h2v1h1v2H6v1H5v1H4v1H3V5H2V4H1V3H0V1h1z'/%3E%3C/svg%3E") no-repeat center / contain;
  vertical-align: -1px;
  margin-right: 5px;
}
.like-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 17px;
  min-height: 38px; padding: 4px 12px;
  border: var(--line) solid var(--ink); background: var(--paper); color: var(--ink);
  cursor: pointer;
}
.like-btn:disabled { cursor: default; }
.like-btn.liked { background: var(--accent); }
.like-btn.liked .heart, .like-btn:hover:not(:disabled) .heart { filter: none; }
.like-btn.just-liked .heart { animation: heart-pop .35s steps(3) 1; }
@keyframes heart-pop { 50% { transform: scale(1.6); } }
.likes-mini { font-size: 15px; white-space: nowrap; color: var(--gray-1); }
.likes-mini .heart { width: 11px; height: 10px; opacity: .6; }
.card-foot { margin-top: 6px; flex-wrap: nowrap; gap: 6px; }
.card-foot .price { margin-top: 0; }
.card-wrap { display: flex; flex-direction: column; min-width: 0; }
.card-wrap .card { flex: 1; border-bottom: 0; }
.card-like { border: var(--line) solid var(--ink); border-top: 2px dashed var(--gray-2); background: var(--paper); padding: 6px 8px; }
.card-like .like-btn { width: 100%; }
.panel.line.row { flex-wrap: nowrap; }
.feature-control { margin-bottom: var(--gap); }

/* Featured page */
.featured-head p { margin: 0; }
@media (max-width: 480px) {
  .tabs { font-size: 15px; }
}

/* Notifications page */
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 2px dashed var(--gray-2); }
.notes li:first-child { border-top: 0; }
.notes .note-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notes .note-text a { text-decoration: none; }
.notes .note-text a:hover { text-decoration: underline; }
.notes .when { white-space: nowrap; }
.notes li.unread .note-text { font-weight: 700; }
.notes li .mark { flex: 0 0 10px; height: 10px; margin-top: 5px; background: transparent; }
.notes li.unread .mark { background: var(--accent); box-shadow: 0 0 0 2px var(--ink); }
.notifications-page { max-width: 680px; margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
