/* Base reset (the Claude artifact viewer adds the same one around the page) */
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Layout concept: a sunny kitchen stage. The dog sits center with a bone biscuit on its nose; the owner's hand
   and speech come from the top right. UI is pet-ID-tag cards and sticker buttons over the canvas.
   One deliberate look (the game world), so there is no dark variant. */
:root {
  --ink: #2B1B12;
  --paper: #FFFFFF;
  --paper2: #FFF3DA;      /* tag inner panel, butter */
  --muted: #6E5A4C;
  --sun: #FFD23F;         /* cheese yellow */
  --accent: #E8553F;      /* collar orange-red */
  --accent2: #1E9E92;     /* fridge teal */
  --room: #FFE38A;        /* kitchen wall */
  --room2: #F7C948;
  --f-display: "Bagel Fat One", "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-label: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --w-label: 400;
  --w-body: 400;
  color-scheme: light;
}
html:lang(ja) {
  --f-display: "Bagel Fat One", "Mochiy Pop One", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --f-label: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --f-body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --w-label: 700;
  --w-body: 500;
}
/* Jua has no accented letters: labels in these languages use Fredoka (loaded on demand) */
html:lang(es), html:lang(fr), html:lang(it) {
  --f-display: "Bagel Fat One", "Fredoka", system-ui, sans-serif;
  --f-label: "Fredoka", system-ui, sans-serif;
  --w-label: 600;
}
html, body { height: 100%; }
body {
  margin: 0; background: var(--room); color: var(--ink);
  font-family: var(--f-body); font-weight: var(--w-body); font-size: 15px; line-height: 1.55;
  overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.game { position: relative; width: 100%; height: 100%; overflow: hidden; touch-action: none; }
.game > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* overlays */
.screen {
  position: absolute; inset: 0; z-index: 5;
  display: grid; justify-items: center; align-items: start; overflow-y: auto;
  padding-block: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(43, 27, 18, 0.28);
}
.screen > .tag { margin-block: auto; }
#title, #result { background: rgba(43, 27, 18, 0.12); padding-top: max(68px, calc(env(safe-area-inset-top, 0px) + 60px)); }
#pause { background: rgba(43, 27, 18, 0.42); }
@media (max-aspect-ratio: 5/4) { #title > .tag, #result > .tag { margin-block: auto 0; } }
@media (min-aspect-ratio: 5/4) and (min-width: 900px) {
  #title, #result { justify-items: start; padding-left: max(28px, 5vw); }
  #title .tag { max-width: 400px; }
}

/* pet ID tag card */
.tag {
  position: relative; width: 100%; max-width: 420px; box-sizing: border-box;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 34px 24px 24px; display: grid; gap: 14px; text-align: center;
  word-break: keep-all; overflow-wrap: anywhere;
}
html:lang(ja) .tag { word-break: normal; line-break: strict; }
.tag::before { /* the ring hole of a dog's name tag */
  content: ""; position: absolute; top: 10px; left: 50%; width: 16px; height: 16px; margin-left: -8px;
  border-radius: 50%; border: 4px solid var(--ink); background: var(--room); box-sizing: border-box;
}
.eyebrow { font-family: var(--f-label); font-weight: var(--w-label); font-size: 14px; letter-spacing: 0.08em; color: var(--muted); margin: 0; }
.title {
  font-family: var(--f-display); font-weight: 400; margin: 0; line-height: 1.02;
  font-size: clamp(42px, 12vw, 64px); letter-spacing: -0.01em; text-wrap: balance;
  color: var(--accent); text-shadow: 3px 3px 0 var(--ink);
}
.title.sm { font-size: clamp(34px, 9vw, 46px); }
.lede { margin: 0; font-size: 16px; text-wrap: balance; }
/* a row of sticker buttons: the margin makes room for their drop shadow, so the gap below looks like every other gap */
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.row:has(> .btn.small) { margin-bottom: 4px; }
#title .row .btn { flex: 1 1 0; min-width: max-content; font-size: clamp(19px, 5.6vw, 22px); padding-inline: clamp(10px, 3.4vw, 16px); }

/* sticker buttons */
.btn {
  appearance: none; cursor: pointer; font-family: var(--f-label); font-weight: var(--w-label); font-size: 22px; line-height: 1;
  color: #FFFFFF; background: var(--accent); border: 4px solid var(--ink); border-radius: 999px;
  padding: 15px 30px 13px; box-shadow: 0 6px 0 var(--ink); transform: translateY(0);
  transition: transform 0.06s, box-shadow 0.06s; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; box-sizing: border-box;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--accent2); outline-offset: 4px; }
.btn.ghost { color: var(--ink); background: var(--paper); }
.btn.sun { color: var(--ink); background: var(--sun); }
.btn.small { font-size: 17px; padding: 11px 18px 9px; box-shadow: 0 4px 0 var(--ink); border-width: 3px; }
.btn.small:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn svg { width: 20px; height: 20px; flex: none; }

/* title extras: the dogs as round profile pictures in one row (names stay for screen readers and tooltips) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 3px; }
.chip {
  appearance: none; cursor: pointer; display: block; padding: 3px; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: 0 3px 0 var(--ink); touch-action: manipulation;
}
.chip canvas { width: 40px; height: 40px; display: block; }
.chip-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chip[aria-checked="true"] { background: var(--sun); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
.best { margin: 0; font-family: var(--f-label); font-weight: var(--w-label); font-size: 15px; color: var(--muted); }

/* result: the share card is the result */
.tag-result { max-width: 400px; padding: 34px 16px 18px; gap: 12px; }
.rblock { display: grid; gap: 12px; }
.card-wrap {
  position: relative; width: 100%; max-width: 100%; aspect-ratio: 4 / 5; box-sizing: border-box;
  border: 3px solid var(--ink); border-radius: 20px; overflow: hidden; background: var(--room); justify-self: center;
}
.card-wrap.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0) 70%) 0 0 / 220% 100% var(--room);
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.card-img {
  display: block; width: 100%; height: 100%;
  -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; pointer-events: auto;
}
.share .btn { flex: 1 1 0; min-width: max-content; font-size: 18px; padding: 13px clamp(10px, 3vw, 14px) 11px; gap: 6px; }
#btnPost svg { width: 18px; height: 18px; } /* the X logo fills its box more than the outline icons do */
.score-big { font-family: var(--f-display); font-size: clamp(44px, 13vw, 64px); line-height: 1; margin: 0; font-variant-numeric: tabular-nums; }
.rank {
  justify-self: center; margin: 0; font-family: var(--f-label); font-weight: var(--w-label); font-size: 18px; padding: 6px 16px 5px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--sun);
}
.rsub { margin: -6px 0 0; font-family: var(--f-label); font-weight: var(--w-label); font-size: 15px; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stats div { background: var(--paper2); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 6px; min-width: 0; }
.stats dt { font-family: var(--f-label); font-weight: var(--w-label); font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--f-display); font-size: 24px; font-variant-numeric: tabular-nums; }

