/*
  見た目の決まり: 置いてある物はすべて「紺のインク枠＋ベタ塗り＋下にずれた影」。
  グラデーション、ぼかし、色つきの上線、つや出しは使わない。
*/
:root {
  --ink: #27375f;
  --ink-soft: #5b6a8f;
  --paper: #fff6dc;
  --paper-line: #e6d6a6;
  --yellow: #ffd23f;
  --orange: #ff8a3d;
  --red: #e2452b;
  --sky: #cdeeff;
  --sea: #5cb8ec;
  --sea-deep: #2c78bd;
  --line: #06c755;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='56'%3E%3Cpath d='M0 14q12-10 24 0t24 0 24 0 24 0' fill='none' stroke='%23fff' stroke-opacity='.28' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M-24 42q12-10 24 0t24 0 24 0 24 0 24 0' fill='none' stroke='%23fff' stroke-opacity='.16' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background: var(--sea) var(--wave);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(120px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* ---- ホーム ---- */
.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 -16px;
  padding: calc(26px + env(safe-area-inset-top)) 20px 24px;
  background: var(--sky);
  border-bottom: 4px solid var(--ink);
}
.logo { border: 3px solid var(--ink); border-radius: 14px; image-rendering: pixelated; box-shadow: 0 4px 0 var(--ink); }
.hero h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1;
  text-shadow: 3px 3px 0 var(--yellow);
}
.hero p { margin-top: 8px; font-size: 12px; font-weight: 800; }

.home { display: grid; gap: 26px; padding-top: 26px; }

.pop-btn {
  display: block;
  width: 100%;
  padding: 15px 20px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--yellow);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 7px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.pop-btn b { display: block; font-size: 22px; font-weight: 800; line-height: 1.3; letter-spacing: .02em; }
.pop-btn small { display: block; margin-top: 2px; font-size: 12px; font-weight: 800; }
.pop-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.pop-btn:disabled { opacity: .6; }

.fab {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 240px;
  margin-left: -120px;
  padding: 12px 20px;
  background: var(--orange);
  color: #fff;
  z-index: 5;
}

/* 紙の札。見出しは上の枠にまたがる荷札 */
.panel {
  position: relative;
  padding: 26px 16px 16px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--sea-deep);
}
.ribbon {
  position: absolute;
  top: -17px;
  left: 14px;
  padding: 3px 14px 3px 26px;
  font-size: 14px;
  font-weight: 800;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 6px;
  transform: rotate(-1.5deg);
}
.ribbon::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
}
.empty { font-size: 14px; line-height: 1.8; color: var(--ink-soft); }
.empty.big { padding: 24px 0; text-align: center; font-size: 16px; font-weight: 800; color: var(--ink); }
.loading { padding: 40vh 0 0; text-align: center; font-weight: 800; }

.room-list li + li { border-top: 2px solid var(--paper-line); }
.room-list button {
  position: relative;
  display: block;
  width: 100%;
  padding: 12px 28px 12px 2px;
  border: 0;
  background: none;
  text-align: left;
}
.room-list b { display: block; font-size: 17px; font-weight: 800; }
.room-list small { font-size: 12px; color: var(--ink-soft); }
.chev { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 24px; font-weight: 800; }

.name-row { justify-self: center; display: flex; align-items: center; gap: 10px; padding: 6px 4px; border: 0; background: none; font-size: 14px; font-weight: 800; }
.name-row b { padding: 3px 10px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; }
.name-row u { text-underline-offset: 3px; }

/* ---- ルーム ---- */
.bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--sky);
  border-bottom: 4px solid var(--ink);
}
.bar-title { flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; }
.bar-title u { margin-left: 8px; text-underline-offset: 3px; }
.bar h1 { font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar p { font-size: 12px; font-weight: 800; }
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
}

/* 見出しタブ。選んだ札だけが下の線を越えて手前に出る */
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 16px 0 20px;
  padding: 0 8px;
  border-bottom: 3px solid var(--ink);
}
.tabs button {
  flex: 1;
  padding: 7px 4px 6px;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #a9d8f3;
  font-size: 13px;
  font-weight: 800;
}
.tabs button.on { margin-bottom: -3px; padding: 10px 4px 9px; background: var(--paper); font-size: 14px; }

.room { display: grid; gap: 26px; }

