/* ==========================================================================
   乾杯ゲームズ
   配色は居酒屋の夜から。藍色の店内、琥珀色の酒、赤提灯。
   暗い店で酔った人が見るため、文字は大きく、タップ領域は広く取っている。
   ========================================================================== */

:root {
  --ai:        #101b2e;  /* 藍 — 背景 */
  --ai-deep:   #0a1220;  /* 藍の影 */
  --ai-light:  #1b2b45;  /* 面 */
  --ai-line:   #2c3f5e;  /* 罫 */
  --kinari:    #f3ede2;  /* 生成り — 文字 */
  --kasumi:    #93a5c2;  /* 霞 — 補助文字 */
  --kohaku:    #e9a94a;  /* 琥珀 — 既定のアクセント */
  --shu:       #d8563f;  /* 朱 — 注意・警告 */

  --accent: var(--kohaku);

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;

  --tap: 60px;           /* 最小タップ高さ */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--ai);
  color: var(--kinari);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic UI", "Yu Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

.app {
  min-height: 100dvh;
  max-width: 480px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- 上部バー ---------- */

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--ai-line);
}
.topbar[hidden] { display: none; }

.topbar__back {
  font-size: 14px;
  color: var(--kasumi);
  padding: 6px 2px;
}
.topbar__back:hover { color: var(--kinari); }

.topbar__title { font-size: 15px; font-weight: 700; }

.topbar__meta {
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- ホーム ---------- */

.home__head {
  padding: 18px 0 30px;
}
.home__mark {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.home__note {
  margin-top: 10px;
  color: var(--kasumi);
  font-size: 14px;
}

.menu { display: flex; flex-direction: column; gap: 12px; }

.menu__item {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  text-align: left;
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-m);
  padding: 14px 16px 14px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.menu__item:hover,
.menu__item:focus-visible { border-color: var(--tint); background: #1f3150; }

.menu__kanji {
  display: grid;
  place-items: center;
  border-radius: var(--r-s);
  background: color-mix(in srgb, var(--tint) 18%, transparent);
  color: var(--tint);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.menu__name { display: block; font-size: 18px; font-weight: 700; line-height: 1.4; }
.menu__tagline { display: block; font-size: 13px; color: var(--kasumi); line-height: 1.5; margin-top: 2px; }
.menu__players {
  display: block;
  font-size: 12px;
  color: var(--tint);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.home__links {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.home__links button {
  flex: 1;
  padding: 14px 8px;
  border-radius: var(--r-s);
  border: 1px solid var(--ai-line);
  background: var(--ai-light);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--kinari);
  transition: border-color 0.15s;
}
.home__links button:hover { border-color: var(--kohaku); }

.home__foot {
  margin-top: auto;
  padding-top: 24px;
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--kasumi);
}

/* ---------- 共有 ---------- */

.share { margin-top: 22px; }
.share__row {
  border-top: 1px solid var(--ai-line);
  padding-top: 18px;
}
.share__label {
  display: block;
  font-size: 12.5px;
  color: var(--kasumi);
  margin-bottom: 10px;
}
.share__buttons { display: flex; gap: 8px; }
.share__btn {
  flex: 1;
  padding: 12px 6px;
  border-radius: var(--r-s);
  border: 1px solid var(--ai-line);
  background: var(--ai-light);
  color: var(--kinari);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.15s;
}
.share__btn:hover { border-color: var(--kohaku); }
.share__btn--line { color: #5ac461; }
.share__btn--x { color: var(--kinari); }

/* ---------- ゲームの入口 ---------- */

.intro { display: flex; flex-direction: column; gap: 18px; }

.intro__head { text-align: center; padding-top: 6px; }
.intro__kanji {
  display: inline-grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: var(--r-s);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.intro__name { font-size: 25px; font-weight: 700; margin-top: 12px; }
.intro__tagline { font-size: 13.5px; color: var(--kasumi); margin-top: 2px; }

.rules {
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-m);
  padding: 18px 20px;
}
.rules__head {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 12px;
  font-weight: 700;
}
.rules__list {
  margin: 0;
  padding-left: 1.35em;
  font-size: 14px;
  line-height: 1.85;
  color: var(--kinari);
}
.rules__list li { margin-bottom: 7px; }
.rules__list li::marker { color: var(--accent); font-weight: 700; }

/* ---------- 自作お題の編集 ---------- */

.editor { display: flex; flex-direction: column; flex: 1; }

.input {
  width: 100%;
  min-height: 52px;
  padding: 14px;
  border-radius: var(--r-s);
  border: 1px solid var(--ai-line);
  background: var(--ai);
  color: var(--kinari);
  font-family: inherit;
  font-size: 16px;   /* iOSで入力時に拡大されないよう16px以上を保つ */
}
.input:focus { border-color: var(--accent); outline: none; }

.editor [data-form] .btn { margin-top: 18px; }

.editor__status {
  font-size: 13px;
  color: var(--kasumi);
  min-height: 1.6em;
  margin: 12px 2px 0;
}
.editor__status.is-error { color: var(--shu); }

.editor__head {
  font-size: 14px;
  font-weight: 700;
  margin: 24px 0 12px;
}
.editor__head span { color: var(--kasumi); font-weight: 500; }

.editor__list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.editor__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-s);
  padding: 12px 14px;
}
.editor__text { font-size: 14px; line-height: 1.6; word-break: break-word; }
.editor__del {
  font-size: 12.5px;
  color: var(--shu);
  padding: 8px 4px;
}
.editor__empty {
  font-size: 13px;
  color: var(--kasumi);
  line-height: 1.8;
  padding: 4px 2px;
}

/* ---------- 汎用ページ ---------- */

.page { display: flex; flex-direction: column; flex: 1; }
.page__title { font-size: 24px; font-weight: 700; margin-bottom: 14px; }
.page__block { margin-top: 26px; }
.page__head {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.page__empty {
  font-size: 14px;
  color: var(--kasumi);
  line-height: 1.9;
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-m);
  padding: 22px 20px;
}

.pr {
  font-size: 12px;
  color: var(--kasumi);
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-s);
  padding: 9px 12px;
  margin-bottom: 16px;
}

.goods { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.goods__item {
  display: block;
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-m);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}
.goods__item:hover { border-color: var(--kohaku); }
.goods__name { display: block; font-size: 16px; font-weight: 700; }
.goods__note {
  display: block;
  font-size: 13px;
  color: var(--kasumi);
  line-height: 1.75;
  margin-top: 5px;
}
.goods__link {
  display: block;
  font-size: 12.5px;
  color: var(--kohaku);
  margin-top: 10px;
}

.log { font-size: 13.5px; line-height: 1.8; }
.log dt { color: var(--kasumi); font-variant-numeric: tabular-nums; margin-top: 10px; }
.log dd { margin-left: 0; }

/* ---------- 汎用パーツ ---------- */

.panel {
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-l);
  padding: 22px 20px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; min-height: 16px; }

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 17px 18px;
  border-radius: var(--r-m);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  transition: transform 0.1s, opacity 0.15s;
}
.btn[hidden] { display: none; }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.35; cursor: default; }