/* follow banner: the maker's X account, on the title and result tags */
.follow {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: 7px 10px 7px 8px; background: var(--paper2); border: 3px solid var(--ink); border-radius: 18px; text-align: left;
}
.follow-dog canvas { width: 36px; height: 36px; display: block; }
.follow-txt { margin: 0; min-width: 0; font-family: var(--f-label); font-weight: var(--w-label); font-size: 15px; line-height: 1.25; }
.follow-handle { white-space: nowrap; }
.follow .btn { font-size: 15px; padding: 9px 12px 7px; gap: 5px; box-shadow: 0 3px 0 var(--ink); }
.follow .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.follow .btn svg { width: 15px; height: 15px; }
.follow-close {
  position: absolute; top: -11px; right: -11px; width: 26px; height: 26px; padding: 0; display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 50%; background: var(--paper); color: var(--ink);
  font: 700 15px/1 system-ui, sans-serif; cursor: pointer; touch-action: manipulation;
}
.follow-close:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* corner controls */
.corner {
  position: absolute; z-index: 6; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px));
  width: 46px; height: 46px; box-sizing: border-box; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper);
  box-shadow: 0 4px 0 var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.corner:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.corner:focus-visible { outline: 4px solid var(--accent2); outline-offset: 3px; }
.corner svg { width: 24px; height: 24px; }
.langpick {
  position: absolute; z-index: 6; top: calc(10px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px));
  height: 46px; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px 0 11px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--paper); box-shadow: 0 4px 0 var(--ink);
  font-family: var(--f-label); font-weight: var(--w-label); font-size: 17px; line-height: 1; color: var(--ink);
}
.langpick svg { width: 20px; height: 20px; flex: none; }
.langpick select {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; margin: 0;
  font-size: 16px; appearance: none;
}
.langpick:focus-within { outline: 4px solid var(--accent2); outline-offset: 3px; }
.langpick:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* toast */
.toast {
  position: absolute; z-index: 9; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  width: max-content; max-width: min(88vw, 440px); box-sizing: border-box; padding: 11px 18px 10px;
  background: var(--ink); color: #FFFFFF; border-radius: 999px; text-align: center;
  font-family: var(--f-label); font-weight: var(--w-label); font-size: 15px; line-height: 1.3;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 720px) and (max-aspect-ratio: 5/4) {
  .tag { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .corner, .toast { transition: none; }
  .card-wrap.loading::after { animation: none; }
}
