/* 仲間分け — 見た目
 *   和紙の地に、藍の盤。札は明るい生成り、選ぶと朱。揃った仲間は和色の帯（山吹・若竹・空・藤）。
 *   地・盤・札の明るさをはっきり分ける（同じ生成りが重なると札が地に溶けて見づらかった）。
 *   骨格はルート AGENTS.md のとおり。普通にスクロールするページで、fixed は使わない
 */

/* **これを先頭に置く。** 下で display を書いた要素でも hidden が効くように */
[hidden] { display: none !important; }

:root {
  --paper: #f6f0e3;
  --paper2: #ede4d1;
  --ink: #2b261f;
  --sub: #7b705f;
  --hair: rgba(43, 38, 31, .14);
  --board: #27344d;
  --board2: #1d2840;
  --tile: #f3ead6;
  --tile-hi: #fffaf0;
  --tile-edge: #b9a782;
  --sel: #c8452d;
  --sel-hi: #e2603f;
  --sel-edge: #8a2a19;
  --sel-ink: #fff8ee;
  --c1: #f5c84a;
  --c2: #92c45c;
  --c3: #7fbbe8;
  --c4: #b98ee0;
  --round: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--round);
  font-weight: 500;
  line-height: 1.7;
  background:
    radial-gradient(900px 420px at 50% -120px, rgba(241, 204, 92, .22), transparent 70%),
    radial-gradient(rgba(120, 96, 60, .07) 1px, transparent 1.2px) 0 0 / 14px 14px,
    var(--paper);
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; }

#app { padding: 0 16px 40px; }

/* ── ヘッダ ───────────────────────────────────── */
#site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--hair);
}
.apps-link {
  color: var(--sub);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.apps-link:hover { color: var(--ink); border-color: rgba(43, 38, 31, .35); }
.header-logo {
  margin: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}
.header-logo a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(17px, 5vw, 22px);
  letter-spacing: .04em;
}
.header-sub { font-size: 12px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; }
.mark { display: grid; grid-template-columns: repeat(2, 9px); gap: 2px; }
.mark i { display: block; width: 9px; height: 9px; border-radius: 2px; }
.mark i:nth-child(1) { background: var(--c1); }
.mark i:nth-child(2) { background: var(--c2); }
.mark i:nth-child(3) { background: var(--c3); }
.mark i:nth-child(4) { background: var(--c4); }

/* ── 盤 ──────────────────────────────────────── */
#play { max-width: 600px; margin: 22px auto 0; }

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.no {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .04em;
}
.no-wrap { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.day { font-size: 13px; color: var(--sub); }
.day.today { color: var(--sel); font-weight: 700; }
.no-wrap .textbtn { margin: 0; }
.lives { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); white-space: nowrap; flex-shrink: 0; }
.dots { display: inline-flex; gap: 6px; }
.dot { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--sel); transition: background .3s, transform .3s; }
.dot.used { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(43, 38, 31, .25); transform: scale(.8); }

#stage {
  position: relative;
  padding: 12px;
  border-radius: 18px;
  background:
    radial-gradient(500px 220px at 50% 0, rgba(127, 187, 232, .16), transparent 70%),
    linear-gradient(180deg, var(--board), var(--board2));
  box-shadow: 0 14px 30px rgba(29, 40, 64, .28), inset 0 1px 0 rgba(255, 255, 255, .08);
}
#bands, #board { display: grid; gap: 8px; }
#bands:not(:empty) { margin-bottom: 8px; }
#board { grid-template-columns: repeat(4, 1fr); }

