:root {
  --bg: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.55);
  --gold: #FFD700;
  --gold-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  --green: #00E676;
  --orange: #FF9100;
  --red: #FF5252;
  --blue: #4FC3F7;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --t: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  overscroll-behavior: none;
}

/* ===== CARD ===== */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px; border-radius: 50px; border: none;
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: var(--t); font-family: inherit; letter-spacing: 0.3px;
  -webkit-appearance: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gold-gradient); color: #1a1a1a;
}
.btn-primary:hover { box-shadow: 0 8px 25px rgba(246, 211, 101, 0.45); transform: translateY(-2px); }

.btn-success { background: rgba(0,230,118,0.15); border: 1.5px solid var(--green); color: var(--green); }
.btn-danger  { background: rgba(255,82,82,0.15);  border: 1.5px solid var(--red);   color: var(--red); }
.btn-ghost   { background: var(--card); border: 1px solid var(--card-border); color: var(--text); }
.btn-sm      { padding: 8px 18px; font-size: 14px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 50px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-easy   { background: rgba(0,230,118,0.15); color: var(--green);  border: 1px solid rgba(0,230,118,0.3); }
.badge-medium { background: rgba(255,195,0,0.15);  color: #FFC300;       border: 1px solid rgba(255,195,0,0.3); }
.badge-hard   { background: rgba(255,82,82,0.15);  color: var(--red);    border: 1px solid rgba(255,82,82,0.3); }
.badge-pending  { background: rgba(255,145,0,0.15);   color: var(--orange); }
.badge-approved { background: rgba(0,230,118,0.15);   color: var(--green); }
.badge-rejected { background: rgba(255,82,82,0.15);   color: var(--red); }
.badge-bonus    { background: rgba(255,215,0,0.15);   color: var(--gold); }

/* ===== PROGRESS RING ===== */
.ring-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto; }
.ring-svg  { transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 14; }
.ring-fill {
  fill: none; stroke: url(#goldGrad); stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }

/* ===== MODAL (bottom sheet) ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-sheet {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: #1c1b3a; border-radius: 28px 28px 0 0;
  padding: 20px 20px 40px; border: 1px solid rgba(255,255,255,0.08);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; margin: 0 auto 20px; }

/* ===== FORM ===== */
input, textarea, select {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-sm); color: var(--text); padding: 12px 16px;
  font-size: 16px; font-family: inherit; width: 100%; transition: var(--t);
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); background: rgba(255,215,0,0.05); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: #1c1b3a; color: var(--text); }
label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.form-group { margin-bottom: 16px; }

/* ===== DATE CHIPS （いつのお手伝いかを選ぶ） ===== */
.date-chips { display: flex; gap: 8px; margin-bottom: 10px; }
.date-chip {
  flex: 1; padding: 10px 8px; border-radius: var(--radius-sm); cursor: pointer;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  color: var(--text); font-size: 14px; font-weight: 700; font-family: inherit;
  transition: var(--t); -webkit-appearance: none;
}
.date-chip.active {
  background: rgba(255,215,0,0.14); border-color: var(--gold); color: var(--gold);
}
/* 日付ピッカーは「その他の日」を選んだときだけ出す */
.date-picker-wrap { display: none; }
.date-picker-wrap.show { display: block; }
/* 過去日を選んでいるときの注意書き */
.date-note {
  font-size: 12px; color: var(--gold); margin-top: 8px;
  background: rgba(255,215,0,0.08); border-radius: var(--radius-sm); padding: 8px 10px;
}

/* ===== TABS ===== */
.tabs {
  display: flex; gap: 4px; background: rgba(255,255,255,0.05);
  border-radius: 50px; padding: 4px; margin-bottom: 20px;
}
.tab-btn {
  flex: 1; padding: 10px 8px; border-radius: 50px; border: none;
  background: transparent; color: var(--text-muted);
  font-size: 13px; font-family: inherit; font-weight: 700; cursor: pointer; transition: var(--t);
}
.tab-btn.active { background: rgba(255,255,255,0.13); color: var(--text); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(20,20,50,0.95); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50px; padding: 12px 28px; font-size: 14px; font-weight: 700;
  backdrop-filter: blur(20px); z-index: 300; transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: var(--red); }
.toast.info    { border-color: var(--blue); color: var(--blue); }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes fireShake {
  0%,100% { transform: rotate(-5deg); }
  50%      { transform: rotate(5deg); }
}
.fade-up { animation: fadeUp 0.4s ease forwards; opacity: 0; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* ===== PHOTO UPLOAD AREA ===== */
.photo-upload {
  border: 2px dashed rgba(255,255,255,0.2); border-radius: var(--radius);
  min-height: 160px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; cursor: pointer; transition: var(--t);
  position: relative; overflow: hidden;
}
.photo-upload:hover, .photo-upload.has-photo { border-color: var(--gold); }
.photo-upload input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-upload img { width: 100%; height: 200px; object-fit: cover; border-radius: 14px; }
.photo-upload .upload-icon { font-size: 40px; }
.photo-upload .upload-label { font-size: 14px; color: var(--text-muted); }

/* ===== WORK CARD ===== */
.work-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 16px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px; cursor: pointer; transition: var(--t);
}
.work-card:hover, .work-card:active { background: rgba(255,255,255,0.1); transform: translateX(3px); }
.work-card .work-icon { font-size: 28px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(255,255,255,0.07); flex-shrink: 0; }
.work-card .work-info { flex: 1; min-width: 0; }
.work-card .work-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.work-card .work-desc { font-size: 12px; color: var(--text-muted); }
.work-card .work-amount { font-size: 20px; font-weight: 800; color: var(--gold); white-space: nowrap; }

/* ===== SUBMISSION CARD ===== */
.sub-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: 16px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 8px;
}
.sub-card .sub-photo { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: rgba(255,255,255,0.07); }
.sub-card .sub-info { flex: 1; min-width: 0; }
.sub-card .sub-name { font-weight: 700; font-size: 14px; }
.sub-card .sub-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.sub-card .sub-amount { font-weight: 800; font-size: 16px; color: var(--gold); white-space: nowrap; }

/* ===== SECTION HEADER ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 16px; font-weight: 800; }

/* ===== CHARACTER CARD ===== */
.char-card {
  margin: 16px 20px 0;
  padding: 20px 20px 16px;
  border-radius: 22px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
}
.char-img {
  width: 120px; height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
  animation: pop 0.5s ease;
  display: block; margin: 0 auto;
}
.char-fallback {
  font-size: 80px; line-height: 1;
  display: block; text-align: center;
  margin: 10px auto 10px;
  animation: pop 0.5s ease;
}
.char-title    { font-size: 17px; font-weight: 900; text-align: center; margin-top: 8px; }
.char-subtitle { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 3px; }
.char-stats { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.char-stat-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.char-stat-label { width: 72px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.char-stat-bar-wrap { flex: 1; height: 7px; background: rgba(255,255,255,0.1); border-radius: 50px; overflow: hidden; }
.char-stat-bar-fill { height: 100%; border-radius: 50px; transition: width 1.2s cubic-bezier(0.4,0,0.2,1); }
.char-stat-val { width: 58px; font-size: 11px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.char-next { margin-top: 11px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* 集計対象年の表示（キャラは毎年1/1にリセットされる） */
.char-year {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-align: center; margin-bottom: 10px; letter-spacing: 0.02em;
}
/* 我慢力の内訳（キープ分＋我慢ボーナス）を説明する小さい注記 */
.char-hint {
  margin-top: 10px; padding: 8px 11px;
  border-radius: 12px;
  background: rgba(79,195,247,0.09);
  border: 1px solid rgba(79,195,247,0.18);
  font-size: 11px; line-height: 1.6; color: var(--text-muted);
}
.char-hint b { color: var(--text); }
/* 過去年の最終キャラ（殿堂） */
.char-hof { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.10); }
.char-hof-title { font-size: 12px; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
.char-hof-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 12px;
  background: rgba(255,255,255,0.04);
}
.char-hof-row + .char-hof-row { margin-top: 6px; }
.char-hof-img { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }

/* 「📖 キャラのルール」ボタン */
.char-rules-btn {
  display: block; width: 100%; margin-top: 12px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-muted);
  font-size: 12px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: var(--t);
}
.char-rules-btn:active { transform: scale(0.97); background: rgba(255,255,255,0.11); }

/* ===== キャラのルール説明（子ども向けモーダル） ===== */
.rule-sec { margin-bottom: 20px; }
.rule-h {
  font-size: 14px; font-weight: 800; margin-bottom: 9px;
  color: var(--gold);
}
.rule-p { font-size: 13px; line-height: 1.75; color: var(--text-muted); }
.rule-p b, .rule-ul b, .rule-ol b, .rule-item b { color: var(--text); }
.rule-item {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 9px 11px; border-radius: 13px;
  background: rgba(255,255,255,0.04);
  font-size: 13px; line-height: 1.6; color: var(--text-muted);
}
.rule-item + .rule-item { margin-top: 7px; }
.rule-ico { font-size: 22px; line-height: 1.2; flex-shrink: 0; }
.rule-formula {
  padding: 12px 14px; border-radius: 14px;
  background: rgba(79,195,247,0.10);
  border: 1px solid rgba(79,195,247,0.22);
  font-size: 13px; line-height: 1.9; font-weight: 700;
  color: var(--text);
}
.rule-ul, .rule-ol {
  margin: 10px 0 0; padding-left: 1.25em;
  font-size: 13px; line-height: 1.75; color: var(--text-muted);
}
.rule-ul li + li, .rule-ol li + li { margin-top: 5px; }
/* 表は幅が足りないときだけ横スクロールする */
.rule-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rule-table {
  border-collapse: collapse; width: 100%; min-width: 340px;
  font-size: 12px;
}
.rule-table th, .rule-table td {
  padding: 7px 6px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rule-table thead th { color: var(--gold); font-size: 11px; font-weight: 800; }
.rule-table tbody th {
  text-align: left; white-space: nowrap;
  color: var(--text-muted); font-size: 11px; font-weight: 700;
  padding-right: 10px;
}
.rule-table td { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.rule-summary {
  padding: 14px; border-radius: 16px;
  background: rgba(255,215,0,0.07);
  border: 1px solid rgba(255,215,0,0.18);
}
.rule-summary .rule-h { margin-bottom: 4px; }
.rule-warn {
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid rgba(255,215,0,0.18);
  font-size: 12px; line-height: 1.7; color: var(--text-muted);
}
.rule-warn b { color: var(--text); }

/* Level-up modal — center overlay (not bottom sheet) */
.modal-overlay.lvup {
  align-items: center; justify-content: center;
}
.modal-overlay.lvup .modal-sheet {
  width: calc(100% - 48px); max-width: 360px;
  border-radius: 28px;
  transform: scale(0.7);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center; padding: 36px 24px 32px;
}
.modal-overlay.lvup.show .modal-sheet { transform: scale(1); }

@keyframes starSpin {
  0%   { transform: scale(0) rotate(0deg); opacity: 1; }
  100% { transform: scale(2.5) rotate(720deg); opacity: 0; }
}
.lvup-star {
  position: absolute; font-size: 22px; pointer-events: none;
  animation: starSpin 0.9s ease-out forwards;
}

/* ===== LAYOUT ===== */
.page-container { max-width: 500px; margin: 0 auto; padding: 0 0 80px; }

/* ===== SEARCH（リアルタイム検索） ===== */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-left: 42px; padding-right: 42px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 16px; opacity: .7; pointer-events: none; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,0.12); color: var(--text); font-size: 13px;
  display: none; align-items: center; justify-content: center;
}
.search-clear.show { display: flex; }
.search-count { font-size: 12px; color: var(--text-muted); margin: -4px 0 10px 4px; }
mark.search-hit { background: rgba(255,215,0,0.35); color: inherit; border-radius: 3px; padding: 0 1px; }
