/* ===== Antique celestial chart =====
 * No gradients, no glows, no glass. Structure comes from rules (hairlines),
 * generous letter-spacing, and paper/ink contrast — the way an 18th-century
 * star atlas is built. Brass is the only accent, used sparingly.
 */

/* Parchment. One palette — the chart is printed on paper, not projected. */
:root {
  color-scheme: light;
  --paper: #eae4d5;
  --panel: #f2ede0;
  --ink: #1b2233;
  --muted: #6b7590;
  --rule: #c6bda6;
  --rule-strong: #a99e83;
  --brass: #8f6f34;
  --brass-ink: #f2ede0;
  --oxide: #9c4a3c;
  --field: #f7f3e8;
  --star: #b0a68e;
  --star-dim: #c7bda6;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, Georgia,
    "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic UI", Roboto, Helvetica, Arial, sans-serif;
  --mono-font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fixed starfield. Static — stars in an atlas are plotted, not animated. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 11% 12%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 26% 41%, var(--star-dim), transparent 100%),
    radial-gradient(1.5px 1.5px at 39% 8%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 54% 29%, var(--star-dim), transparent 100%),
    radial-gradient(2px 2px at 67% 14%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 81% 36%, var(--star-dim), transparent 100%),
    radial-gradient(1.5px 1.5px at 92% 19%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 6% 58%, var(--star-dim), transparent 100%),
    radial-gradient(1.5px 1.5px at 31% 72%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 47% 89%, var(--star-dim), transparent 100%),
    radial-gradient(2px 2px at 61% 64%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 77% 81%, var(--star-dim), transparent 100%),
    radial-gradient(1.5px 1.5px at 94% 57%, var(--star), transparent 100%),
    radial-gradient(1px 1px at 17% 94%, var(--star-dim), transparent 100%);
}
/* Two faint celestial circles, as on an armillary plate. */
body::after {
  content: "";
  position: fixed;
  top: -18vw;
  left: 50%;
  width: 122vw;
  height: 122vw;
  margin-left: -61vw;
  z-index: 0;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--brass) 16%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 1px transparent,
    inset 0 0 0 clamp(60px, 13vw, 190px) transparent,
    inset 0 0 0 calc(clamp(60px, 13vw, 190px) + 1px)
      color-mix(in srgb, var(--brass) 11%, transparent);
}

.wrap { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 56px 20px 80px; }

/* ===== Masthead ===== */
header { margin-bottom: 40px; text-align: center; }
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
.kicker::before, .kicker::after {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--rule-strong);
}
.star-mark { color: var(--brass); font-size: 0.8rem; letter-spacing: 0; }

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.55rem, 4.6vw, 2.35rem);
  margin: 0;
  letter-spacing: 0.12em;
  line-height: 1.35;
  text-transform: uppercase;
}
h1 a { color: inherit; text-decoration: none; }
/* Double rule beneath the masthead — the atlas plate border. */
.rule-double {
  height: 4px;
  margin: 18px auto 20px;
  max-width: 420px;
  border-top: 1px solid var(--brass);
  border-bottom: 1px solid var(--brass);
  opacity: 0.65;
}
.sub {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.9;
  margin: 0 auto;
  max-width: 32em;
}

/* ===== Plates (cards) ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 26px;
}

.name-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.remove {
  flex: 0 0 auto;
  width: 44px;
  height: 48px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.remove:hover { color: var(--oxide); border-color: var(--oxide); }

.field-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.add-btn {
  font-family: var(--sans);
  background: transparent;
  border: 1px dashed var(--rule-strong);
  color: var(--muted);
  border-radius: 2px;
  padding: 13px 18px;
  cursor: pointer;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  transition: color 0.15s, border-color 0.15s;
}
.add-btn:hover:not(:disabled) { color: var(--brass); border-color: var(--brass); }
.add-btn:disabled { opacity: 0.4; cursor: default; }

.field { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"] {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  padding: 13px 15px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: var(--field);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s;
}
input[type="text"]::placeholder { color: var(--muted); opacity: 0.65; }
input[type="text"]:focus { border-color: var(--brass); }

/* The one filled element on the page. */
button.primary {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: 2px;
  border: 1px solid var(--brass);
  background: var(--brass);
  color: var(--brass-ink);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
button.primary:hover:not(:disabled) { background: transparent; color: var(--brass); }
button.primary:disabled { opacity: 0.45; cursor: default; }

.opts {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--muted);
}
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 2px; }
.seg button {
  font-family: var(--sans);
  border: none;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.15s, background 0.15s;
}
.seg button:last-child { border-right: none; }
.seg button:hover:not(.on) { color: var(--ink); }
.seg button.on { background: var(--brass); color: var(--brass-ink); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--brass); width: 14px; height: 14px; }
.hint { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); flex-basis: 100%; }
.hint code { font-family: var(--mono-font); color: var(--brass); }

