/* ============================================================
   Jadon Score - playful, gamified behaviour scoreboard
   Palette: warm cream + ink, orange brand accent,
            emerald positive, rose negative.
   Type: Fredoka (display) + Plus Jakarta Sans (body)
   ============================================================ */

:root {
  --bg:        #FFF6EC;
  --bg-soft:   #FBEFDF;
  --surface:   #FFFFFF;
  --ink:       #221F2B;
  --ink-soft:  #5C5868;
  --muted:     #9A93A8;
  --line:      #ECE3D4;

  --brand:     #FF6B2C;   /* warm orange */
  --brand-dk:  #E4541A;
  --pos:       #16A34A;
  --pos-bg:    #E7F6EC;
  --neg:       #E23754;
  --neg-bg:    #FCE7EA;

  /* tier colors */
  --tier-gold:   #F59E0B;
  --tier-gold-bg:#FEF3C7;
  --tier-green:  #16A34A;
  --tier-green-bg:#E7F6EC;
  --tier-amber:  #D97706;
  --tier-amber-bg:#FFF3CD;
  --tier-red:    #E23754;
  --tier-red-bg: #FCE7EA;

  --shadow-sm: 0 1px 2px rgba(34,31,43,.06), 0 2px 8px rgba(34,31,43,.05);
  --shadow-md: 0 6px 18px rgba(34,31,43,.08), 0 14px 40px rgba(34,31,43,.06);
  --shadow-lg: 0 18px 50px rgba(34,31,43,.14);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;

  --ease: cubic-bezier(.16,1,.3,1);
  --spring: cubic-bezier(.34,1.56,.64,1);

  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* subtle film grain on the warm background */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,246,236,.82);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #FFA45C);
  box-shadow: 0 4px 12px rgba(255,107,44,.4);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px;
  border: 2.5px solid #fff; border-radius: 6px; border-top-color: transparent;
}
.brand-text { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -.01em; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.scorer-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--pos-bg); color: var(--pos);
  font-weight: 600; font-size: 13px;
  padding: 6px 12px; border-radius: var(--r-pill);
  text-decoration: none;
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.scorer-chip:hover { background: rgba(22,163,74,.18); transform: translateY(-1px); }
.scorer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); }
.muted-text { color: var(--muted); font-size: 13px; font-weight: 500; }

/* ---------------- Page layout ---------------- */
.page {
  position: relative; z-index: 1;
  max-width: 1080px; margin: 0 auto;
  padding: 28px 22px 80px;
  display: flex; flex-direction: column; gap: 26px;
}

/* ---------------- Hero ---------------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 30px 30px 26px;
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; top: -60px; right: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,44,.14), transparent 70%);
  pointer-events: none;
}
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand);
  margin-bottom: 18px;
}
.hero-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 34px; align-items: center;
}

/* score ring */
.score-ring {
  --pct: 0;
  --ring-color: var(--brand);
  width: 168px; height: 168px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), var(--bg-soft) 0);
  transition: background .9s var(--ease);
  position: relative;
}
/* tier-based ring colors */
.tier-perfect .score-ring { --ring-color: var(--tier-gold); }
.tier-good    .score-ring { --ring-color: var(--tier-green); }
.tier-warning .score-ring { --ring-color: var(--tier-amber); }
.tier-locked  .score-ring { --ring-color: var(--tier-red); }
.score-ring::before {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 2px 6px rgba(34,31,43,.06);
}
.score-ring-inner { position: absolute; inset: 12px; text-align: center; overflow: hidden; border-radius: 50%; display: grid; place-items: center; }
.score-number {
  font-family: var(--font-display); font-weight: 700;
  font-size: 52px; line-height: 1; letter-spacing: -.02em;
  color: var(--ink); display: block;
}
.score-of { font-size: 14px; color: var(--muted); font-weight: 600; }

