/*
  見た目の決まり: 置いてある物はすべて「インク色の枠＋ベタ塗り＋下にずれた影」。
  グラデーション、ぼかし、色つきの上線は使わない。
*/
:root {
  --ink: #2b2a33;
  --ink-soft: #6a6872;
  --paper: #fff3d6;
  --card: #fffdf6;
  --orange: #ff8a3d;
  --orange-soft: #ffd9b8;
  --green: #4cb36b;
  --green-soft: #c9ecd3;
  --line: #e4d4a8;
  --font: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --shadow: 0 3px 0 var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 480px; margin: 0 auto; padding: 0 16px calc(80px + env(safe-area-inset-bottom)); }
button, input, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; cursor: pointer; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
[hidden] { display: none !important; }

.hero { padding: calc(28px + env(safe-area-inset-top)) 4px 18px; }
.hero h1 { font-size: 28px; line-height: 1.25; }
.hero p { margin-top: 8px; color: var(--ink-soft); line-height: 1.6; font-size: 14px; }

.bar { display: flex; align-items: center; gap: 10px; padding: calc(16px + env(safe-area-inset-top)) 0 6px; }
.bar h1 { font-size: 19px; overflow-wrap: anywhere; }
.back { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 2px solid var(--ink); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; font-weight: 700; }
.rules { font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; }

.card { margin-top: 14px; padding: 16px; background: var(--card); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2 { font-size: 16px; margin-bottom: 10px; }
.hint { font-size: 12.5px; line-height: 1.6; color: var(--ink-soft); margin: 4px 0 10px; }
.hint.pad { margin: 16px 4px; }

.field { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 700; }
.input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font-weight: 500; font-size: 16px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; }
.area { resize: vertical; line-height: 1.6; }

.seg { display: flex; gap: 6px; margin-top: 6px; }
.seg-b { flex: 1; padding: 9px 4px; font-size: 14px; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 10px; }
.seg-b.on { background: var(--orange); box-shadow: var(--shadow); transform: translateY(-1px); }

