/* 中央にスロット、下にみんなの履歴。紙っぽい地に墨と朱 */
:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --reel: #e9e4d8;
  --ink: #1a1a1a;
  --muted: #8a857a;
  --accent: #d6322b;
  --line: #d9d3c6;
  --line-green: #06c755;
  --gold: #c8972b;
  --gold-deep: #7d5a12;
  --gold-light: #f1d27a;
  --mincho: "Zen Old Mincho", "Hiragino Mincho ProN", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--gothic);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-block: 48px 32px;
  gap: 24px;
}

.lead {
  margin: 0;
  font-size: 14px;
  letter-spacing: .2em;
  color: var(--muted);
}

.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.concept {
  margin: 0;
  max-width: 34em;
  /* 一番長い行（31文字）が画面幅に収まるサイズにして、必ず2行で表示する */
  font-size: min(13px, calc((100vw - 32px) / 31.5));
  white-space: nowrap;
  line-height: 1.9;
  color: var(--ink);
}

.stage {
  width: min(100%, 960px);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.title {
  margin: 0;
  font-family: var(--mincho);
  font-weight: 900;
  white-space: nowrap;
  font-size: 160px; /* JSで幅に合わせて調整 */
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 0;
  transition: gap .25s;
}

/* スロットの窓 */
.reel {
  display: block;
  height: 1.3em;
  overflow: hidden;
  border-radius: .06em;
  background: transparent;
  transition: width .3s ease, background-color .3s;
}
.strip { display: flex; flex-direction: column; align-items: center; }
.strip span { display: block; height: 1.3em; line-height: 1.3em; white-space: nowrap; padding-inline: 0; }

.title.spinning { gap: .12em; }
.title.spinning .reel {
  background: var(--reel);
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.reel.stopped { background: transparent !important; }
.title.ruined .strip span { color: var(--accent); }
.title.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes pop {
  from { transform: scale(.88); }
  to   { transform: scale(1); }
}

/* リーチ・大当たり */
.stage { position: relative; transition: background-color .4s; }
.callout {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--mincho);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: .3em;
  color: var(--accent);
  white-space: nowrap;
}
.callout.stamp {
  top: 12px;
  padding: 4px 14px 4px 20px;
  border: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 26px;
  transform: translateX(-50%) rotate(-6deg);
  animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes stamp {
  from { opacity: 0; transform: translateX(-50%) rotate(-6deg) scale(2.6); }
  to   { opacity: 1; transform: translateX(-50%) rotate(-6deg) scale(1); }
}
.stage.jackpot { background: radial-gradient(ellipse at center, color-mix(in srgb, var(--gold-light) 55%, var(--bg)), var(--bg) 72%); }
.title.jackpot .strip span {
  background: linear-gradient(100deg, var(--gold-deep) 20%, var(--gold-light) 45%, var(--gold-deep) 70%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 2.4s linear infinite;
}
@keyframes shine { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.count.jackpot { color: var(--gold-deep); font-weight: 700; text-align: center; line-height: 1.7; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }

.test-row { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 11px; color: var(--accent); }
.test-row button { background: transparent; border: 1px dashed var(--accent); color: var(--accent); padding: 4px 12px; font-size: 12px; }
.test-row button:disabled { opacity: .4; cursor: default; }

.count {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 1em;
}

button { font: inherit; cursor: pointer; border: 0; border-radius: 999px; }

.ruin {
  background: var(--ink);
  color: var(--bg);
  font-size: 20px;
  font-weight: 700;
  padding: 18px 48px;
  letter-spacing: .1em;
  transition: transform .1s, background .2s;
}
.ruin:hover { background: var(--accent); }
.ruin:active { transform: scale(.96); }
.ruin:disabled { opacity: .5; cursor: default; }

/* 共有パネル */
.share-panel {
  width: min(100%, 480px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: opacity .2s;
}
.share-panel.stale { opacity: .35; pointer-events: none; }
.share-card { margin: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.share-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 630;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--reel);
}
.share-card figcaption { font-size: 11px; color: var(--muted); text-align: center; }
.share-btns { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-btns a, .share-btns button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  text-decoration: none;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
}
.share-btns .x { grid-column: 1 / -1; }
.share-btns .primary { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: #fff; }
.share-btns .x { background: var(--ink); color: var(--bg); }
.share-btns a:hover, .share-btns button:hover { filter: brightness(.92); }
.reset { background: none; color: var(--muted); font-size: 13px; padding: 4px 8px; }
.reset:hover { color: var(--ink); }

/* 履歴と図鑑 */
.board {
  width: min(100%, 960px);
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.board-title { margin: 0; font-size: 16px; letter-spacing: .12em; }
.total { margin: 0; font-size: 13px; color: var(--muted); }
.total b {
  font-family: var(--mincho);
  font-weight: 900;
  font-size: 32px;
  color: var(--accent);
  margin: 0 4px;
  font-variant-numeric: tabular-nums;
}
.total b { display: inline-block; }
.total b.bump { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }

.panel { display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.new-pill {
  align-self: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.new-pill:hover { filter: brightness(.95); }
.sort { display: flex; flex-wrap: wrap; gap: 6px; }
/* スマホでは履歴のタブを2つずつ2段に並べる */
@media (max-width: 480px) {
  #panelHistory .panel-head { flex-direction: column; align-items: stretch; }
  #panelHistory .sort { display: grid; grid-template-columns: 1fr 1fr; }
}
.sort button {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 14px;
  font-size: 13px;
  color: var(--muted);
}
.sort button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.meta { font-size: 12px; color: var(--muted); margin: 0; }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 8px;
}
.cards:empty { display: none; }
.cards.collapsed li:nth-child(n+7) { display: none; }
.more {
  align-self: center;
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 22px;
}
.more:hover { background: var(--ink); color: var(--bg); }
.cards li {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "word like" "time like";
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
  min-width: 0;
}
.cards li.jackpot { border-color: var(--gold); background: color-mix(in srgb, var(--gold-light) 22%, var(--bg)); }
.cards li.jackpot .word { color: var(--gold-deep); }
.cards li.jackpot time::before { content: "大当たり ・ "; color: var(--gold-deep); font-weight: 700; }
.cards li.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: var(--reel); } to { background: var(--bg); } }
.cards .word { grid-area: word; font-family: var(--mincho); font-weight: 900; font-size: 22px; line-height: 1.3; color: var(--accent); white-space: nowrap; overflow: hidden; min-width: 0; }
.cards time { grid-area: time; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.like {
  grid-area: like;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: transform .1s, color .2s, border-color .2s;
}
.like:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.like[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.like:active:not(:disabled) { transform: scale(.92); }
.like:disabled { cursor: default; opacity: .6; }
.like svg { width: 14px; height: 14px; }
.like[aria-pressed="true"] svg path { fill: currentColor; }
.empty { font-size: 13px; color: var(--muted); margin: 0; }

.combos { margin: -8px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ワード提案 */
.suggest {
  width: min(100%, 960px);
  margin: 56px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.suggest-lead { margin: 0; font-size: 13px; line-height: 1.8; color: var(--muted); }
.suggest-form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.slot-pick { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot-pick legend { font-size: 12px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.slot-pick label { cursor: pointer; }
.slot-pick input { position: absolute; opacity: 0; pointer-events: none; }
.slot-pick span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: var(--mincho);
  font-weight: 900;
  font-size: 17px;
  transition: border-color .2s, background-color .2s;
}
.slot-pick small { font-family: var(--gothic); font-weight: 500; font-size: 11px; color: var(--muted); }
.slot-pick input:checked + span { border-color: var(--accent); background: var(--reel); }
.slot-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.suggest-row { display: flex; gap: 8px; }
.suggest-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
}
.suggest-row input:focus { outline: none; border-color: var(--ink); }
.suggest-row button {
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  padding: 0 22px;
  white-space: nowrap;
}
.suggest-row button:hover:not(:disabled) { background: var(--accent); }
.suggest-row button:disabled, .suggest-row input:disabled { opacity: .5; cursor: default; }
.suggest-msg { margin: 0; font-size: 13px; min-height: 1.4em; color: var(--muted); }
.suggest-msg.ok { color: var(--ink); }
.suggest-msg.ng { color: var(--accent); }

.suggest-block { display: flex; flex-direction: column; gap: 10px; }
.sub { margin: 8px 0 0; font-size: 13px; letter-spacing: .12em; color: var(--muted); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}
.chips .w { font-family: var(--mincho); font-weight: 900; font-size: 15px; }
.chips .slot { font-size: 11px; color: var(--muted); }
.chips .st { font-size: 11px; font-weight: 700; color: var(--muted); }
.chips .st.approved { color: var(--accent); }
.chips button { background: none; padding: 0 2px; color: var(--muted); font-size: 14px; line-height: 1; }
.chips button:hover { color: var(--accent); }

.review { padding: 16px; border: 1.5px dashed var(--line); border-radius: 12px; }
.owner-tag { margin-left: 8px; font-size: 11px; letter-spacing: 0; color: var(--accent); }

/* ワード管理 */
.manage {
  width: min(100%, 960px);
  margin: 56px auto 0;
  padding: 20px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.manage .board-head { padding-bottom: 8px; }
.manage form { max-width: 560px; }
.manage-tools input {
  width: min(100%, 560px);
  font: inherit;
  font-size: 16px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.manage-tools input:focus { outline: none; border-color: var(--ink); }
.manage-list { max-height: 420px; overflow-y: auto; align-content: flex-start; }
.manage-list li.added { border-color: var(--accent); }
.undo { background: none; padding: 0 0 0 8px; font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: underline; }
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.review-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.review-list li:last-child { border-bottom: 0; }
.review-list .w { font-family: var(--mincho); font-weight: 900; font-size: 18px; }
.review-list .slot { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.review-list button { font-size: 13px; font-weight: 700; padding: 6px 14px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); }
.review-list button.yes { background: var(--ink); color: var(--bg); }
.review-list button.yes:hover { background: var(--accent); border-color: var(--accent); }

.site-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.site-foot p { margin: 0; }
.foot-links { display: flex; gap: 16px; }
.foot-links button { background: none; padding: 0; font-size: 11px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot-links button:hover { color: var(--ink); }

dialog.doc {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow-y: auto;
  padding: 28px 24px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.9;
}
dialog.doc::backdrop { background: rgb(0 0 0 / .45); }
dialog.doc h2 { margin: 0 0 12px; font-family: var(--mincho); font-weight: 900; font-size: 20px; }
dialog.doc h3 { margin: 18px 0 4px; font-size: 13px; letter-spacing: .08em; }
dialog.doc p, dialog.doc ul { margin: 0; }
dialog.doc ul { padding-left: 1.3em; }
dialog.doc dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 16px 0 0; }
dialog.doc dt { color: var(--muted); }
dialog.doc dd { margin: 0; }
dialog.doc a { color: var(--ink); font-weight: 700; }
.doc-date { margin-top: 18px !important; font-size: 11px; color: var(--muted); }
.doc-close { display: block; margin: 20px auto 0; background: var(--ink); color: var(--bg); font-weight: 700; padding: 10px 28px; }

footer { text-align: center; font-size: 11px; color: var(--muted); padding-block: 32px; }

button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .title.pop, .cards li.fresh, .callout.stamp, .title.jackpot .strip span { animation: none; }
}

img { max-width: 100%; }
.badge {
  margin: 0;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.shared-note { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.net-error { margin: 0; font-size: 12px; color: var(--accent); text-align: center; }