.tile {
  position: relative;
  aspect-ratio: 5 / 4;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--tile-hi), var(--tile));
  box-shadow: 0 3px 0 var(--tile-edge), 0 6px 12px rgba(0, 0, 0, .25);
  color: var(--ink);
  font-weight: 900;
  font-size: clamp(16px, 4.6vw, 22px);
  letter-spacing: .02em;
  line-height: 1.2;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s, transform .15s, box-shadow .15s;
}
.tile.l4 { font-size: clamp(14px, 4vw, 20px); }
.tile.l5 { font-size: clamp(12px, 3.3vw, 18px); letter-spacing: 0; }
.tile.l6 { font-size: clamp(11px, 2.9vw, 16px); letter-spacing: 0; }
.tile.k1, .tile.k2 { font-family: var(--serif); font-weight: 800; }
.tile.k1 { font-size: clamp(22px, 6.4vw, 30px); }
.tile.k2 { font-size: clamp(18px, 5vw, 25px); }
@media (hover: hover) {
  .tile:not(.on):not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--tile-edge), 0 10px 18px rgba(80, 60, 30, .12); }
}
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-edge); }
.tile.on {
  background: linear-gradient(180deg, var(--sel-hi), var(--sel));
  color: var(--sel-ink);
  box-shadow: 0 3px 0 var(--sel-edge), 0 6px 14px rgba(0, 0, 0, .3);
}
.tile:disabled { cursor: default; }
.tile.hop { animation: hop .32s ease; }
.tile.shake { animation: shake .4s ease; }
.tile.out { animation: out .26s ease forwards; }
@keyframes hop { 40% { transform: translateY(-9px); } 100% { transform: translateY(0); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes out { to { transform: scale(.85); opacity: 0; } }

.band {
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
  box-shadow: 0 3px 0 rgba(43, 38, 31, .14);
  min-height: calc((min(600px, 100vw - 32px) - 48px) / 4 * .8);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.band.pop { animation: pop .42s cubic-bezier(.2, 1.4, .4, 1); }
.band.wave { animation: wave .5s ease; }
@keyframes wave { 35% { transform: translateY(-7px) scale(1.015); } 100% { transform: none; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.band b { display: block; font-size: clamp(16px, 4.2vw, 19px); font-weight: 900; letter-spacing: .04em; }
.band span { display: block; font-size: clamp(13px, 3.5vw, 15px); }
.band small { color: rgba(43, 38, 31, .62); font-size: .85em; }
.c1 { background: var(--c1); }
.c2 { background: var(--c2); }
.c3 { background: var(--c3); }
.c4 { background: var(--c4); }

#toast {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translate(-50%, 0);
  background: var(--sel);
  color: var(--sel-ink);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(40, 30, 20, .2);
  animation: toast .2s ease;
  z-index: 2;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ── ボタン ───────────────────────────────────── */
#controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.pill {
  min-width: 96px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: rgba(255, 255, 255, .35);
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
}
.pill:hover:not(:disabled) { background: rgba(255, 255, 255, .8); }
.pill:active:not(:disabled) { transform: scale(.97); }
.pill.solid:not(:disabled) { background: var(--ink); color: var(--sel-ink); }
.pill.solid:hover:not(:disabled) { background: #46392c; }
.pill:disabled { opacity: .35; cursor: default; }
.textbtn {
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  margin-top: 10px;
}

/* ── 結果 ─────────────────────────────────────── */
#result {
  margin-top: 26px;
  padding: 22px 16px 18px;
  text-align: center;
  background: rgba(255, 255, 255, .55);
  border: 1px solid var(--hair);
  border-radius: 16px;
  animation: pop .45s ease;
}
#result h2 { margin: 0; font-family: var(--serif); font-size: clamp(18px, 5.4vw, 24px); font-weight: 800; letter-spacing: .04em; }
#verdict-sub { margin: 2px 0 14px; color: var(--sub); font-size: 14px; }
#grid { display: inline-grid; gap: 4px; margin-bottom: 16px; }
#grid .row { display: grid; grid-template-columns: repeat(4, 22px); gap: 4px; }
#grid i { display: block; width: 22px; height: 22px; border-radius: 5px; }
.result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.next-in { margin: 14px 0 0; font-size: 14px; color: var(--sub); }
.share { border-top: 1px solid var(--hair); padding-top: 14px; }
.share-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--sub); }
.share-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pill.share-btn { min-width: 0; padding: 8px 16px; font-size: 14px; }
#share-x:not(:disabled) { background: #1f1f1f; border-color: #1f1f1f; color: #fff; }
#share-line:not(:disabled) { background: #06c755; border-color: #06c755; color: #fff; }
.share-msg { min-height: 1.4em; margin: 6px 0 0; font-size: 13px; color: var(--sub); }
.today-btn {
  border: 1.5px solid var(--sel);
  background: transparent;
  color: var(--sel);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.today-btn:hover { background: var(--sel); color: var(--sel-ink); }
.next-in b { font-family: var(--serif); font-size: 20px; color: var(--ink); letter-spacing: .06em; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ── 成績 ─────────────────────────────────────── */
#stats { margin-top: 36px; }
#stats h2 { font-size: 16px; margin: 0 0 10px; }
#stats h3 { font-size: 13px; color: var(--sub); margin: 16px 0 6px; }
.st-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.st-grid div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  background: #fffdf8;
  border: 1px solid var(--hair);
  border-radius: 10px;
}
.st-grid b { font-family: var(--serif); font-size: 24px; font-weight: 800; line-height: 1.2; }
.st-grid span { font-size: 11px; color: var(--sub); white-space: nowrap; }
.dist-row { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.dist-row span { text-align: right; color: var(--sub); }
.dist-row i {
  display: block;
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 4px;
  background: #cfc6b3;
  color: var(--ink);
  font-style: normal;
  font-weight: 700;
  text-align: right;
}
.dist-row i.mine { background: var(--sel); color: var(--sel-ink); }

/* ── 一覧 ─────────────────────────────────────── */
#archive { margin-top: 40px; }
#archive h2 { font-size: 16px; margin: 0 0 10px; }
#archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px; }
.arc {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: #fffdf8;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.arc:hover { background: rgba(255, 255, 255, .85); }
.arc.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.arc.playing { border-style: dashed; border-color: rgba(43, 38, 31, .4); }
.arc.won { background: var(--c2); border-color: transparent; }
.arc.perfect { background: var(--c1); border-color: transparent; }
.arc.lost { background: #d9d2c3; border-color: transparent; color: var(--sub); }
.arc.today { box-shadow: inset 0 -3px 0 var(--sel); }
.arc.perfect::after {
  content: "★";
  position: absolute;
  right: 4px;
  top: 1px;
  font-size: 10px;
}

/* ── 遊び方・フッタ ───────────────────────────── */
#guide-section { max-width: 1200px; margin: 56px auto 0; }
#guide-section h2 { font-size: 18px; border-bottom: 1px solid var(--hair); padding-bottom: 6px; }
.guide-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; }
.guide-lead { font-size: 14px; color: #4d443a; margin: 0 0 16px; }
.guide-col h3 { font-size: 14px; margin: 0 0 4px; }
.guide-col p { font-size: 14px; margin: 0; color: #4d443a; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 4px; }

.related-apps { max-width: 1200px; margin: 40px auto 0; background: rgba(255, 250, 240, .6); border: 1px solid var(--hair); border-radius: 12px; padding: 16px; }
.related-apps-title { font-size: 15px; margin: 0 0 10px; }
.related-apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.related-app-link {
  display: block;
  padding: 9px 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--tile-hi);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.related-app-link:hover { border-color: var(--sel); color: var(--sel-edge); }
#ad-section { max-width: 1200px; margin: 28px auto 0; }

#site-footer { max-width: 1200px; margin: 44px auto 0; padding-top: 16px; border-top: 1px solid var(--hair); color: var(--sub); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.footer-link { color: var(--sub); text-decoration: none; }
.footer-link:hover { color: var(--ink); }
.footer-copy { font-size: 12px; }

@media (max-width: 760px) {
  .guide-content { grid-template-columns: 1fr; gap: 14px; }
  .header-sub { display: none; }
}
@media (max-width: 400px) {
  #bands, #board { gap: 6px; }
  .pill { min-width: 0; padding: 9px 16px; }
}