.btn { display: inline-block; padding: 10px 16px; font-size: 15px; font-weight: 700; text-align: center; text-decoration: none; color: var(--ink); background: var(--orange); border: 2px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { background: #e9e3d2; color: var(--ink-soft); box-shadow: none; cursor: default; }
.btn.big { display: block; width: 100%; margin-top: 12px; padding: 14px; font-size: 17px; }
.btn.ghost { background: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.count { font-weight: 700; color: var(--ink-soft); }
.count.ok { color: var(--green); }
.invite { display: flex; gap: 8px; margin-top: 12px; }
.invite .btn:first-child { flex: 1; }

.members li, .rooms li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px dashed var(--line); }
.members li:first-child, .rooms li:first-child { border-top: 0; }
.who small { margin-left: 6px; font-size: 11px; color: var(--ink-soft); }
.tag { padding: 2px 9px; font-size: 12px; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 99px; }
.tag.ok { background: var(--green-soft); }
.room-link { color: var(--ink); font-weight: 700; text-decoration: none; display: block; width: 100%; overflow-wrap: anywhere; }

/* ---- 盤面 ---- */
.grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 5px; margin: 10px 0 4px; }
.cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; aspect-ratio: 1; padding: 3px; font-size: clamp(9px, 3vw, 13px); font-weight: 700; line-height: 1.25; text-align: center; overflow-wrap: anywhere; overflow: hidden; background: #fff; border: 2px solid var(--ink); border-radius: 9px; }
.grid[style*="--n:5"] .cell { font-size: clamp(8px, 2.4vw, 11px); }
button.cell { cursor: pointer; }
.cell.sel { background: var(--orange-soft); box-shadow: var(--shadow); transform: translateY(-2px); }
.cell.free { background: var(--paper); color: var(--ink-soft); font-size: 11px; }
.cell.hidden { background: #ece6d4; color: var(--ink-soft); font-size: 20px; }
.cell.closed { background: #fff; font-weight: 500; }
.cell.open { background: var(--green-soft); }
.cell.line { background: var(--orange); }

.tabs { display: flex; gap: 6px; margin-top: 14px; overflow-x: auto; }
.tab { flex: none; padding: 7px 14px; font-weight: 700; font-size: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 99px; }
.tab.on { background: var(--orange); box-shadow: var(--shadow); }
.tab b { margin-left: 6px; padding: 0 6px; background: var(--ink); color: #fff; border-radius: 99px; font-size: 12px; }

.todo li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); line-height: 1.4; overflow-wrap: anywhere; }
.todo li:first-child { border-top: 0; }
.todo li.done span:first-child { color: var(--ink-soft); text-decoration: line-through; }

.banner { margin-top: 14px; padding: 14px 16px; font-weight: 700; font-size: 17px; background: var(--orange); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
.banner small { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; }

dialog { width: min(92vw, 360px); padding: 16px; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(43, 42, 51, .45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { font-size: 16px; }
.x { width: 32px; height: 32px; font-size: 20px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; }
.qr svg { display: block; width: 100%; height: auto; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: 88vw; padding: 10px 16px; font-size: 14px; font-weight: 700; color: #fff; background: var(--ink); border-radius: 12px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 触感用の透明label（feel.js）と、押した場所からはじける粒 */
[data-haptic-trigger] { position: absolute; inset: 0; z-index: 1; touch-action: manipulation; }
button:disabled > [data-haptic-trigger], [data-feel="off"] [data-haptic-trigger] { pointer-events: none; }
.sparks { position: fixed; z-index: 200; width: 0; height: 0; pointer-events: none; }
.sparks i { position: absolute; border: 1.5px solid var(--ink); border-radius: 3px; animation: spark .55s cubic-bezier(.1, .7, .3, 1) both; }
@keyframes spark {
  0% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3) rotate(120deg); opacity: 0; }
}
button:active:not(:disabled) { transition-duration: .04s; }
.seg-b:active, .tab:active, button.cell:active { transform: translateY(2px) scale(.97); }

/* 難易度・控え */
.tier { margin-top: 12px; }
.tier-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.stars { display: block; font-style: normal; font-size: .75em; letter-spacing: -1px; color: var(--ink-soft); font-weight: 500; }
.todo .stars { display: inline; }
.cell.line .stars, .cell.open .stars { color: var(--ink); }
.acts { display: flex; gap: 6px; flex: none; }
.spare { margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; font-size: 13px; font-weight: 700; background: #fff; border: 2px dashed var(--ink); border-radius: 99px; text-align: left; overflow-wrap: anywhere; }
.chip.sel { background: var(--orange-soft); border-style: solid; box-shadow: var(--shadow); }

/* アイコン中心の表示 */
.ic { display: inline-flex; flex: none; vertical-align: middle; }
.marks { display: inline-flex; gap: 1px; flex: none; line-height: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.icon-only { padding: 8px 12px; }
.btn.small.icon-only { padding: 6px 10px; }
.btn.big { display: flex; }
.seg { flex-wrap: wrap; margin: 0 0 12px; }
.seg-b { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 12px; }
.card > .input { margin: 0 0 10px; }
.rules { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.rules > span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; font-size: 12px; font-weight: 700; background: var(--card); border: 2px solid var(--ink); border-radius: 99px; }
.tier-card { margin-top: 12px; }
.tier-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tier-head .count { margin-left: auto; }
.row-item { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row-item .input { margin: 0; flex: 1; min-width: 0; }
.add { display: flex; width: 100%; }
.who { display: inline-flex; align-items: center; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 3px; }
.members.compact { margin-top: 12px; padding: 0 4px; }
.status { display: flex; gap: 6px; margin-bottom: 6px; }
.todo-text { display: inline-flex; align-items: center; gap: 8px; }
.cell .t { display: block; }
.score { display: inline-flex; align-items: baseline; gap: 6px; }
.score b { font-size: 18px; }
.score small { color: var(--ink-soft); font-size: 12px; }
.banner { display: flex; align-items: center; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.invite .btn:first-child { flex: 1; }
.btn.big .ic + * { margin-left: 0; }

/* ライン数・期限・カレンダー */
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; padding: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }
.stepper-n { display: inline-flex; align-items: center; gap: 8px; min-width: 70px; justify-content: center; }
.stepper-n b { font-size: 22px; }
.due { display: flex; width: 100%; margin-bottom: 12px; justify-content: flex-start; padding: 10px 14px; }
.due-x { margin-left: auto; display: inline-flex; padding: 2px; border-radius: 99px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: 17px; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-week { margin-bottom: 4px; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.cal-week span:first-child { color: #d9533a; }
.cal-d { aspect-ratio: 1; display: grid; place-items: center; font-size: 15px; font-weight: 700; background: #fff; border: 2px solid transparent; border-radius: 10px; }
.cal-d:disabled { color: #c9c2ae; background: transparent; cursor: default; }
.cal-d.today { border-color: var(--ink); }
.cal-d.on { background: var(--orange); border-color: var(--ink); box-shadow: var(--shadow); }
.cal-d:active:not(:disabled) { transform: scale(.92); }

/* 見出し・区切り */
.group { padding: 12px 0 14px; border-top: 2px dashed var(--line); }
.group:first-child { padding-top: 0; border-top: 0; }
.group-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.group .seg, .group .stepper, .group .due, .group .input:last-child { margin-bottom: 0; }
.group .seg + .stepper { margin-top: 8px; }
.group .input + .input { margin-top: 8px; }
.card > .btn.big { margin-top: 6px; }
.sec-h { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.sec-h.standalone { margin: 22px 4px 0; }
.sub-h { margin: 14px 0 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.stepper-n small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }

/* みんなの状況・お題のメモとToDo */
.status-list li { align-items: flex-start; flex-wrap: wrap; }
.chips-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.who small { font-weight: 700; }
.todo li { display: block; padding: 6px 0; }
.todo-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.todo-text-btn { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 8px 0; text-align: left; background: none; border: 0; line-height: 1.4; overflow-wrap: anywhere; }
.todo-label { min-width: 0; }
.chev { display: inline-flex; margin-left: auto; transition: transform .15s; color: var(--ink-soft); }
.chev.up { transform: rotate(180deg); }
.todo li.open { background: #fff9e6; margin: 0 -8px; padding: 6px 8px; border-radius: 10px; }
.detail { padding: 4px 0 10px; }
.note-priv { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.subs li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); }
.subs li:first-child { border-top: 0; }
.subs li span { flex: 1; overflow-wrap: anywhere; }
.subs li.done span { color: var(--ink-soft); text-decoration: line-through; }
.check { display: grid; place-items: center; width: 26px; height: 26px; flex: none; background: #fff; border: 2px solid var(--ink); border-radius: 8px; }
.check.on { background: var(--green-soft); }
.sub-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.sub-add .input { margin: 0; flex: 1; min-width: 0; }
.memo { resize: vertical; line-height: 1.5; margin-top: 4px; }
