:root,
[data-theme="paper"] {
  --bg: #f4efe6;
  --surface: #fffaf3;
  --fg: #1b1814;
  --muted: #655d52;
  --line: rgba(27, 24, 20, 0.14);
  --accent: #b5522a;
  --accent-fg: #fffaf3;
}
[data-theme="ink"] {
  --bg: #141210;
  --surface: #221e1a;
  --fg: #f4efe6;
  --muted: #b3a89a;
  --line: rgba(244, 239, 230, 0.16);
  --accent: #e07a45;
  --accent-fg: #141210;
}
[data-theme="sea"] {
  --bg: #e4eef2;
  --surface: #f7fbfc;
  --fg: #12262e;
  --muted: #4d6670;
  --line: rgba(18, 38, 46, 0.14);
  --accent: #0c6e86;
  --accent-fg: #f7fbfc;
}
[data-theme="moss"] {
  --bg: #e6eee4;
  --surface: #f7faf6;
  --fg: #1a291c;
  --muted: #516355;
  --line: rgba(26, 41, 28, 0.14);
  --accent: #3d6b45;
  --accent-fg: #f7faf6;
}
:root {
  --sans: "Outfit", "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "Noto Sans Devanagari", ui-sans-serif, system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --control: 2.75rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
}
main { flex: 1 0 auto; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button, [role="button"] { cursor: pointer; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -0.03em; text-wrap: balance; margin: 0; }
p { margin: 0; }

.wrap { width: min(40rem, calc(100% - 1rem)); margin-inline: auto; }
header.bar, footer.bar {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.55rem;
  padding-block: 0.85rem;
}
.brand { font-family: var(--display); font-size: 1.2rem; line-height: 1.15; text-align: center; text-decoration: none; }
.tools { width: auto; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 1.15rem; }
.emoji-pick {
  width: 2.75rem;
  min-height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font-size: 1.05rem;
  text-align: center;
  padding: 0 0.15rem;
}
#install[hidden] { display: none; }
#install { width: auto; padding: 0 0.75rem; font-size: 0.85rem; }
.lang { position: relative; }
.lang-menu[hidden] { display: none; }
.lang-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 14rem;
  max-height: min(70vh, 28rem);
  overflow: auto;
  padding: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 16px 40px color-mix(in srgb, var(--fg) 12%, transparent);
}
.lang-menu a {
  padding: 0.75rem 1rem;
  border-radius: 0.7rem;
  text-decoration: none;
  white-space: nowrap;
}
.lang-menu a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); }
nav { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
nav a, .quiet { color: var(--muted); text-decoration: none; }
nav a:hover, .quiet:hover { color: var(--fg); }

main { display: flex; flex-direction: column; gap: 2.5rem; padding-bottom: 4rem; }
.hero { display: grid; gap: 1.5rem; align-items: end; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.1fr 0.9fr; } }
.kicker { color: var(--muted); letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.75rem; }
.display { font-size: clamp(1.8rem, 7vw, 2.4rem); line-height: 1.05; }
.lede { font-size: 1.25rem; color: var(--muted); max-width: 38rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.grid { display: grid; gap: 0.9rem; }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.four { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface); border-radius: 1.4rem; padding: 1.15rem 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; }
.card h2 { font-size: 1.7rem; }
.muted { color: var(--muted); }
.frame { border-radius: 1.6rem; overflow: hidden; background: var(--surface); }
.frame img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: var(--control);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-decoration: none;
}
.btn span.disc {
  width: var(--control);
  height: var(--control);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
}
.btn.quiet span.disc { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.55; cursor: wait; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.field, select.field, textarea.field {
  width: 100%;
  min-height: var(--control);
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  padding-inline: 0.9rem;
}
textarea.field { min-height: 7rem; padding-block: 0.75rem; resize: vertical; }
.field:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
form.stack, .stack { display: flex; flex-direction: column; gap: 0.8rem; }
.err { color: var(--accent); font-size: 0.9rem; }
.desk { display: grid; gap: 1rem; }
@media (min-width: 900px) { .desk { grid-template-columns: 0.9fr 1.1fr; } }
.kinds { display: flex; flex-wrap: wrap; gap: 0.4rem; }
footer.bar { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
audio { width: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.brand { white-space: nowrap; max-width: 100%; font-size: clamp(0.92rem, 4.5vw, 1.15rem); line-height: 1.1; }

.board { display: flex; flex-direction: column; gap: 0.8rem; }
.fx {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 4.4rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
}
.fx.head {
  background: color-mix(in srgb, var(--fg) 10%, var(--surface));
  border-radius: 1rem 1rem 0 0;
}
#rows .fx:last-child { border-radius: 0 0 1rem 1rem; }
.pick { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; min-width: 0; }
.flag { font-size: 1.9rem; line-height: 1; width: 2.2rem; text-align: center; }
.code { font-size: 1.45rem; letter-spacing: 0.04em; }
.pick select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.amt {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  text-align: end;
  width: auto;
  min-width: 2.4rem;
  max-width: none;
  field-sizing: content;
  border: 0;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--fg);
  padding: 0.35rem 0.45rem;
}
.amt.out { background: transparent; }
.x {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.2rem;
}
#board > .btn { align-self: flex-start; }

.tool { width: 100%; margin: 0.25rem auto 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.flag img { width: 1.7rem; height: 1.15rem; object-fit: cover; border-radius: 0.2rem; display: block; }
dialog {
  width: min(22rem, calc(100% - 1.5rem));
  margin: auto;
  border: 0;
  border-radius: 1.2rem;
  background: var(--bg);
  color: var(--fg);
  padding: 1rem;
}
dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.pile { position: relative; height: 10.5rem; margin-bottom: 0.8rem; }
.pile div {
  position: absolute;
  inset-inline: 0.4rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  padding-inline: 0.85rem;
  border-radius: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.pile div:nth-child(1) { top: 0; z-index: 7; }
.pile div:nth-child(2) { top: 0.85rem; z-index: 6; opacity: 0.86; }
.pile div:nth-child(3) { top: 1.7rem; z-index: 5; opacity: 0.7; }
.pile div:nth-child(4) { top: 2.55rem; z-index: 4; opacity: 0.54; }
.pile div:nth-child(5) { top: 3.4rem; z-index: 3; opacity: 0.38; }
.pile div:nth-child(6) { top: 4.25rem; z-index: 2; opacity: 0.22; }
.pile div:nth-child(7) { top: 5.1rem; z-index: 1; opacity: 0.1; }

.find {
  flex: 1 1 8rem;
  width: auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1.05rem;
  padding: 0.45rem 0.6rem;
}
.find-list {
  flex: 1 0 100%;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  max-height: 14rem;
  overflow: auto;
}
.find-list[hidden] { display: none; }
.find-list button {
  text-align: start;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}
#add { cursor: pointer; }

.brand {
  white-space: nowrap;
  font-size: clamp(0.82rem, 3.7vw, 1.05rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 100%;
}
.pick { display: flex; flex-direction: column; width: 100%; min-width: 0; gap: 0.35rem; }
.find-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--bg);
  padding: 0 0.45rem;
}
.find-row .find {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.15rem;
}
.find-list[hidden] { display: none; }
.find-empty { margin: 0; padding: 0.55rem 0.7rem; color: var(--muted); }

.drop {
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  padding: 0.4rem 0.15rem;
  cursor: pointer;
}

.find-list {
  position: fixed;
  z-index: 80;
  max-height: min(16rem, 50vh);
  overflow: auto;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--fg) 18%, transparent);
}

.brand {
  display: inline-block;
  width: auto;
  max-width: 100%;
  white-space: nowrap;
  text-align: center;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.emoji-pick { width: clamp(2.75rem, 12vw, 3.2rem); min-height: clamp(2.4rem, 10vw, 2.9rem); }

footer.bar {
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  margin-top: auto;
  white-space: nowrap;
}

#updated { text-align: center; margin-top: -0.35rem; }

#add { align-self: center; }
