:root {
  --orange: #ffa31a;
  --orange-bright: #ffb84d;
  --orange-soft: #fff1d6;
  --bg: #fffaf1;
  --card: #ffffff;
  --ink: #3a2a12;
  --muted: #7a6a55;
  --line: #f1dfbd;
  --yes: #23864a;
  --no: #c9342f;
  --maybe: #4a63c4;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}

/* ---------- ヘッダー ---------- */
.top {
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  color: #3a2200;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(160, 90, 0, .18);
}
.top-inner {
  padding: 12px 16px 4px;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.top h1 { margin: 0; font-size: 1.05rem; letter-spacing: .02em; line-height: 1.3; }
.role-badge {
  flex: none;
  font-size: .75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.role-badge.admin { background: #3a2200; color: #fff; }
.role-badge.general { background: rgba(255, 255, 255, .7); color: #5a3a08; }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; max-width: 760px; margin: 0 auto; }
.tab {
  flex: 1;
  border: 0;
  background: rgba(255, 255, 255, .35);
  color: #3a2200;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  padding: 9px 2px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.tab-link { display: block; }
.tab[aria-current="true"] { background: var(--bg); }

/* ---------- 共通 ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 14px 64px; }
h2 { font-size: 1.05rem; margin: 6px 0 12px; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.muted { color: var(--muted); font-size: .85rem; }

button { font: inherit; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--orange); border-color: var(--orange); color: #3a2200; }
.btn.danger { color: var(--no); border-color: #efc4c2; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }

/* ---------- 予定カード ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(120, 80, 0, .06);
}
.ev-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.ev-head .date { font-weight: 800; font-size: 1.1rem; }
.ev-head .time { color: var(--muted); font-size: .9rem; }
.ev-title { margin: 4px 0 0; font-weight: 700; }
.ev-meta { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.ev-note { margin: 6px 0 0; padding: 6px 10px; background: var(--orange-soft); border-radius: 8px; font-size: .9rem; }

.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.k-practice { background: #e6f1ff; color: #1d4f8f; }
.k-pg { background: #e7f6ec; color: #1f6b3a; }
.k-league { background: #ffeed9; color: #94440a; }
.k-official { background: #ffe1e1; color: #9b1c1c; }

.score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 1.4rem;
  font-weight: 800;
}
.res { font-size: .8rem; padding: 2px 10px; border-radius: 999px; color: #fff; }
.res.win { background: var(--yes); }
.res.lose { background: var(--no); }
.res.draw { background: #6b7280; }

.counts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 2px; font-size: .88rem; align-items: baseline; }
.counts .rl { font-weight: 800; min-width: 3.6em; }
.counts b { font-size: 1rem; }
.c-yes b { color: var(--yes); }
.c-no b { color: var(--no); }
.c-maybe b { color: var(--maybe); }
.c-none { color: var(--muted); }

/* ---------- 出欠入力 ---------- */
.mine { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.prow { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid #f7ecd3; }
.prow:last-child { border-bottom: 0; }
.pname { font-weight: 700; }
.pname .no { color: var(--muted); font-weight: 400; margin-right: 6px; font-size: .85rem; }
.btns { display: flex; gap: 6px; }
.st {
  flex: 1;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 2px;
  font-weight: 700;
  cursor: pointer;
}
.st .mark { margin-right: 4px; }
.st-yes.on { background: var(--yes); border-color: var(--yes); color: #fff; }
.st-no.on { background: var(--no); border-color: var(--no); color: #fff; }
.st-maybe.on { background: var(--maybe); border-color: var(--maybe); color: #fff; }
.att-ctl { display: flex; flex-direction: column; gap: 6px; }
.note, .fld input, .fld select {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.note:disabled { background: #faf5ea; }

/* ---------- みんなの出欠 ---------- */
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.rolegroup { margin: 10px 0 4px; }
.rolehead { margin: 8px 0 2px; font-size: .92rem; color: var(--ink); border-left: 4px solid var(--orange); padding-left: 8px; }
.group { margin: 6px 0; }
.group h5 { margin: 0 0 4px; font-size: .82rem; color: var(--muted); }
.rtag { margin-left: 6px; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--orange-soft); color: #94440a; vertical-align: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .88rem;
}
.chip .no { color: var(--muted); margin-right: 4px; font-size: .8rem; }
.chip .why { color: var(--muted); font-size: .8rem; }

.card-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- 結果タブ ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chipbtn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 700;
  cursor: pointer;
}
.chipbtn[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: #3a2200; }
.record { background: var(--orange-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-weight: 700; }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.cal-title { flex: 1; text-align: center; font-size: 1.1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-grid.dows { margin-bottom: 3px; }
.dow { text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); }
.dow0 { color: #c9342f; }
.dow6 { color: #3a63b8; }
.day {
  position: relative;
  min-height: 76px;
  padding: 3px 2px 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  cursor: pointer;
  overflow: hidden;
}
.day .num { font-size: .85rem; font-weight: 700; text-align: left; padding-left: 3px; line-height: 1.2; }
.day.dow0 .num, .day.hol .num { color: #c9342f; }
.day.hol { background: #fff5f3; }
.day .hname {
  display: block;
  font-size: .58rem;
  line-height: 1.2;
  color: #c9342f;
  white-space: nowrap;
  overflow: hidden;
  padding-left: 3px;
}
.day.dow6 .num { color: #3a63b8; }
.day.out { opacity: .45; }
.day.today { border: 2px solid var(--orange); }
.day.today .num { color: #b35c00; }
.day.sel { background: var(--orange-soft); border: 2px solid var(--orange-deep, #e08a00); box-shadow: 0 0 0 2px rgba(255, 163, 26, .35); }
.evbar {
  display: block;
  font-size: .62rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 0 3px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.day .more { font-size: .62rem; color: var(--muted); padding-left: 3px; }
.day .ask {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--no);
}
.cal-note { margin: 6px 0 0; }
.day-head { margin-top: 18px; }
.day-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.day-title h2 { margin: 0; }
.hol-tag { color: #c9342f; font-size: .85rem; font-weight: 700; }

/* ---------- 回答する選手 ---------- */
.mybar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--orange-soft);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: .92rem;
}
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 名簿 ---------- */
.mlist { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.mrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f7ecd3; }
.mrow:last-child { border-bottom: 0; }
.minfo { min-width: 0; }
.mname { font-weight: 700; }
.mname .no { color: var(--muted); font-weight: 400; margin-right: 6px; font-size: .85rem; }
.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.check { display: block; padding: 4px 0; font-weight: 400; }
.fld textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }

/* ---------- ダイアログ・フォーム ---------- */
.gtable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.gtable td { padding: 6px 4px; border-bottom: 1px solid #f7ecd3; vertical-align: middle; }
.gform { display: grid; gap: 8px; margin-bottom: 8px; }
.warn { background: #fff4e5; border: 1px solid #ffd8a1; border-radius: 10px; padding: 8px 12px; font-size: .88rem; }

dialog {
  width: min(520px, calc(100% - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 16px;
  color: var(--ink);
  background: var(--card);
}
dialog::backdrop { background: rgba(58, 34, 0, .45); }
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #3a2a12;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 50;
  max-width: calc(100% - 32px);
}
.fatal { text-align: center; padding: 40px 12px; }

@media (min-width: 560px) {
  .prow { flex-direction: row; align-items: center; gap: 12px; }
  .prow .pname { flex: 0 0 8.5em; }
  .prow .att-ctl { flex: 1; flex-direction: row; align-items: center; }
  .prow .btns { flex: 0 0 240px; }
}

.mybar .btn, .mybar button { white-space: nowrap; flex-shrink: 0; }
.hname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.tab { white-space: nowrap; font-size: .8rem; padding-left: 4px; padding-right: 4px; }