/* Subject picture inside ring */
.subject-picture {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  display: block; position: absolute; inset: 0;
}
.score-badge {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  padding: 4px 14px; border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm); border: 2px solid var(--line);
  z-index: 2;
}
.tier-perfect .score-badge { border-color: var(--tier-gold); color: var(--tier-gold); }
.tier-good    .score-badge { border-color: var(--tier-green); color: var(--tier-green); }
.tier-warning .score-badge { border-color: var(--tier-amber); color: var(--tier-amber); }
.tier-locked  .score-badge { border-color: var(--tier-red); color: var(--tier-red); }

/* Picture upload button */
.pic-upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-soft); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; margin-top: 10px;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.pic-upload-btn:hover { background: rgba(255,107,44,.1); border-color: var(--brand); color: var(--brand); }
.pic-upload-btn.uploading { opacity: .5; pointer-events: none; }
.hero-cap-label { text-align: center; margin-top: 10px; font-size: 14px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.tier-perfect .hero-cap-label { color: var(--tier-gold); }
.tier-good    .hero-cap-label { color: var(--tier-green); }
.tier-warning .hero-cap-label { color: var(--tier-amber); }
.tier-locked  .hero-cap-label { color: var(--tier-red); }

.hero-meta { display: flex; flex-direction: column; gap: 16px; }

/* Monthly aggregate card */
.aggregate-card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 16px 18px;
}
.aggregate-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.aggregate-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.aggregate-tier { font-family: var(--font-display); font-weight: 600; font-size: 14px; padding: 3px 10px; border-radius: var(--r-pill); }
.tier-perfect .aggregate-tier { background: var(--tier-gold-bg); color: var(--tier-gold); }
.tier-good    .aggregate-tier { background: var(--tier-green-bg); color: var(--tier-green); }
.tier-warning .aggregate-tier { background: var(--tier-amber-bg); color: var(--tier-amber); }
.tier-locked  .aggregate-tier { background: var(--tier-red-bg); color: var(--tier-red); }
.aggregate-value { display: flex; align-items: baseline; gap: 4px; margin-bottom: 10px; }
.aggregate-num { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; color: var(--ink); }
.aggregate-possible { font-size: 16px; color: var(--muted); font-weight: 600; }
.aggregate-bar { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.aggregate-bar-fill {
  height: 100%; border-radius: var(--r-pill);
  background: var(--brand);
  transition: width .8s var(--ease), background .4s var(--ease);
}
.tier-perfect .aggregate-bar-fill { background: var(--tier-gold); }
.tier-good    .aggregate-bar-fill { background: var(--tier-green); }
.tier-warning .aggregate-bar-fill { background: var(--tier-amber); }
.tier-locked  .aggregate-bar-fill { background: var(--tier-red); }

.stat-row { display: flex; gap: 28px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.1; color: var(--ink); }
.stat-num.pos { color: var(--pos); }
.stat-num.neg { color: var(--neg); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Week pills */
.week-pills { display: flex; gap: 8px; }
.week-pill {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px; border-radius: var(--r-md);
  background: var(--bg-soft); border: 1px solid var(--line);
  transition: transform .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.week-pill.is-elapsed { background: var(--surface); }
.week-pill.is-current { border-color: var(--brand); border-width: 2px; box-shadow: 0 4px 12px rgba(255,107,44,.18); }
.week-pill-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.week-pill.is-current .week-pill-label { color: var(--brand); }
.week-pill-score { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--ink); }
.week-pill:not(.is-elapsed) .week-pill-score { color: var(--muted); }

/* privilege banner */
.privilege-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 18px; border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background .4s var(--ease), border-color .4s var(--ease), transform .4s var(--spring);
}
.privilege-banner.is-on { background: var(--pos-bg); border-color: rgba(22,163,74,.25); color: var(--pos); }
.privilege-banner.is-off { background: var(--neg-bg); border-color: rgba(226,55,84,.25); color: var(--neg); }
.privilege-banner.flash { transform: scale(1.03); }
.priv-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.6); }
.priv-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.priv-sub { font-size: 13px; color: var(--ink-soft); margin-top: 1px; }