/* No text-transform here: this line echoes the name the user typed. */
.status {
  margin: 30px 0 16px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  min-height: 1.2em;
}
.status b { color: var(--ink); font-weight: 600; }

/* ===== Scramble: letters being cast, then read ===== */
.scramble {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 30px 0 10px;
  min-height: 54px;
}
.scramble:empty { display: none; }
.tile {
  width: 40px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: var(--panel);
  border: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 1.3rem;
  text-transform: uppercase;
  color: var(--muted);
  animation: tileWaver 1.1s ease-in-out infinite alternate;
}
@keyframes tileWaver {
  from { transform: translateY(0); border-color: var(--rule); }
  to   { transform: translateY(-3px); border-color: var(--rule-strong); }
}
.scramble.settled .tile {
  animation: tileSet 0.4s ease-out backwards;
  border-color: var(--brass);
  color: var(--ink);
}
@keyframes tileSet {
  from { transform: translateY(-3px); opacity: 0.35; }
  to   { transform: none; opacity: 1; }
}
.scramble.fading { opacity: 0; transition: opacity 0.35s; }

/* ===== The lead result: the page's principal figure ===== */
.headline {
  text-align: center;
  padding: 34px 20px 30px;
  border: 1px solid var(--brass);
  border-radius: 2px;
  background: var(--panel);
  margin-bottom: 34px;
  animation: plateIn 0.45s ease-out;
}
@keyframes plateIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.headline-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 18px;
}
.headline-pick {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  padding: 6px 4px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--serif);
}
.headline-name {
  display: block;
  font-size: clamp(1.9rem, 7vw, 3rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  word-break: break-word;
}
.headline-kana {
  display: block;
  margin-top: 14px;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: var(--ink);
}
.headline-handle {
  display: block;
  margin-top: 10px;
  font-family: var(--mono-font);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--brass);
  word-break: break-all;
}
.headline-pick:focus-visible { outline: 1px solid var(--brass); outline-offset: 2px; }
.headline-hint {
  display: block;
  margin-top: 16px;
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ===== The reading: a companion plate, set below the names ===== */
.fortune {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  margin: 40px 0 0;
  padding: 3px;
}
.fortune-inner {
  border: 1px solid var(--rule);
  padding: 24px 24px 22px;
}
.fortune-head {
  font-family: var(--sans);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 18px;
}

/* Numeral, name and label read as one line — a caption, not a headline. */
.meisu {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 14px;
}
.meisu-num {
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--brass);
}
.meisu-name { font-size: 1.15rem; letter-spacing: 0.22em; text-indent: 0.22em; }
.meisu-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.personality {
  margin: 0 auto 22px;
  max-width: 30em;
  text-align: center;
  font-size: 0.92rem;
}