.catch {
  padding: 12px 14px 14px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--sea-deep);
}
.catch header { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.catch header b { font-weight: 800; }
.catch time { font-size: 12px; color: var(--ink-soft); }
.avatar {
  flex: none;
  display: block;
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  object-fit: cover;
  overflow: hidden;
}
.avatar svg { display: block; width: 100%; height: 100%; }
.avatar.big { width: 84px; height: 84px; border-width: 3px; border-radius: 18px; box-shadow: 0 5px 0 var(--ink); }

.avatar-pick { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: start; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.avatar-grid button { padding: 0; aspect-ratio: 1; border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden; }
.avatar-grid svg { display: block; width: 100%; height: 100%; }
.avatar-grid button.on { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5.5px var(--ink); }
.memo { padding: 9px 12px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--paper); font-size: 14px; line-height: 1.6; }
.memo b { margin-right: 8px; padding: 0 6px; border: 2px solid var(--ink); border-radius: 5px; font-size: 11px; font-weight: 800; }
.map-link { margin-top: -6px; font-size: 13px; font-weight: 800; color: var(--ink); text-underline-offset: 3px; }
.del { margin-left: auto; padding: 4px 2px; border: 0; background: none; font-size: 12px; color: var(--ink-soft); text-decoration: underline; }
.what { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 10px; font-size: 23px; font-weight: 800; }

/* 朱色の落款ふうの印 */
.badge {
  padding: 1px 7px;
  border: 2px solid currentColor;
  border-radius: 5px;
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.badge.first, .badge.big { color: var(--red); transform: rotate(-3deg); }
.stamp {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 3px solid var(--red);
  border-radius: 50%;
  outline: 1.5px solid var(--red);
  outline-offset: -7px;
  color: var(--red);
  font-size: 20px;
  font-weight: 800;
  transform: rotate(-9deg);
}

.photo { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: cover; border: 3px solid var(--ink); border-radius: 8px; background: var(--sky); }
.catch footer { display: flex; gap: 8px; margin-top: 12px; }
.react {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 46px;
  height: 36px;
  padding: 0 9px;
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  background: #fff;
  font-size: 16px;
}
.react span { font-size: 13px; font-weight: 800; }
.react.on { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); transform: translateY(-3px); }
.pending { padding: 8px 12px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; font-size: 13px; font-weight: 800; }

.total { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 6px 0 14px; font-size: 18px; font-weight: 800; }
.total small { font-size: 13px; margin-right: 6px; }
.total b { padding: 0 8px; font-size: 60px; line-height: 1; box-shadow: inset 0 -16px 0 var(--yellow); }

.rows li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-top: 2px solid var(--paper-line); font-size: 16px; }
.rows li > span { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; }
.rows li > .avatar { flex: none; display: block; }
.rows small { font-size: 12px; color: var(--ink-soft); }
.rows b { font-weight: 800; min-width: 3.5em; text-align: right; }

.awards li { display: flex; align-items: center; gap: 14px; padding: 10px 2px; }
.awards li + li { border-top: 2px solid var(--paper-line); }
.awards small { display: block; font-size: 12px; font-weight: 800; color: var(--red); }
.awards b { font-size: 19px; font-weight: 800; }
.awards span { font-size: 14px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---- 共通ボタン ---- */
.btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--sea); }
.btn.line { background: var(--line); color: #fff; }
.btn.small { width: auto; padding: 6px 14px; font-size: 14px; }

/* ---- シート: 画面端から浮かせた、題字帯つきの札 ---- */
#sheet {
  width: min(456px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  margin: auto auto calc(14px + env(safe-area-inset-bottom));
  padding: 0;
  border: 4px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 0 #16254a;
  overflow: hidden;
}
#sheet[open] { display: flex; flex-direction: column; }
#sheet::backdrop { background: rgba(22, 37, 74, .6); }
.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px 8px 16px;
  background: var(--yellow);
  border-bottom: 4px solid var(--ink);
}
.sheet-head h2 { font-size: 18px; font-weight: 800; }
.x { flex: none; width: 34px; height: 34px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; font-size: 20px; font-weight: 800; line-height: 1; }

.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
#sheet > .form { padding: 16px 16px 20px; overflow-y: auto; }
.form label, .label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
.form input[type="text"], .form input[type="date"] {
  width: 100%;
  padding: 11px 12px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
}
.form .pop-btn { margin: 4px 0 6px; }
.hint { font-size: 13px; line-height: 1.7; color: var(--ink-soft); }
.qr { padding: 16px; background: #fff; border: 3px solid var(--ink); border-radius: 10px; }
.qr svg { display: block; width: min(240px, 100%); height: auto; margin: 0 auto; }

.preview { display: flex; gap: 10px; padding-bottom: 4px; }
.preview img { width: 120px; height: 90px; object-fit: cover; border: 3px solid var(--ink); border-radius: 8px; }
.preview .btn.small { align-self: center; }
.pick { flex: 1; display: grid; place-items: center; width: auto; min-width: 0; padding-left: 4px; padding-right: 4px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 7px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 9px;
  background: #fff;
  font-size: 15px;
  font-weight: 800;
}
.chips button.on { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); transform: translateY(-3px); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  flex: none;
  width: 38px;
  height: 38px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}
.stepper input {
  flex: 1;
  min-width: 0;
  padding: 8px 2px;
  border: 0;
  border-bottom: 3px solid var(--ink);
  border-radius: 0;
  background: none;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper span { font-size: 13px; font-weight: 800; }

#toast {
  position: fixed;
  left: 50%;
  top: calc(72px + env(safe-area-inset-top));
  z-index: 100;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--ink);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: transform .2s, opacity .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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