/* ---------------- Panel ---------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.panel-head { margin-bottom: 18px; }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.panel-sub { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.panel-readonly { text-align: center; }
.panel-readonly .panel-sub { color: var(--muted); }

/* quick buttons */
.quick-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding-bottom: 18px; margin-bottom: 18px;
  border-bottom: 1px dashed var(--line);
}
.quick-btn {
  font-family: var(--font-display); font-weight: 600; font-size: 18px;
  width: 56px; height: 56px; border-radius: 16px;
  border: 1px solid transparent; cursor: pointer;
  display: grid; place-items: center;
  transition: transform .18s var(--spring), box-shadow .18s var(--ease), background .18s var(--ease);
  user-select: none;
}
.quick-btn.pos { background: var(--pos-bg); color: var(--pos); border-color: rgba(22,163,74,.2); }
.quick-btn.neg { background: var(--neg-bg); color: var(--neg); border-color: rgba(226,55,84,.2); }
.quick-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.quick-btn:active { transform: translateY(0) scale(.94); }
.quick-btn.pos:hover { background: var(--pos); color: #fff; box-shadow: 0 8px 18px rgba(22,163,74,.35); }
.quick-btn.neg:hover { background: var(--neg); color: #fff; box-shadow: 0 8px 18px rgba(226,55,84,.35); }
.quick-divider { width: 1px; height: 36px; background: var(--line); margin: 0 4px; }

/* manual form */
.manual-form { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.manual-points { display: flex; align-items: center; gap: 6px; }
.step-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 20px; font-weight: 700; color: var(--ink); cursor: pointer;
  transition: transform .15s var(--spring), background .15s var(--ease);
}
.step-btn:hover { background: var(--line); }
.step-btn:active { transform: scale(.9); }
.step-btn:disabled { opacity: .35; cursor: not-allowed; }
.step-btn:disabled:hover { background: var(--bg-soft); }
.manual-points input {
  width: 72px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 18px;
  color: var(--ink);
}
.manual-points input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.manual-comment {
  height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px;
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.manual-comment:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,107,44,.18); }

/* ---------------- Buttons ---------------- */
.btn {
  font-family: var(--font-body); font-weight: 700; font-size: 14px;
  border: none; cursor: pointer; border-radius: var(--r-pill);
  padding: 12px 22px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s var(--spring), box-shadow .18s var(--ease), background .15s var(--ease);
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(255,107,44,.35); }
.btn-primary:hover { background: var(--brand-dk); box-shadow: 0 10px 22px rgba(255,107,44,.45); transform: translateY(-2px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- History ---------------- */
.history { display: flex; flex-direction: column; gap: 14px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; }
.entry-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.entry {
  display: grid; grid-template-columns: 64px 1fr auto;
  gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  animation: entryIn .45s var(--spring) both;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.entry:hover { transform: translateX(2px); box-shadow: var(--shadow-md); }
@keyframes entryIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.entry-points {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  text-align: center; line-height: 1; padding: 10px 0;
  border-radius: 12px; min-width: 56px;
}
.entry-points.pos { background: var(--pos-bg); color: var(--pos); }
.entry-points.neg { background: var(--neg-bg); color: var(--neg); }
.entry-body { min-width: 0; }
.entry-comment { font-size: 15px; color: var(--ink); font-weight: 500; word-break: break-word; }
.entry-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); display: inline-block; }
.tag-baseline, .tag-fixed {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-pill);
}
.tag-baseline { background: var(--bg-soft); color: var(--ink-soft); }
.tag-fixed { background: rgba(255,107,44,.12); color: var(--brand-dk); }
.entry.is-baseline { background: var(--bg-soft); border-style: dashed; }
.entry-del {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: background .15s var(--ease), color .15s var(--ease);
}
.entry-del:hover { background: var(--neg-bg); color: var(--neg); }
.entry-empty { text-align: center; color: var(--muted); padding: 30px; font-size: 14px; }

/* ---------------- Toasts ---------------- */
.toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink); color: #fff;
  padding: 13px 20px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .4s var(--spring) both;
}
.toast.pos { background: var(--pos); }
.toast.neg { background: var(--neg); }
.toast.out { animation: toastOut .35s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px) scale(.9); } }

/* ---------------- Confetti ---------------- */
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

/* ---------------- Footer ---------------- */
.foot { text-align: center; color: var(--muted); font-size: 13px; padding-top: 20px; }

