@font-face {
  font-family: 'BotFont';
  src: url('./assets/MPLUS1p-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --text: #fff;
  --text-soft: rgba(255, 255, 255, 0.75);
  --gold: #ffd54a;
  --panel: rgba(0, 0, 0, 0.32);
  --overlay: rgba(0, 0, 0, 0.35);
  --medal-1: #f5c542;
  --medal-2: #cfd6df;
  --medal-3: #cd8a4b;
  --ink: #1d2036;
  --font: 'BotFont', 'M PLUS 1p', 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(var(--overlay), var(--overlay)),
    url('./assets/welcome_bg.png') center / cover,
    linear-gradient(135deg, hsl(235 75% 60%), hsl(285 75% 55%));
}

#app {
  display: grid;
  gap: 20px;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 32px);
}

@media (min-width: 820px) {
  #app { grid-template-columns: minmax(300px, 4fr) minmax(0, 5fr); align-items: stretch; }
}

.notice { grid-column: 1 / -1; margin: 40px 0; text-align: center; font-size: 20px; }

.card {
  padding: clamp(18px, 3vw, 28px);
  background: var(--panel);
  border-radius: 24px;
}

svg.lucide { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }

.who { display: flex; align-items: center; gap: 16px; min-width: 0; }
.who img { width: 88px; height: 88px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.9); flex: none; }
.who h1 { margin: 0; font-size: clamp(22px, 4vw, 30px); overflow-wrap: anywhere; line-height: 1.25; }

.level { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 14px; }
.level small { font-size: 26px; color: var(--text-soft); }
.level strong { font-size: clamp(72px, 14vw, 104px); line-height: 1; color: var(--gold); font-weight: 700; }

.bar { height: 14px; overflow: hidden; background: rgba(255, 255, 255, 0.2); border-radius: 999px; }
.bar > i { display: block; width: calc(var(--p, 0) * 100%); height: 100%; background: var(--gold); border-radius: inherit; transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.bar-label { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 0; color: var(--text-soft); font-size: 15px; }

.me { display: flex; flex-direction: column; }
.stats { display: grid; gap: 10px; margin: auto 0 0; padding: 22px 0 0; list-style: none; }
.stats li { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.stats li span:first-of-type { color: var(--text-soft); font-size: 15px; }
.stats li b { margin-left: auto; font-weight: 700; }
.stats svg { color: var(--gold); }

.board h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 22px; color: var(--gold); }
.board ol { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.row { display: grid; grid-template-columns: 36px 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 16px; }
.row.is-me { background: rgba(255, 255, 255, 0.14); outline: 2px solid var(--gold); }
.row img { width: 44px; height: 44px; border-radius: 50%; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { text-align: right; line-height: 1.25; }
.row .meta small { display: block; color: var(--text-soft); font-size: 13px; }

.place { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; color: var(--text-soft); text-shadow: none; }
.place.m1 { background: var(--medal-1); color: var(--ink); }
.place.m2 { background: var(--medal-2); color: var(--ink); }
.place.m3 { background: var(--medal-3); color: var(--ink); }

.bump { grid-column: 1 / -1; padding: 0; }
.bump-head {
  transition: background-color 0.2s ease;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  padding: clamp(18px, 3vw, 28px); color: inherit; background: transparent; border: 0; border-radius: 24px;
  font: inherit; text-align: left; text-shadow: inherit; cursor: pointer;
}
.bump-head:hover { background: rgba(255, 255, 255, 0.06); }
.bump-head:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.bump-label { display: block; color: var(--text-soft); font-size: 15px; }
.bump-time { display: block; color: var(--gold); font-size: clamp(26px, 6vw, 40px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.chev { display: grid; flex: none; transition: transform 0.2s; }
.chev svg { width: 1.8em; height: 1.8em; }
.bump-head[aria-expanded='true'] .chev { transform: rotate(90deg); }
.bump-help { padding: 0 clamp(18px, 3vw, 28px) clamp(18px, 3vw, 28px); color: var(--text-soft); font-size: 15px; }
.bump-help ul { display: grid; gap: 8px; margin: 0; padding-left: 1.2em; }

.row-button {
  transition: background-color 0.2s ease;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin-top: 18px; padding: 14px 18px;
  color: inherit; background: rgba(255, 255, 255, 0.12); border: 0; border-radius: 16px;
  font: inherit; font-size: 17px; text-shadow: inherit; cursor: pointer;
}
.row-button:hover { background: rgba(255, 255, 255, 0.2); }
.row-button:focus-visible, .back:focus-visible, .primary:focus-visible, .ghost:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.row-button .chev svg { width: 1.4em; height: 1.4em; }

.view { grid-column: 1 / -1; width: min(100%, 720px); justify-self: center; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.view-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 22px; color: var(--gold); }
.back { transition: background-color 0.2s ease; display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px 6px 8px; color: inherit; background: rgba(255, 255, 255, 0.12); border: 0; border-radius: 999px; font: inherit; text-shadow: inherit; cursor: pointer; }
.back:hover { background: rgba(255, 255, 255, 0.2); }

.bio-section { margin: 0 0 18px; }
.bio-section h3 { margin: 0 0 6px; color: var(--gold); font-size: 16px; }
.bio-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.saved { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; color: var(--gold); }

.bio-form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field-label { display: flex; justify-content: space-between; gap: 12px; color: var(--gold); font-size: 16px; }
.count { color: var(--text-soft); font-size: 13px; }
.field-input {
  width: 100%; padding: 12px 14px; color: var(--text); background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.25); border-radius: 14px; font: inherit; text-shadow: none; resize: vertical;
}
.field-input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.form-message { min-height: 1.5em; margin: 0; color: #ffd0d0; }
.form-message:empty { min-height: 0; }

.who.small { margin-bottom: 18px; font-size: 18px; }
.who.small img { width: 44px; height: 44px; border-width: 3px; }

dialog.preview {
  width: min(94vw, 760px); max-height: 86vh; padding: clamp(18px, 3vw, 28px); overflow: auto;
  color: var(--text); background: #261c4d; border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 24px;
  font: inherit; text-shadow: none;
}
.card-image { display: block; width: 100%; height: auto; border-radius: 10px; }
dialog.preview { opacity: 0; transform: scale(0.5); transition: opacity 0.22s ease-in, transform 0.22s ease-in; }
dialog.preview.is-open { opacity: 1; transform: scale(1); transition: opacity 0.28s ease-out, transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog.preview::backdrop { background: rgba(0, 0, 0, 0); transition: background-color 0.2s ease; }
dialog.preview.is-open::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog.preview h3 { margin: 0 0 16px; color: var(--gold); font-size: 20px; }
dialog.preview .actions { margin-top: 20px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary, .ghost { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border: 0; border-radius: 999px; font: inherit; text-shadow: none; cursor: pointer; }
.primary { color: var(--ink); background: var(--gold); }
.primary:disabled { opacity: 0.6; cursor: default; }
.ghost { color: var(--text); background: rgba(255, 255, 255, 0.14); }

.gap { margin: 6px 0; text-align: center; color: var(--text-soft); letter-spacing: 0.3em; }
.empty { margin: 0; color: var(--text-soft); }

.error { grid-column: 1 / -1; justify-self: center; max-width: 460px; text-align: center; }
.error p { margin: 0 0 18px; }
.error button {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px;
  color: var(--ink); background: var(--gold); border: 0; border-radius: 999px;
  font: inherit; text-shadow: none; cursor: pointer;
}
.error button:focus-visible, .row:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .bar > i, .chev, .bump-head, .row-button, .back, dialog.preview, dialog.preview::backdrop { transition: none; }
}
