/*
 * デザインの下敷き：トークン・リセット・レイアウト・フォーム・ボタン。
 *
 * コンセプトは「澄んだ水面のグラデーションに、達成を金の印で刻む」。
 *   ブランド … 水色 → 青 → 紫 のグラデーション。ロゴ・ボタン・進行中のものに使う
 *   ゴールド … 「達成」だけに使う。スタンプ、連続記録、首位。安売りしない
 *   地      … ほんのり青みを含んだ白。清潔感を出しつつ真っ白の硬さを避ける
 */

/* ===== トークン ================================================= */
:root {
  /* 地と文字 */
  --paper:        #f5f7fe;
  --paper-sunk:   #e9eefb;
  --card:         #ffffff;
  --card-raised:  #ffffff;
  --ink:          #151a2e;
  --ink-2:        #4d5573;
  --ink-3:        #8b93ae;
  --line:         #e2e8f7;
  --line-strong:  #c8d2ec;

  /* ブランド（水色 → 青 → 紫） */
  --aqua:         #4fcbe6;
  --blue:         #3a63da;
  --violet:       #7b4bd4;
  --gradient:     linear-gradient(135deg, var(--aqua) 0%, var(--blue) 52%, var(--violet) 100%);
  /* 文字に使うグラデーション。地の色に対して十分暗くしないと見出しが読めない。 */
  --gradient-text: linear-gradient(115deg, #1c85a6 0%, #2a48ad 48%, #5b2fa8 100%);
  --brand:        #3a63da;
  --brand-deep:   #2a48ad;
  --brand-tint:   rgba(58, 99, 218, 0.10);
  --brand-tint-2: rgba(58, 99, 218, 0.24);
  --brand-soft:   rgba(58, 99, 218, 0.16);

  /* 達成の金。文字と線は白地で 5:1 以上のコントラストが出るところまで落とす。 */
  --gold:         #8a6612;   /* 文字・罫線 */
  --gold-fill:    #d0a63f;   /* 面で塗るとき */
  --gold-gradient: linear-gradient(135deg, #e8ce8a 0%, #c79a37 100%);
  --gold-tint:    rgba(186, 140, 40, 0.20);
  --gold-tint-2:  rgba(186, 140, 40, 0.45);

  /* 注意（達成の金と混ざらないよう別の色にする） */
  --warn:         #c2603a;
  --warn-tint:    rgba(194, 96, 58, 0.12);

  /* ガラス（透過パネル）。台紙をカードではなく、光を透かす板として見せる。 */
  --glass-bg:          linear-gradient(150deg, rgba(255, 255, 255, 0.62) 0%, rgba(232, 239, 255, 0.50) 100%);
  --glass-border:      rgba(255, 255, 255, 0.70);
  --glass-tile:        rgba(255, 255, 255, 0.92);
  --glass-tile-border: rgba(255, 255, 255, 0.85);
  --glass-highlight:   rgba(255, 255, 255, 0.55);

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(21, 26, 46, 0.05), 0 1px 1px rgba(21, 26, 46, 0.04);
  --shadow-md: 0 4px 18px rgba(21, 26, 46, 0.08), 0 1px 3px rgba(21, 26, 46, 0.05);
  --shadow-lg: 0 20px 44px rgba(21, 26, 46, 0.16), 0 3px 10px rgba(21, 26, 46, 0.07);
  --glow:      0 10px 26px -10px rgba(58, 99, 218, 0.75);
  --ring:      0 0 0 3px rgba(58, 99, 218, 0.30);

  /* かたち */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* 余白スケール */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;

  --font-sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic",
               "Noto Sans JP", "Yu Gothic Medium", "Meiryo", system-ui,
               -apple-system, "Segoe UI", sans-serif;

  --page-max: 960px;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #0a0d1a;
    --paper-sunk:   #131829;
    --card:         #141a2d;
    --card-raised:  #1a2138;
    --ink:          #e9edfb;
    --ink-2:        #a6aeca;
    --ink-3:        #757d9b;
    --line:         #242c46;
    --line-strong:  #384263;

    --aqua:         #6fdcf2;
    --blue:         #6e9bff;
    --violet:       #a67cf5;
    --gradient-text: linear-gradient(115deg, #7fe0f5 0%, #9db8ff 48%, #c9a6ff 100%);
    --brand:        #7ba3ff;
    --brand-deep:   #a5c2ff;
    --brand-tint:   rgba(123, 163, 255, 0.14);
    --brand-tint-2: rgba(123, 163, 255, 0.30);
    --brand-soft:   rgba(123, 163, 255, 0.22);

    --gold:         #e3c47c;
    --gold-fill:    #d9b152;
    --gold-tint:    rgba(227, 196, 124, 0.14);
    --gold-tint-2:  rgba(227, 196, 124, 0.34);

    --warn:         #e8956c;
    --warn-tint:    rgba(232, 149, 108, 0.14);

    --glass-bg:          linear-gradient(150deg, rgba(32, 41, 68, 0.60) 0%, rgba(22, 28, 48, 0.50) 100%);
    --glass-border:      rgba(255, 255, 255, 0.11);
    --glass-tile:        rgba(30, 38, 64, 0.80);
    --glass-tile-border: rgba(255, 255, 255, 0.10);
    --glass-highlight:   rgba(255, 255, 255, 0.10);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.6);
    --glow:      0 10px 26px -10px rgba(110, 155, 255, 0.6);
    --ring:      0 0 0 3px rgba(123, 163, 255, 0.35);
  }
}

/* ===== リセット ================================================= */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--paper);
  /* 水面のような淡い光。画像を使わず、極薄のグラデーションを重ねるだけ。 */
  background-image:
    radial-gradient(1100px 560px at 8% -10%,  rgba(79, 203, 230, 0.20), transparent 62%),
    radial-gradient(900px 520px  at 98% 2%,   rgba(123, 75, 212, 0.16), transparent 58%),
    radial-gradient(700px 420px  at 50% 108%, rgba(58, 99, 218, 0.10),  transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* 数字はいつでも桁が揃うように */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ===== タイポ =================================================== */
.display {
  font-size: clamp(30px, 7vw, 46px);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.02em;
}
.title    { font-size: clamp(21px, 4.2vw, 27px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.35; }
.subtitle { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.lede     { font-size: 16px; color: var(--ink-2); line-height: 1.8; }
.small    { font-size: 13px; color: var(--ink-2); }
.tiny     { font-size: 11.5px; color: var(--ink-3); }

/* セクション見出し。左にグラデーションの縦線を1本引くだけ。 */
.eyebrow {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 12px; font-weight: 800; letter-spacing: 0.14em;
  color: var(--ink-3); text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 3px; height: 13px; border-radius: 2px;
  background: var(--gradient); flex: none;
}

/* ===== レイアウト =============================================== */
.page {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--s5) var(--s4) calc(var(--s8) + env(safe-area-inset-bottom));
}
.stack   { display: grid; gap: var(--s5); }
.stack-s { display: grid; gap: var(--s3); }
.row     { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.center  { text-align: center; }

/* ===== ヘッダー ================================================= */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar__inner {
  max-width: var(--page-max); margin-inline: auto;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s4);
}
.appbar__title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.appbar__title a { color: inherit; }

/* サービスのロゴタイプ。文字を組むより、描かれた形のほうが名前らしく出る。 */
.appbar__brand { display: inline-flex; align-items: center; text-decoration: none; flex: none; }
.appbar__brand:hover { text-decoration: none; opacity: .85; }
.appbar__wordmark { height: 26px; width: auto; display: block; }

/* ログインなど「入口」の画面で、ルーム名の上に置くロゴ。 */
.entry__brand {
  height: 46px; width: auto;
  margin: 0 auto var(--s2);
}
@media (max-width: 480px) { .appbar__wordmark { height: 20px; } }

/* ルーム内のヘッダーは「サービス名 ｜ ルーム名」の並び。 */
.appbar__divider {
  flex: none; width: 1px; height: 18px; border-radius: 1px;
  background: var(--line-strong);
}
.appbar__room {
  min-width: 0; text-decoration: none; color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.appbar__room:hover { text-decoration: none; opacity: .75; }

/* いま誰として入っているか。名前は画面が狭いとアバターだけになる。 */
/* button で出すので、見た目は素のテキストに戻しておく。 */
.appbar__me {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  padding: 3px 7px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: inherit; font: inherit; cursor: pointer;
  transition: background .12s ease;
}
.appbar__me:hover { background: var(--brand-tint); }
.appbar__me-name {
  font-size: 13px; font-weight: 700; max-width: 8em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 480px) { .appbar__me-name { display: none; } }

/* ロゴマーク：グラデーションの印 */
.seal-mark {
  flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--gradient);
  color: #fff;
  font-weight: 800; font-size: 15px; letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), var(--glow);
}
.seal-mark--lg { width: 54px; height: 54px; border-radius: 17px; font-size: 23px; }
.seal-mark svg { width: 56%; height: 56%; }
/* ロゴはアイコンの絵そのもの。背景が透過なので、タイルに載せずに地へ直接置く。
   （ルーム名の頭文字を出す印タイルとは別物） */
.seal-mark--logo {
  background: none;
  box-shadow: none;
  border-radius: 0;
}
.seal-mark--logo img { width: 100%; height: 100%; display: block; }

/* ===== ボタン =================================================== */
.btn {
  --btn-bg: var(--card-raised);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--btn-bd); border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover  { text-decoration: none; box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px) scale(.99); box-shadow: var(--shadow-sm); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary {
  background: var(--gradient); color: #fff; border-color: transparent;
  box-shadow: var(--glow);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--ink     { --btn-bg: var(--ink); --btn-fg: var(--paper); --btn-bd: transparent; }
.btn--ghost   { --btn-bg: transparent; --btn-bd: var(--line-strong); box-shadow: none; }
.btn--quiet   { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--ink-2); }
.btn--danger  { --btn-fg: var(--warn); --btn-bd: var(--warn-tint); --btn-bg: transparent; box-shadow: none; }
.btn--sm      { min-height: 34px; padding: 0 13px; font-size: 13px; }
.btn--block   { display: flex; width: 100%; }

/* ===== フォーム ================================================= */
.field { display: grid; gap: 6px; }
.field > label, .label {
  font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.01em;
}
.field__hint { font-size: 12px; color: var(--ink-3); line-height: 1.6; }

.input, .select, .textarea {
  width: 100%; min-height: 46px;
  padding: 10px 13px;
  background: var(--card-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
  appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.input--num { font-variant-numeric: tabular-nums; }
.select {
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 13px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.fieldset {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s4); display: grid; gap: var(--s4);
  background: color-mix(in srgb, var(--paper-sunk) 45%, transparent);
}
.fieldset > legend {
  padding-inline: var(--s2); font-size: 12px; font-weight: 800;
  letter-spacing: 0.1em; color: var(--ink-3);
}

/* ===== 通知・エラー ============================================= */
.flash {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 13px var(--s4);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--card-raised);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px; font-weight: 700;
  animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2);
}
.flash.is-leaving { animation: toast-out .22s ease forwards; }
.flash--notice { border-color: var(--brand-tint-2); }
.flash--notice::before { content: "✓"; color: var(--brand); font-weight: 800; }
.flash--alert  { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.flash--alert::before { content: "!"; color: var(--warn); font-weight: 800; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

.errors {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: var(--warn-tint);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  display: grid; gap: 4px;
}
.errors__title { font-size: 13px; font-weight: 800; color: var(--warn); }
.errors li { font-size: 13.5px; color: var(--ink-2); }
.errors li::before { content: "・"; }

/* ===== アニメーション抑制 ======================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