.fortune-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  margin-bottom: 22px;
}
.fortune-facts > div {
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 14px 16px;
  text-align: center;
}
.fortune-facts span {
  display: block;
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.fortune-facts b {
  font-weight: 400;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  width: 13px; height: 13px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid var(--brass);
}
.element-text {
  margin: 0 0 26px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.guard {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 16px;
  margin-bottom: 26px;
  text-align: center;
  font-size: 1.05rem;
  transition: border-color 0.16s;
}
.guard:hover { border-color: var(--brass); }
.guard .gl {
  display: block;
  font-family: var(--sans);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.guard .gk {
  display: block;
  margin-top: 6px;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
}
.guard .gh {
  display: block;
  margin-top: 4px;
  font-family: var(--mono-font);
  color: var(--brass);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.stats { margin-bottom: 26px; }
.stat {
  display: grid;
  grid-template-columns: 5.5em 1fr 2.4em;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.85rem;
}
.stat:first-child { border-top: 1px solid var(--rule); }
.stat-k { color: var(--muted); font-family: var(--sans); font-size: 0.76rem; letter-spacing: 0.1em; }
/* A ruled scale, ticked at each fifth — read like an instrument, not a meter. */
.bar {
  position: relative;
  height: 9px;
  border-bottom: 1px solid var(--rule);
  background-image: repeating-linear-gradient(
    to right, var(--rule) 0 1px, transparent 1px 20%
  );
  background-position: bottom;
  background-size: 100% 4px;
  background-repeat: no-repeat;
}
.bar > i {
  position: absolute;
  bottom: -1px;
  left: 0;
  display: block;
  height: 3px;
  background: var(--brass);
  animation: barDraw 0.8s ease-out backwards;
}
@keyframes barDraw { from { width: 0; } }
.stat-v {
  text-align: right;
  color: var(--ink);
  font-family: var(--mono-font);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.fortune-msg {
  text-align: center;
  font-size: 1.02rem;
  font-style: italic;
  line-height: 2;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  color: var(--ink);
}

/* ===== Index of candidates ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.sortlabel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.sortlabel select {
  font-family: var(--serif);
  font-size: 0.92rem;
  padding: 7px 10px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s;
}
.sortlabel select:hover { border-color: var(--brass); }
.toolbar .caption { font-family: var(--sans); font-size: 0.76rem; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.result {
  position: relative;
  overflow: hidden;
  text-align: left;
  background: var(--panel);
  border: none;
  border-radius: 0;
  padding: 15px 16px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--serif);
  transition: background 0.16s;
  animation: cardIn 0.36s ease-out backwards;
}
@keyframes cardIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.result:hover { background: var(--field); }
.result:focus-visible { outline: 1px solid var(--brass); outline-offset: -3px; }
.result .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.result .name { font-size: 1.05rem; letter-spacing: 0.01em; }
.result .badge {
  font-family: var(--mono-font);
  font-size: 0.7rem;
  color: var(--brass);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.result .kana {
  margin-top: 4px;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.result .handle {
  margin-top: 3px;
  font-family: var(--mono-font);
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}
/* Copy confirmation: the plate takes ink briefly. */
.result.copied::after,
.headline-pick.copied::after,
.guard.copied::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brass);
  animation: inkPress 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes inkPress {
  from { opacity: 0.28; }
  to   { opacity: 0; }
}

.empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 2px;
  animation: plateIn 0.4s ease-out;
}
.empty .big { font-size: 1.6rem; color: var(--brass); margin-bottom: 12px; letter-spacing: 0.3em; }

.more {
  display: block;
  margin: 22px auto 0;
  font-family: var(--sans);
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 2px;
  padding: 11px 24px;
  cursor: pointer;
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}
.more:hover { color: var(--brass); border-color: var(--brass); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--brass);
  color: var(--ink);
  padding: 13px 22px;
  border-radius: 2px;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.24s ease-out;
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .tick { flex: 0 0 auto; color: var(--brass); font-size: 0.9rem; }

/* ===== Ad slots ===== */
.ad-slot { margin: 32px 0; }
.ad-label {
  font-family: var(--sans);
  font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: 6px;
}
.ad-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 90px;
  border: 1px dashed var(--rule);
  border-radius: 2px;
  color: var(--muted); font-size: 0.8rem; text-align: center;
  font-family: var(--sans);
}
.ad-placeholder small { font-size: 0.7rem; opacity: 0.8; }

/* ===== Cookie consent ===== */
.consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  max-width: 720px; margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 16px 18px; display: flex; gap: 14px; align-items: center;
  flex-wrap: wrap; z-index: 50; font-size: 0.84rem;
}
.consent-text { flex: 1 1 260px; color: var(--ink); }
.consent-text a { color: var(--brass); }
.consent-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.consent-actions button {
  font-family: var(--sans);
  border-radius: 2px; padding: 10px 20px; cursor: pointer;
  font-size: 0.76rem; letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid var(--brass);
  background: var(--brass); color: var(--brass-ink);
  transition: background 0.16s, color 0.16s;
}
.consent-actions button:hover { background: transparent; color: var(--brass); }

/* ===== Footer ===== */
footer {
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--rule);
  text-align: center; color: var(--muted);
  font-family: var(--sans); font-size: 0.76rem;
}
.footer-nav { margin-bottom: 10px; }
.footer-nav a {
  color: var(--muted); text-decoration: none; margin: 0 12px;
  letter-spacing: 0.06em;
}
.footer-nav a:hover { color: var(--brass); }

/* ===== Content pages (about / privacy) ===== */
.content header { text-align: left; }
.content header .sub { margin: 0; max-width: none; }
.content header .rule-double { margin-left: 0; }
.content h2 {
  font-weight: 400; font-size: 1.35rem; margin: 40px 0 12px;
  letter-spacing: 0.06em;
  padding-bottom: 8px; border-bottom: 1px solid var(--rule);
}
.content h3 { font-weight: 400; font-size: 1.1rem; margin: 26px 0 8px; letter-spacing: 0.04em; }
.content p, .content li { font-size: 0.95rem; }
.content a { color: var(--brass); }
.content ul { padding-left: 1.2em; }
.content .card { margin-bottom: 18px; }
.back-link {
  display: inline-block; margin-bottom: 24px; color: var(--muted);
  text-decoration: none; font-family: var(--sans);
  font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase;
}
.back-link:hover { color: var(--brass); }
.updated { color: var(--muted); font-size: 0.8rem; }
.meisu-list { border-top: 1px solid var(--rule); margin: 16px 0; }
.meisu-list .row {
  display: grid; grid-template-columns: 100px 1fr; gap: 12px;
  border-bottom: 1px solid var(--rule);
  padding: 12px 4px;
  font-size: 0.9rem;
}
.meisu-list .k { color: var(--brass); }

/* ===== Motion opt-out ===== */
@media (prefers-reduced-motion: reduce) {
  .tile, .bar > i, .result, .headline, .empty { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}
