:root {
  --blue: #38B6D9;
  --blue-deep: #0E7490;
  --blue-dark: #0B5A72;
  --bg: #EFF9FD;
  --ink: #0F3B49;
  --ink-soft: #4E7E8E;
  --ink-mute: #6B93A1;
  --pale: #E4F5FB;
  --line: #E8F4F9;
  --amber: #B26B16;
  --amber-pale: #FDF0DF;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Zen Maru Gothic', system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: url('img/pattern-tile.svg');
  background-repeat: repeat;
  background-size: 400px 400px;
}

.screen {
  max-width: 430px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- ヘッダー ---- */
.head { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 46px; height: 46px; border-radius: 23px; flex-shrink: 0;
  background: #fff; border: 1px solid #CFEAF4;
  display: flex; align-items: center; justify-content: center;
}
.title { flex-grow: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hello { font-size: 11px; font-weight: 500; color: var(--ink-soft); }
.title h1 { margin: 0; font-size: 18px; font-weight: 900; }
.who {
  flex-shrink: 0; font-size: 12px; font-weight: 700; color: #fff;
  background: var(--blue-deep); border-radius: 16px; padding: 9px 14px;
}

/* ---- カード ---- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 1px 2px rgba(14,116,144,.05), 0 10px 26px rgba(14,116,144,.10);
}
.level-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.level-row { display: flex; align-items: center; justify-content: space-between; }

.badge {
  width: 128px; height: 128px; border-radius: 64px; flex-shrink: 0;
  background: var(--pale); border: 5px solid var(--blue);
  box-shadow: 0 0 0 7px rgba(56,182,217,.13);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.badge span { font-size: 13px; font-weight: 700; color: #3C7C90; letter-spacing: .08em; }
.badge strong { font-size: 60px; font-weight: 900; line-height: 1; color: var(--blue-dark); }
.badge.big { width: 132px; height: 132px; border-width: 6px; box-shadow: none; }
.badge.big strong { font-size: 64px; }

.violin { flex-shrink: 0; }

.meter-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cap { font-size: 11px; font-weight: 700; color: #3C7C90; }
.cap.sub { font-size: 10px; font-weight: 500; color: var(--ink-mute); }
.meter {
  position: relative; width: 46px; height: 140px; overflow: hidden;
  background: var(--pale); border: 2px solid #CFEAF4;
}
.meter .fill {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0;
  background: var(--blue); transition: height .55s cubic-bezier(.25,.8,.3,1);
}
.meter .pnum {
  position: absolute; left: 0; width: 100%; bottom: 4px; text-align: center;
  font-size: 11px; font-weight: 900; color: #06374A;
  transition: bottom .55s cubic-bezier(.25,.8,.3,1);
}
.meter .pnum.out { color: var(--blue-deep); }
.meter .tick { position: absolute; left: 0; width: 100%; height: 1px; background: rgba(11,90,114,.16); }
.tick-a { top: 45px; }
.tick-b { top: 90px; }

.gain {
  position: absolute; top: -10px; left: 50%; white-space: nowrap;
  font-size: 19px; font-weight: 900; color: var(--blue-deep);
  opacity: 0; pointer-events: none;
}
.gain.show { animation: float-up 1.1s ease-out forwards; }
@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, 12px) scale(.8); }
  25%  { opacity: 1; transform: translate(-50%, -2px) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(1); }
}

.next {
  margin: 0; background: var(--pale); border-radius: 14px; padding: 10px 14px;
  text-align: center; font-size: 13px; font-weight: 500; color: #23606F;
}
.next b { font-size: 15px; font-weight: 900; color: var(--blue-dark); }

/* ---- 一覧 ---- */
.block { display: flex; flex-direction: column; gap: 8px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.sec-head h2 { margin: 0; font-size: 14px; font-weight: 700; color: #23606F; }
.sec-head span { font-size: 11px; font-weight: 500; color: var(--ink-mute); }

.list { padding: 4px 10px; display: flex; flex-direction: column; }

.row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 16px 4px; border: none; border-bottom: 1px solid #EAF4F8;
  background: transparent; border-radius: 10px; text-align: left;
  font-family: inherit; color: inherit; cursor: pointer;
  transition: transform .08s ease-out, background .15s ease-out;
}
.row:active { transform: scale(.975); background: var(--pale); }
.row:disabled { opacity: .5; }
.row .name { flex-grow: 1; font-size: 15px; font-weight: 500; }
.ico {
  width: 32px; height: 32px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ico.blue { background: var(--pale); }
.ico.amber { background: var(--amber-pale); }
.ico.white { background: #fff; }
.pt {
  flex-shrink: 0; font-size: 13px; font-weight: 900; color: #fff;
  background: var(--blue-deep); border-radius: 12px; padding: 3px 10px;
}
.pt.amber-bg { background: var(--amber); }
.pt.soft { background: #D7EEF7; color: var(--blue-deep); }

.bonus {
  display: flex; align-items: center; gap: 11px;
  margin: 6px 0 4px; padding: 12px 8px;
  background: #F2FAFD; border-radius: 14px;
}
.bonus-text { flex-grow: 1; display: flex; flex-direction: column; gap: 5px; }
.bonus-text .name { font-size: 15px; font-weight: 500; }
.sub { font-size: 10px; font-weight: 500; color: #7EA0AC; }
.bonus-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.bonus-right .sub { font-weight: 700; color: var(--ink-mute); }
.dots { display: flex; gap: 5px; }
.dots i { width: 11px; height: 11px; border-radius: 6px; background: #D7E9F0; }
.dots i.on { background: var(--blue); }

/* ---- きょうの記録 ---- */
.log { padding: 6px 12px; display: flex; flex-direction: column; }
.log .empty { margin: 0; padding: 16px 4px; font-size: 13px; font-weight: 500; color: #7EA0AC; }
.item { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid #F1F8FB; }
.item:last-child { border-bottom: none; }
.item .time { width: 33px; flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--ink-mute); }
.item .tag {
  flex-shrink: 0; font-size: 10px; font-weight: 700; color: var(--blue-deep);
  background: var(--pale); border-radius: 9px; padding: 3px 8px;
}
.item .tag.auto { background: #F4F1E6; color: var(--amber); }
.item .what { flex-grow: 1; font-size: 13px; font-weight: 500; }
.item .val { flex-shrink: 0; font-size: 13px; font-weight: 900; color: var(--blue-deep); }
.undo {
  width: 38px; height: 38px; border-radius: 19px; flex-shrink: 0;
  border: 1px solid #E2EEF3; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease-out, background .15s ease-out;
}
.undo:active { transform: scale(.94); background: var(--pale); }

/* ---- レベルアップ演出 ---- */
.celebrate { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.celebrate .veil { position: absolute; inset: 0; background: rgba(6,55,74,.28); }
.cheer {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(330px, 86vw); background: #fff; border-radius: 28px; padding: 26px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 14px 34px rgba(6,55,74,.25);
  animation: pop .6s cubic-bezier(.22,.9,.3,1.1) both;
}
@keyframes pop {
  0%   { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  55%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.cheer-title { font-size: 24px; font-weight: 900; color: var(--blue-deep); }
.cheer-sub { font-size: 14px; font-weight: 500; color: #23606F; }

.confetti { position: absolute; inset: 0; overflow: hidden; }
.confetti span { position: absolute; bottom: -30px; animation: rise 2.4s cubic-bezier(.15,.6,.35,1) forwards; }
.confetti span i { display: block; animation: sway 1.1s ease-in-out infinite alternate; }
@keyframes rise {
  0%   { transform: translateY(0); opacity: 0; }
  8%   { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(-105vh); opacity: 0; }
}
@keyframes sway {
  from { transform: translateX(-24px) rotate(-150deg); }
  to   { transform: translateX(24px) rotate(190deg); }
}

/* ---- お知らせ ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--blue-dark); color: #fff; font-size: 13px; font-weight: 700;
  padding: 12px 18px; border-radius: 20px; z-index: 60;
  box-shadow: 0 8px 20px rgba(6,55,74,.25);
}