.btn--go {
  background: var(--accent);
  color: var(--ai-deep);
}
.btn--sub {
  background: transparent;
  color: var(--kinari);
  border: 1px solid var(--ai-line);
}
.btn--quiet {
  min-height: 0;
  padding: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--kasumi);
}

.lede { font-size: 14px; color: var(--kasumi); line-height: 1.85; }

/* ---------- 人数設定 ---------- */

.setup__title { font-size: 22px; font-weight: 700; }
.setup__desc { margin-top: 8px; margin-bottom: 26px; }

.counter {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  align-items: center;
  gap: 10px;
}
.counter__btn {
  height: var(--tap);
  border-radius: var(--r-s);
  border: 1px solid var(--ai-line);
  background: var(--ai);
  font-size: 26px;
  line-height: 1;
  transition: border-color 0.15s;
}
.counter__btn:hover:not(:disabled) { border-color: var(--accent); }
.counter__btn:disabled { opacity: 0.3; cursor: default; }
.counter__value {
  text-align: center;
  font-size: 44px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.counter__unit { font-size: 16px; font-weight: 500; color: var(--kasumi); margin-left: 4px; }

.switch {
  display: flex;
  gap: 8px;
  background: var(--ai);
  border-radius: var(--r-s);
  padding: 5px;
}
.switch__opt {
  flex: 1;
  padding: 13px 6px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--kasumi);
  transition: background 0.15s, color 0.15s;
}
.switch__opt[aria-pressed="true"] { background: var(--accent); color: var(--ai-deep); }

.field + .field { margin-top: 24px; }
.field__label { display: block; font-size: 13.5px; color: var(--kasumi); margin-bottom: 12px; }

/* ---------- カードを回す（王様・ワードウルフ共通） ---------- */

.pass { flex: 1; display: flex; flex-direction: column; }

.pass__who {
  text-align: center;
  font-size: 23px;
  font-weight: 700;
}
.pass__hint {
  text-align: center;
  font-size: 13.5px;
  color: var(--kasumi);
  margin-top: 6px;
  min-height: 1.7em;
}

.pass__stage {
  flex: 1;
  display: grid;
  place-items: center;
  perspective: 1400px;
  padding: 26px 0;
  min-height: 260px;
}

.card {
  position: relative;
  width: 100%;
  max-width: 250px;
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.35, 0.1, 0.2, 1);
}
.card.is-open { transform: rotateY(180deg); }

.card__side {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.card__side--back {
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  color: var(--kasumi);
}
.card__seal {
  font-size: 40px;
  color: var(--accent);
  opacity: 0.85;
  font-weight: 700;
}
.card__prompt { font-size: 13px; }

.card__side--face {
  transform: rotateY(180deg);
  background: var(--kinari);
  color: var(--ai-deep);
}
.card__side--face.is-special { background: var(--accent); }

.card__main {
  font-size: 68px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.card__main.is-long { font-size: 40px; }
.card__sub { font-size: 14px; font-weight: 700; opacity: 0.7; }

/* ---------- 読み札（なぞなぞ・白状・早口） ---------- */

.slate {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  background: var(--ai-light);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-l);
  padding: 34px 24px;
  min-height: 240px;
  text-align: center;
}
.slate__body {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.75;
}
.slate__body--tight { font-size: 21px; }
.slate__answer {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  padding-top: 20px;
  border-top: 1px solid var(--ai-line);
}
.slate__count {
  font-size: 12.5px;
  color: var(--kasumi);
  font-variant-numeric: tabular-nums;
}

/* ---------- タイマー ---------- */

.clock { text-align: center; padding: 8px 0 4px; }
.clock__num {
  font-size: 76px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.clock__num.is-urgent { color: var(--shu); }
.clock__rail {
  height: 5px;
  border-radius: 3px;
  background: var(--ai-light);
  margin-top: 16px;
  overflow: hidden;
}
.clock__fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transition: transform 0.25s linear, background 0.25s;
}
.clock__fill.is-urgent { background: var(--shu); }

.verdict {
  text-align: center;
  font-size: 27px;
  font-weight: 800;
  color: var(--shu);
}

/* ---------- アクセシビリティ ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media (min-height: 780px) {
  .card { max-width: 276px; }
  .slate__body { font-size: 27px; }
}
