:root {
  --bg: #eaf7f4; --card: #fff; --ink: #1f3d47; --sub: #6d8790; --line: #d5ebe6;
  --main: #17a398; --main-d: #0f7f76; --gold: #ffc93c; --gold-d: #e0a100;
  --coral: #ff6f61; --coral-d: #d9503f; --ok: #2aa86b; --ng: #e5484d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Rounded Mplus 1c", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5;
  user-select: none; -webkit-user-select: none;
}
#root { max-width: 520px; height: 100%; margin: 0 auto; display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 700; background: none; }
button:disabled { opacity: .4; }
ul { list-style: none; margin: 0; padding: 0; }
h2, h3 { margin: 0; }
small { font-size: .78rem; }
.sub { color: var(--sub); font-size: .8rem; margin: 2px 0 12px; }
.scroll { flex: 1; overflow-y: auto; padding: 12px 14px 28px; -webkit-overflow-scrolling: touch; }
.bigem { font-size: 64px; line-height: 1.1; }

.primary { background: linear-gradient(#ffd761, var(--gold)); color: #4a3200; padding: 12px 26px; box-shadow: 0 4px 0 var(--gold-d); }
.primary:active, .go:active, .open:active { transform: translateY(3px); box-shadow: none; }
.primary.big { font-size: 1.4rem; padding: 16px 56px; }
.ghost { background: #e6f3f0; color: var(--main-d); flex: none; }
.ok { background: var(--ok); color: #fff; flex: none; }
.ok.soft { background: #e3f5ea; color: #1c7a4c; }
.ng { background: #fde8e8; color: var(--ng); flex: none; }
.dashed { width: 100%; border: 2px dashed #b9d8d2; border-radius: 16px; color: var(--main-d); padding: 14px; margin-top: 10px; background: rgba(255,255,255,.5); }
.pill { background: #fff; border-radius: 99px; padding: 4px 12px; font-size: .8rem; font-weight: 700; color: var(--coral-d); flex: none; }
.av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; padding: 0; }
.bar { height: 10px; background: #e8f0ee; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .5s; }
.bar.pink i { background: var(--coral); }

/* タイトル */
.title { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px;
  background: radial-gradient(circle at 50% 30%, #fff8d9, transparent 60%), linear-gradient(#a7e8df, #eaf7f4); }
.logo { font-size: 3rem; font-weight: 900; line-height: 1.15; text-align: center; color: var(--coral);
  text-shadow: 0 3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 -3px 0 #fff, 0 7px 0 rgba(0,0,0,.12); transform: rotate(-3deg); }
.logo small { display: block; font-size: 1rem; color: var(--main-d); text-shadow: none; margin-bottom: 6px; }
.pig { width: 190px; display: block; margin: 0 auto; animation: bob 2.6s ease-in-out infinite; }
.pig .coin { animation: drop 2.6s ease-in infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes drop { 0%, 55% { transform: translateY(-6px); opacity: 1; } 85% { transform: translateY(30px); opacity: 1; } 86%, 100% { transform: translateY(30px); opacity: 0; } }

/* はじめの設定 */
.setup { background: #fbf9f2; display: flex; flex-direction: column; padding-top: calc(16px + env(safe-area-inset-top)); }
.dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: #ddd; }
.dots i.on { width: 26px; background: var(--gold); }
.welcome { text-align: center; padding: 20px 8px; }
.welcome p { color: var(--sub); font-size: .92rem; }
.nav { display: flex; gap: 10px; margin-top: auto; padding-top: 24px; }
.nav .primary { flex: 1; }

/* 行リスト */
.rows { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.row .em { font-size: 26px; width: 36px; text-align: center; flex: none; }
.body { flex: 1; min-width: 0; }
.body b { display: block; }
.body small { color: var(--sub); display: block; }
.price { font-weight: 700; color: var(--gold-d); flex: none; }
.price.pay { color: var(--ng); }
.empty { text-align: center; color: var(--sub); padding: 20px; font-size: .9rem; grid-column: 1 / -1; }

/* こども画面 */
.app { background: linear-gradient(#fff3c9, var(--bg) 220px); }
.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; }
.top b { flex: 1; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top.plain { background: #fff; }
.lock { width: 40px; height: 40px; padding: 0; background: #fff; border: 1.5px solid var(--line); font-size: 18px; flex: none; }
.card { background: var(--card); border-radius: 22px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 2px 0 var(--line); }
.card .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card .hd b { flex: 1; }
.card .hd small { font-weight: 700; color: var(--sub); }
.bank { text-align: center; }
.bank > small { color: var(--sub); display: block; margin-top: 4px; }
.bal { font-size: 3rem; font-weight: 900; line-height: 1.1; }
.bal small { font-size: 1.1rem; margin-left: 4px; }
.goal { margin-top: 10px; text-align: left; }
.goal small { display: block; margin-bottom: 4px; font-weight: 700; color: var(--main-d); }
.streak { display: inline-block; margin-top: 10px; background: #fff0e0; color: #c65a00; font-weight: 700; font-size: .8rem; padding: 3px 12px; border-radius: 99px; }
.pals { background: linear-gradient(135deg, #ffe3e0, #fff3d1); }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: rgba(255,255,255,.75); border-radius: 16px; padding: 10px; }
.slots span { font-size: 34px; text-align: center; line-height: 1.3; }
.slots .q { background: #f1e9dc; color: #b9aa93; border-radius: 12px; font-size: 20px; font-weight: 700; line-height: 44px; }
.prog { background: rgba(255,255,255,.75); border-radius: 14px; padding: 8px 12px; margin-top: 8px; }
.prog small { display: block; margin-bottom: 4px; color: var(--sub); font-weight: 700; }
.open { width: 100%; margin-top: 10px; background: linear-gradient(#ffd761, var(--gold)); color: #4a3200; font-size: 1.1rem; padding: 13px; box-shadow: 0 4px 0 var(--gold-d); position: relative; animation: pulse 1.4s infinite; }
.open .cnt { position: absolute; left: 14px; top: -8px; background: var(--ng); color: #fff; font-size: .75rem; padding: 1px 8px; border-radius: 99px; }
@keyframes pulse { 50% { filter: brightness(1.12); } }
.luckyrow { display: flex; align-items: center; gap: 10px; border-top: 1.5px solid var(--line); margin-top: 6px; padding-top: 10px; }
.luckyrow .em { font-size: 28px; }
.luckyrow span:nth-child(2) { flex: 1; }
.luckyrow small { display: block; color: var(--sub); }
.luckyrow .pill { background: #ffe9e6; }
.lvrow { display: flex; align-items: center; gap: 12px; }
.medal { width: 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold)); border: 3px solid var(--gold-d); display: grid; place-content: center; text-align: center; font-size: .6rem; font-weight: 700; line-height: 1; color: #6b4a00; flex: none; }
.medal b { display: block; font-size: 1.3rem; }
.lvrow .bar { margin: 4px 0; }
.linkrow { display: flex; justify-content: space-between; width: 100%; border-top: 1.5px solid var(--line); border-radius: 0; margin-top: 10px; padding: 12px 0 0; }
.linkrow span:last-child { color: var(--sub); font-size: .85rem; }
.ribbon { width: fit-content; margin: 20px auto 10px; background: #a05a2c; color: #fff3d1; font-size: 1rem; padding: 8px 28px; border-radius: 10px; border: 3px solid #f0b060; box-shadow: 0 3px 0 #6e3b18; }
.count { text-align: center; margin: 0 0 10px; }
.count { color: var(--coral-d); font-size: .82rem; font-weight: 700; }
.chores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chore { background: linear-gradient(#fff, #fff8e6); border: 1.5px solid #f3e3bd; border-radius: 20px; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-height: 150px; }
.chore .hd { display: flex; justify-content: space-between; align-items: center; }
.chore .em { font-size: 30px; }
.chore .price { background: var(--gold); color: #4a3200; font-size: .8rem; padding: 3px 10px; border-radius: 99px; box-shadow: 0 2px 0 var(--gold-d); }
.chore b { font-size: 1rem; }
.lucky { color: #1c7a4c; font-weight: 700; }
.go, .st { margin-top: auto; text-align: center; border-radius: 99px; padding: 10px 4px; font-weight: 700; }
.go { background: linear-gradient(#ff8b7f, var(--coral)); color: #fff; font-size: 1.05rem; box-shadow: 0 4px 0 var(--coral-d); }
.st { font-size: .82rem; background: #eceff0; color: #7c8a8f; }
.st.done { background: #e3f5ea; color: #1c7a4c; }
.st.wait { background: #e6f3f0; color: var(--main-d); }

.tabs { display: flex; background: #fff; margin: 0 14px calc(10px + env(safe-area-inset-bottom)); border-radius: 22px; box-shadow: 0 2px 10px rgba(0,60,50,.12); }
.tabs button { flex: 1; border-radius: 22px; padding: 8px 0; font-size: .7rem; color: var(--sub); }
.tabs span { display: block; font-size: 22px; filter: grayscale(.9); opacity: .6; transition: transform .2s; }
.tabs .on { color: var(--main-d); }
.tabs .on span { filter: none; opacity: 1; transform: scale(1.25) translateY(-3px); }

.sum { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #ffe3e0, #fff3d1); }
.sum .bal { font-size: 2rem; }
.sum .sub { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid li { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 10px 4px; text-align: center; position: relative; min-height: 118px; }
.grid span { font-size: 42px; display: block; line-height: 1.2; }
.grid b { display: block; font-size: .82rem; }
.grid small { display: block; font-size: .62rem; color: var(--sub); }
.grid i { font-style: normal; font-size: .68rem; color: var(--gold-d); font-weight: 700; }
.grid em { position: absolute; top: 4px; right: 8px; font-style: normal; font-size: .68rem; color: var(--sub); font-weight: 700; }
.grid .lock { background: #edf3f1; border-style: dashed; color: #a9bbb7; width: auto; height: auto; }
.grid .lock span { opacity: .35; }
.grid .s3, .grid .r1 { border-color: #9ad0f5; background: #f2f9ff; }
.grid .s4, .grid .r2 { border-color: var(--gold); background: #fff9e0; }

/* マスコット */
#mascot { position: fixed; right: max(10px, calc(50% - 250px)); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 5; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
#mascot[hidden], #fx[hidden], #toast[hidden], .say[hidden] { display: none; }
#mascot span { font-size: 44px; animation: bob 2s ease-in-out infinite; pointer-events: auto; filter: drop-shadow(0 3px 2px rgba(0,0,0,.2)); }
.say { background: #fff; border: 2px solid var(--coral); border-radius: 14px 14px 2px 14px; padding: 6px 12px; font-weight: 700; font-size: .85rem; margin-bottom: 2px; animation: pop .3s; }

/* 保護者メニュー */
.parent { background: #fbf9f2; }
.ptabs { display: flex; background: #fff; border-bottom: 1.5px solid var(--line); }
.ptabs button { flex: 1; border-radius: 0; color: var(--sub); border-bottom: 3px solid transparent; padding: 10px 0; font-size: .9rem; }
.ptabs .on { color: var(--ink); border-color: var(--gold); }
.ptabs i { font-style: normal; background: var(--ng); color: #fff; font-size: .7rem; border-radius: 9px; padding: 0 6px; margin-left: 4px; }
.parent h3 { font-size: .9rem; margin: 4px 4px 8px; }
.parent .rows { margin-bottom: 14px; }
.kidcard { border: 1.5px solid var(--line); box-shadow: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 4px 0 12px; }
.stats b { display: block; color: var(--gold-d); }
.stats small { color: var(--sub); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two button { border-radius: 12px; font-size: .88rem; }
.toggle { background: #ddd; color: #555; min-width: 64px; flex: none; }
.toggle.on { background: var(--ok); color: #fff; }

/* ダイアログ */
dialog { border: 0; border-radius: 22px; padding: 20px; width: min(92vw, 400px); color: var(--ink); max-height: 92vh; user-select: text; -webkit-user-select: text; }
dialog::backdrop { background: rgba(20, 50, 50, .55); }
dialog h3 { margin: 0 0 12px; }
dialog label { display: block; font-size: .8rem; color: var(--sub); margin-bottom: 12px; }
dialog input:not([type=checkbox]):not([type=radio]), dialog select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; font-size: 1rem; background: #fff; }
dialog input:focus, dialog select:focus { outline: none; border-color: var(--main); }
dialog fieldset { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
dialog legend { font-size: .8rem; color: var(--sub); margin-bottom: 6px; }
.dow, .colors label { margin: 0; }
.dow input, .colors input { position: absolute; opacity: 0; }
.dow span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #e6f3f0; color: var(--ink); font-weight: 700; }
.dow input:checked + span { background: var(--main); color: #fff; }
.colors { display: flex; gap: 10px; margin-bottom: 16px; }
.colors span { display: block; width: 36px; height: 36px; border-radius: 50%; }
.colors input:checked + span { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.dow input:focus-visible + span, .colors input:focus-visible + span { outline: 2px solid var(--main-d); outline-offset: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 0 12px; }
.chips button { padding: 4px 6px; font-size: 22px; border-radius: 10px; background: #f0f7f5; }
.btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.btns .ng { margin-right: auto; }
.btns .primary { padding: 10px 22px; }
.who { display: grid; gap: 8px; }
.who button { display: flex; align-items: center; gap: 12px; background: #f0f7f5; border-radius: 16px; font-size: 1.1rem; }
.pin { text-align: center; }
.pdots { display: flex; gap: 14px; justify-content: center; margin: 14px 0 18px; }
.pdots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pdots i.on { background: var(--ink); }
.keys { display: grid; grid-template-columns: repeat(3, 64px); gap: 12px; justify-content: center; margin-bottom: 14px; }
.keys button { width: 64px; height: 64px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line); font-size: 1.4rem; background: #fff; }
.keys button:active { background: #e6f3f0; }

/* 演出 */
#fx { position: fixed; inset: 0; background: rgba(20, 50, 50, .7); display: grid; place-items: center; z-index: 10; padding: 20px; overflow: hidden; }
#fx .panel { background: #fff; border-radius: 28px; padding: 22px 26px; text-align: center; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); position: relative; width: min(100%, 320px); }
#fx p { margin: 6px 0; }
.tag { display: inline-block; background: var(--coral); color: #fff; font-weight: 700; padding: 4px 16px; border-radius: 99px; }
.praise { color: var(--coral); font-weight: 900; font-size: 1.4rem; }
.amt { color: var(--gold-d); font-weight: 900; font-size: 3rem; line-height: 1.1; }
.amt small { font-size: 1.1rem; margin-left: 4px; }
.stk { border: 2px solid #b9e3c6; background: #f1faf4; border-radius: 18px; padding: 8px; margin: 10px auto; width: 170px; }
.stk.r1 { border-color: #9ad0f5; background: #f2f9ff; } .stk.r2 { border-color: var(--gold); background: #fff9e0; }
.stk small { display: block; color: var(--coral-d); font-weight: 700; }
.stk em { font-style: normal; background: var(--ng); color: #fff; border-radius: 6px; padding: 0 5px; font-size: .65rem; }
.stk span { font-size: 60px; display: block; line-height: 1.2; animation: pop .5s .2s backwards; }
.stk b { display: block; } .stk i { font-style: normal; font-size: .75rem; color: var(--sub); }
.line { font-weight: 700; font-size: .92rem; } .line.gold { color: #b07800; } .line.green { color: var(--ok); }
#fx .primary { margin-top: 12px; font-size: 1.1rem; position: relative; }
.bounce { animation: bob 1s ease-in-out infinite; }
#fx.chest { background: radial-gradient(circle, #8a5a1e, #2c1a06); align-content: center; gap: 12px; color: #fff; text-align: center; }
#fx.chest.opened { background: repeating-conic-gradient(from 0deg at 50% 45%, #ffcf4d 0 12deg, #f4b21f 12deg 24deg); }
.box { font-size: 150px; line-height: 1.1; filter: drop-shadow(0 10px 10px rgba(0,0,0,.35)); }
.box.shake { animation: shake .7s infinite; }
.box.pop { animation: pop .5s cubic-bezier(.2, 1.8, .4, 1); }
.tap { font-size: 1.4rem; font-weight: 900; text-shadow: 0 2px 4px rgba(0,0,0,.45); }
.plate { background: #fff; color: var(--ink); border-radius: 18px; padding: 10px 28px; min-width: 220px; }
.plate b { display: block; font-size: 1.3rem; } .plate small { display: block; color: var(--sub); }
.plate i { font-style: normal; color: var(--coral); letter-spacing: 2px; }
@keyframes shake { 20% { transform: rotate(-7deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-4deg) scale(1.05); } 80% { transform: rotate(4deg); } }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -40px; font-style: normal; font-size: 26px; animation: fall 2.2s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

#toast { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: .88rem; z-index: 30; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