/* ---------------- Auth page ---------------- */
.auth-body {
  min-height: 100dvh; display: grid; place-items: center;
  background: radial-gradient(120% 80% at 50% 0%, #FFE7CF, var(--bg) 60%);
  padding: 24px;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  animation: cardIn .6s var(--spring) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
.auth-emoji { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand); background: rgba(255,107,44,.12);
  padding: 6px 14px; border-radius: var(--r-pill);
}
.auth-title { font-family: var(--font-display); font-weight: 700; font-size: 28px; text-align: center; letter-spacing: -.01em; }
.auth-sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin-top: 6px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input {
  height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,107,44,.18); }
.auth-error {
  background: var(--neg-bg); color: var(--neg);
  font-size: 13px; font-weight: 600; text-align: center;
  padding: 10px 14px; border-radius: 12px;
}
.auth-error[hidden] { display: none; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* score number pop animation when it changes */
.score-number.bump { animation: bump .5s var(--spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); color: var(--brand); } 100% { transform: scale(1); } }
.score-number.bump-neg { animation: bumpNeg .5s var(--spring); }
@keyframes bumpNeg { 0% { transform: scale(1); } 40% { transform: scale(1.12); color: var(--neg); } 100% { transform: scale(1); } }

/* shake for negative quick action */
.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 760px) {
  .hero { padding: 22px 18px; }
  .hero-grid { grid-template-columns: 1fr; gap: 22px; justify-items: center; text-align: center; }
  .hero-meta { width: 100%; align-items: stretch; }
  .stat-row { justify-content: center; gap: 22px; }
  .manual-form { grid-template-columns: 1fr; gap: 10px; }
  .manual-points { justify-content: center; }
  .entry { grid-template-columns: 52px 1fr auto; padding: 12px; gap: 10px; }
  .topbar-inner { padding: 12px 16px; }
  .page { padding: 20px 16px 60px; }
  .quick-btn { width: 50px; height: 50px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------------- Rule book ---------------- */
.rulebook {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.rulebook-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.rule-list { list-style: none; display: flex; flex-direction: column; gap: 10px; counter-reset: rule; }
.rule-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-soft); border: 1px solid var(--line);
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.rule-item:hover { transform: translateX(3px); border-color: var(--brand); }
.rule-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  display: grid; place-items: center;
  box-shadow: 0 3px 8px rgba(255,107,44,.3);
}
.rule-text { font-size: 15px; color: var(--ink); font-weight: 500; line-height: 1.5; padding-top: 4px; flex: 1; min-width: 0; }
.rule-actions { display: flex; gap: 4px; flex: none; opacity: 0; transition: opacity .15s var(--ease); }
.rule-item:hover .rule-actions { opacity: 1; }
.rule-edit, .rule-del {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.rule-edit:hover { background: rgba(255,107,44,.12); color: var(--brand); }
.rule-del:hover { background: var(--neg-bg); color: var(--neg); }
.rule-empty { text-align: center; color: var(--muted); padding: 24px; font-size: 15px; }

/* Add rule input */
.rule-add { display: flex; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.rule-input {
  flex: 1; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.rule-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,107,44,.18); }

/* Modal confirm text */
.modal-confirm-text { font-size: 15px; color: var(--ink-soft); line-height: 1.5; text-align: center; padding: 8px 0; }
.modal-foot .btn-primary { background: var(--brand); box-shadow: 0 6px 16px rgba(255,107,44,.35); }
#ruleDelModal .modal-foot .btn-primary { background: var(--neg); box-shadow: 0 6px 16px rgba(226,55,84,.35); }
#ruleDelModal .modal-foot .btn-primary:hover { background: #C92E48; }

/* Rule link card (on dashboard) */
.rule-link-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--ink);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.rule-link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand); }
.rule-link-icon {
  flex: none; width: 48px; height: 48px; border-radius: 14px;
  background: rgba(255,107,44,.12); color: var(--brand);
  display: grid; place-items: center;
}
.rule-link-body { flex: 1; min-width: 0; }
.rule-link-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.rule-link-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.rule-link-arrow { color: var(--muted); transition: transform .2s var(--ease), color .2s var(--ease); }
.rule-link-card:hover .rule-link-arrow { transform: translateX(4px); color: var(--brand); }

/* Rules page */
.page-narrow { max-width: 720px; }
.rulebook-page { padding: 32px 30px; }
.rulebook-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }

/* ---------------- At-max note ---------------- */
.at-max-note {
  text-align: center; font-size: 13px; color: var(--tier-gold);
  background: var(--tier-gold-bg); padding: 10px 16px; border-radius: var(--r-md);
  margin-bottom: 16px; font-weight: 600;
}

/* ---------------- Disabled quick buttons ---------------- */
.quick-btn:disabled, .quick-btn[disabled] {
  opacity: .35; cursor: not-allowed; transform: none !important; box-shadow: none !important;
}
.quick-btn:disabled:hover { background: var(--pos-bg); color: var(--pos); transform: none !important; box-shadow: none !important; }

/* ---------------- Modal (deduction report) ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(34,31,43,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
  animation: overlayIn .25s var(--ease);
}
.modal-overlay[hidden] { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn .4s var(--spring);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(.95); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.modal-close {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--bg-soft); color: var(--ink-soft); cursor: pointer;
  display: grid; place-items: center; transition: background .15s var(--ease);
}
.modal-close:hover { background: var(--neg-bg); color: var(--neg); }
.modal-body { padding: 18px 24px 20px; }
.modal-points-display {
  font-family: var(--font-display); font-weight: 700; font-size: 36px;
  color: var(--neg); text-align: center; margin-bottom: 18px;
  padding: 14px; border-radius: var(--r-md); background: var(--neg-bg);
}
.modal-comment-input {
  width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.modal-comment-input:focus { outline: none; border-color: var(--neg); box-shadow: 0 0 0 3px rgba(226,55,84,.18); }
.modal-foot { display: flex; gap: 10px; padding: 0 24px 24px; justify-content: flex-end; }
.modal-foot .btn-primary { background: var(--neg); box-shadow: 0 6px 16px rgba(226,55,84,.35); }
.modal-foot .btn-primary:hover { background: #C92E48; box-shadow: 0 10px 22px rgba(226,55,84,.45); transform: translateY(-2px); }
.modal-foot .btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------------- Profile page ---------------- */
.profile-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 30px;
  box-shadow: var(--shadow-sm);
}
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.profile-avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(255,107,44,.3);
}
.profile-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.profile-sub { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }
.profile-form { display: flex; flex-direction: column; gap: 18px; }
.profile-form .field { display: flex; flex-direction: column; gap: 6px; }
.profile-form input {
  height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.profile-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255,107,44,.18); }
.profile-form input:disabled { background: var(--bg-soft); color: var(--muted); cursor: not-allowed; }
.field-locked { font-size: 12px; color: var(--muted); font-weight: 500; }
.profile-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.profile-msg { font-size: 14px; font-weight: 600; }
.profile-msg.pos { color: var(--pos); }
.profile-msg.neg { color: var(--neg); }

/* ---------------- Admin page ---------------- */
.admin-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 28px 26px;
  box-shadow: var(--shadow-sm);
}
.admin-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.admin-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-soft); border: 1px solid var(--line);
  transition: border-color .15s var(--ease);
}
.admin-row.is-admin { border-color: var(--brand); background: rgba(255,107,44,.05); }
.admin-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  display: grid; place-items: center;
}
.admin-row.is-admin .admin-avatar { background: var(--tier-gold); }
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--tier-gold-bg); color: var(--tier-gold);
}
.admin-badge.you { background: var(--pos-bg); color: var(--pos); }
.admin-meta { font-size: 13px; color: var(--ink-soft); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-actions { display: flex; gap: 6px; flex: none; }
.admin-toggle {
  padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s var(--ease);
}
.admin-toggle:hover { border-color: var(--brand); color: var(--brand); }
.admin-delete {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: all .15s var(--ease);
}
.admin-delete:hover { background: var(--neg-bg); color: var(--neg); border-color: var(--neg); }
