/*
 * HEROINES メンバー当て
 * 配色: iLiFE! 公式トーン
 * タイポ: デジタル庁デザインシステム準拠（Noto Sans JP・16px基準・コントラスト重視）
 */

/* ==========================================================================
   1. Design Tokens
   ========================================================================== */

:root {
  /* --- カラー --- */
  --ilife-pink: #fd64ae;
  --ilife-pink-deep: #de4990;
  --ilife-pink-hot: #ff407d;
  --ilife-blush: #fff3f7;
  --ilife-rose: #ffd4e1;
  --ilife-mist: #f5f1ec;
  --ilife-white: #ffffff;
  --ilife-text: #212121;
  --ilife-muted: #545454;
  --ilife-shadow: 0 12px 40px rgba(222, 73, 144, 0.08);

  /* --- タイポグラフィ --- */
  --font-sans:
    "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans",
    sans-serif;
  --fs-body: 1rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.8125rem;
  --lh-body: 1.75;
  --lh-tight: 1.5;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-bold: 700;

  /* --- レイアウト --- */
  --radius: 14px;
  --radius-sm: 10px;
  --history-row-min-height: 4.5rem;

  /* --- メッセージ --- */
  --msg-danger: #ba0000;
  --msg-danger-bg: rgba(186, 0, 0, 0.06);
  --msg-ok: #0d7a52;
  --msg-ok-bg: rgba(13, 122, 82, 0.08);

  /* --- Wordle系ヒントセル --- */
  --rush-green: #6aaa64;
  --rush-yellow: #c9b458;
  --rush-miss: #d3d6da;
}

/* ==========================================================================
   2. Reset / Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ilife-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-normal);
  line-height: var(--lh-body);
  letter-spacing: 0;
  background-color: var(--ilife-white);
}

/* ==========================================================================
   3. Site Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: var(--ilife-pink);
}

.site-header__inner {
  max-width: 1060px;
  width: 92%;
  margin: 0 auto;
  padding: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ilife-white);
}

.site-header__brand:hover {
  opacity: 0.85;
}

.site-header__logo {
  font-size: 1.125rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.2em;
  color: var(--ilife-white);
}

.site-header__pipe {
  color: rgba(255, 255, 255, 0.5);
  font-weight: var(--fw-normal);
}

.site-header__sub {
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--ilife-white);
  letter-spacing: 0.04em;
}

/* --- Mode tabs (Daily / Free) --- */

.mode-tabs {
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
}

.mode-tabs__help {
  margin-left: 1rem;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.05em;
  color: var(--ilife-white);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.15);
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.mode-tab:hover {
  color: var(--ilife-white);
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.6);
}

.mode-tab[aria-selected="true"] {
  color: var(--ilife-pink);
  background: var(--ilife-white);
  border-color: var(--ilife-white);
}

/* --- Icon button (header help "？") --- */

.icon-btn {
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.15);
  color: var(--ilife-white);
  font-weight: var(--fw-medium);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.6);
}

/* ==========================================================================
   4. Status Bar
   ========================================================================== */

.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.25rem;
  padding: 0.6rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid #f5dbe7;
}

.status-bar__main {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.status-bar__meta {
  font-size: var(--fs-xs);
  color: var(--ilife-muted);
}

.status-bar__leagues {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
}

.status-bar__leagues[hidden] {
  display: none !important;
}

.status-bar__leagues-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  color: var(--ilife-muted);
  white-space: nowrap;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  background: #fde8f2;
  color: var(--ilife-pink);
  border: 1px solid var(--ilife-pink);
}

.mode-badge[data-mode="free"] {
  background: #eef2ff;
  color: #3946a0;
  border-color: #c8d0f4;
}

/* ==========================================================================
   5. Main Layout
   ========================================================================== */

.app {
  max-width: 1060px;
  width: 92%;
  margin: 0 auto;
  padding: 2rem 0 5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--ilife-muted);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   6. Panel / Card
   ========================================================================== */

.panel {
  background: var(--ilife-white);
  border: 1px solid var(--ilife-rose);
  border-radius: var(--radius);
  box-shadow: var(--ilife-shadow);
  padding: 1rem 2rem;
  margin-bottom: 2rem;
}

/* ==========================================================================
   7. Titles
   ========================================================================== */

.ttl {
  font-family: var(--font-sans);
  color: var(--ilife-pink);
  text-align: center;
  position: relative;
  padding-bottom: 1.375rem;
  margin: 0 0 1.75rem;
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}

.ttl::after {
  content: "";
  width: 50px;
  height: 0;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  border-bottom: 4px solid var(--ilife-pink);
}

.ttl--dialog {
  font-size: 1.25rem;
  margin-bottom: 0;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--ilife-rose);
}

.ttl--dialog::after {
  display: none;
}

/* ==========================================================================
   8. Toolbar (Group / Member selects + Buttons)
   ========================================================================== */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 1.5rem;
  align-items: flex-end;
}

.toolbar-picks {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0 0.65rem;
  flex: 1 1 100%;
  min-width: 0;
}

.toolbar-picks__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toolbar-picks__cell {
  flex: 1 1 0;
  min-width: 0;
}

.toolbar-picks__cell select {
  width: 100%;
}

.toolbar-picks__no {
  flex-shrink: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ilife-muted);
  line-height: 1;
  user-select: none;
  padding-bottom: 0.2rem;
}

.toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

/* ==========================================================================
   9. Form Elements
   ========================================================================== */

label {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  color: var(--ilife-pink);
}

select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--ilife-rose);
  background: var(--ilife-white);
  color: var(--ilife-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  transition:
    border-color 0.2s,
    background 0.2s;
}

select option {
  font-weight: var(--fw-medium);
  background: var(--ilife-white);
  color: var(--ilife-text);
}

select option.select-placeholder {
  font-weight: var(--fw-medium);
  color: var(--ilife-text);
}

select:has(option.select-placeholder:checked) {
  font-weight: var(--fw-medium);
}

select:focus {
  outline: none;
  border: 1.5px solid var(--ilife-pink);
  background: var(--ilife-white);
}

/* --- League checkbox --- */

.league-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  cursor: pointer;
  color: var(--ilife-muted);
}

.league-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  flex-shrink: 0;
  border: 1.5px solid var(--ilife-pink);
  border-radius: 3px;
  background-color: var(--ilife-white);
  cursor: pointer;
  vertical-align: middle;
  position: relative;
}

.league-check input[type="checkbox"]:checked {
  background-color: var(--ilife-pink);
  border-color: var(--ilife-pink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6l2.5 2.5L9.5 3.5'/%3E%3C/svg%3E");
  background-size: 0.65rem auto;
  background-position: center;
  background-repeat: no-repeat;
}

.league-check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ilife-pink);
  outline-offset: 2px;
}

.league-check input[type="checkbox"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ==========================================================================
   10. Buttons
   ========================================================================== */

.btn {
  min-height: 2.75rem;
  padding: 0.625rem 1.25rem;
  border-radius: 999px;
  border: none;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.15s,
    filter 0.2s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--ilife-pink);
  color: var(--ilife-white);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn--ghost {
  background: var(--ilife-white);
  color: var(--ilife-pink);
  border: 1px solid var(--ilife-pink);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(253, 100, 174, 0.1);
}

.btn--x {
  background: var(--ilife-pink);
  color: var(--ilife-white);
}

.btn--x:hover:not(:disabled) {
  filter: brightness(1.06);
}

/* ==========================================================================
   11. Messages
   ========================================================================== */

.msg {
  font-size: var(--fs-body);
  font-weight: var(--fw-normal);
  line-height: var(--lh-body);
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.msg--error {
  background: var(--msg-danger-bg);
  border-color: rgba(186, 0, 0, 0.25);
  color: var(--msg-danger);
}

.msg--success {
  background: var(--msg-ok-bg);
  border-color: rgba(13, 122, 82, 0.25);
  color: var(--msg-ok);
}

.msg--hint {
  background: var(--ilife-blush);
  border-color: var(--ilife-rose);
  color: var(--ilife-muted);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   12. History Table
   ========================================================================== */

.history-section {
  margin: 0 0 1.75rem;
}

.history-wrap {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--ilife-rose);
  background: var(--ilife-blush);
  padding: 0.6rem;
}

.history-scroll-hint {
  display: none;
  flex-shrink: 0;
  margin: 0 0 0.5rem;
  padding: 0.2rem 0.25rem;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--ilife-muted);
  text-align: center;
  line-height: var(--lh-tight);
  letter-spacing: 0.02em;
}

.history-scroll-hint__icon {
  display: inline-block;
  margin-right: 0.2em;
  font-size: 1.05em;
  opacity: 0.65;
  vertical-align: -0.05em;
}

.history-scroll {
  flex: 0 0 auto;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: calc(var(--radius-sm) - 2px);
  outline: none;
  scrollbar-color: rgba(222, 73, 144, 0.35) var(--ilife-blush);
}

.history-scroll:focus-visible {
  outline: 2px solid var(--ilife-pink);
}

.history-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  font-size: var(--fs-body);
  table-layout: fixed;
}

.history-table th,
.history-table td {
  padding: 0;
  border: none;
}

.history-table tbody td {
  vertical-align: middle;
  min-height: var(--history-row-min-height);
}

/* --- Sticky header & first column --- */

.history-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  box-shadow: 0 1px 0 var(--ilife-rose);
}

.history-table thead th:first-child,
.history-table tbody td:first-child {
  position: sticky;
  left: 0;
}

.history-table thead th:first-child {
  z-index: 6;
  box-shadow:
    4px 0 12px -4px rgba(34, 20, 40, 0.14),
    0 1px 0 var(--ilife-rose);
}

.history-table tbody td:first-child {
  z-index: 2;
  box-shadow: 4px 0 10px -4px rgba(34, 20, 40, 0.1);
}

.history-table tbody td:not(:first-child) {
  position: relative;
  z-index: 1;
}

/* --- Header cells --- */

.history-table th {
  font-family: var(--font-sans);
  color: var(--ilife-pink);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  letter-spacing: 0.03em;
  line-height: var(--lh-tight);
  white-space: nowrap;
  background: var(--ilife-white);
  padding: 0.5rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--ilife-rose);
  vertical-align: middle;
  text-align: center;
}

.history-table th:first-child {
  width: 15%;
}

/* --- Column hint buttons --- */

.history-th-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0.2rem 0.1rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
  text-align: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.2em;
  transition:
    text-decoration-color 0.15s ease,
    background 0.15s ease;
}

.history-th-btn:hover,
.history-th-btn:focus-visible {
  text-decoration-color: var(--ilife-pink);
  background: rgba(253, 100, 174, 0.09);
  outline: none;
}

/* --- Result cells --- */

.history-cell--name {
  background: var(--ilife-white);
  border: 1px solid var(--ilife-rose);
  border-radius: 6px;
  padding: 0.65rem 0.5rem;
  vertical-align: middle;
  text-align: center;
}

.result-cell {
  vertical-align: middle;
  text-align: center;
  padding: 0.5rem 0.35rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  font-size: clamp(0.875rem, 2vw, 0.9375rem);
  line-height: var(--lh-tight);
  word-break: break-word;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.result-cell--hit {
  background: var(--rush-green);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.result-cell--close {
  background: var(--rush-yellow);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.result-cell--miss {
  background: var(--rush-miss);
  color: var(--ilife-text);
}

.guess-label {
  display: block;
  font-weight: var(--fw-medium);
  font-size: var(--fs-body);
  line-height: var(--lh-tight);
  color: var(--ilife-text);
  font-family: var(--font-sans);
  text-align: center;
}

.guess-label--link {
  color: var(--ilife-pink-deep);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.15em;
  transition: text-decoration-color 0.15s ease;
}

.guess-label--link:hover {
  text-decoration-color: var(--ilife-pink-deep);
}

/* --- Legend --- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ilife-rose);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-body);
  color: var(--ilife-muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* 凡例直下のデータ出典・連絡先（アコーディオン） */
.data-about {
  margin-top: 1.35rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ilife-blush) 92%, var(--ilife-white));
  border: 1px solid color-mix(in srgb, var(--ilife-rose) 65%, transparent);
  text-align: left;
}

.data-about__summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.15rem;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.06em;
  color: var(--ilife-pink-deep);
  line-height: var(--lh-tight);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.data-about__summary::-webkit-details-marker {
  display: none;
}

.data-about__summary::after {
  content: "";
  width: 0.5em;
  height: 0.5em;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.65;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.data-about[open] .data-about__summary::after {
  transform: rotate(-135deg);
  margin-top: 0.35em;
}

.data-about__summary:hover {
  color: var(--ilife-pink-hot);
}

.data-about__summary:focus-visible {
  outline: 2px solid var(--ilife-pink-deep);
  outline-offset: 2px;
  border-radius: 6px;
}

.data-about__panel {
  padding: 0 1.15rem 1rem;
}

.data-about[open] .data-about__panel {
  border-top: 1px solid color-mix(in srgb, var(--ilife-rose) 65%, transparent);
}

.data-about__text {
  margin: 0;
  padding-top: 0.85rem;
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
  color: var(--ilife-muted);
}

.data-about__text a {
  color: var(--ilife-pink-deep);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-color: color-mix(
    in srgb,
    var(--ilife-pink-deep) 35%,
    transparent
  );
}

.data-about__text a:hover {
  text-decoration-color: var(--ilife-pink-deep);
}

.dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.dot--g {
  background: var(--rush-green);
}
.dot--y {
  background: var(--rush-yellow);
}
.dot--w {
  background: var(--rush-miss);
}

/* ==========================================================================
   13. Dialogs (shared)
   ========================================================================== */

.dialog {
  border: 1px solid var(--ilife-rose);
  border-radius: var(--radius);
  background: var(--ilife-white);
  color: var(--ilife-text);
  max-width: min(460px, 94vw);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(222, 73, 144, 0.2);
}

.dialog::backdrop {
  background: rgba(51, 51, 51, 0.45);
}

.dialog__body {
  padding: 1.25rem 1.5rem 1.5rem;
  font-size: var(--fs-body);
  font-weight: var(--fw-normal);
  color: var(--ilife-text);
  line-height: var(--lh-body);
}

.dialog__body p {
  margin: 0 0 1rem;
}
.dialog__body ul {
  margin: 0;
  padding-left: 1.4rem;
}

.dialog__body code {
  font-size: 0.9375em;
  font-weight: var(--fw-medium);
  padding: 0.1em 0.35em;
  background: var(--ilife-blush);
  border-radius: 4px;
}

.dialog__footer {
  padding: 0 2rem 2rem;
}

/* --- Column hint dialog --- */

.dialog--col-hint {
  width: 420px;
  max-width: calc(100vw - 2rem);
}

.dialog__body--col-hint {
  padding-top: 0.75rem;
}

.col-hint-intro {
  margin: 0 0 0.75rem;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ilife-text);
}

.col-hint-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.col-hint-list li {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  margin-bottom: 0.6rem;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
  color: var(--ilife-text);
}

.col-hint-list li:last-child {
  margin-bottom: 0;
}

.col-hint-list .dot {
  position: relative;
  top: 0.12em;
  flex-shrink: 0;
}

.col-hint-note {
  margin: 0.75rem 0 0;
  font-size: var(--fs-sm);
  color: var(--ilife-muted);
  line-height: var(--lh-body);
}

/* --- Win dialog --- */

.dialog--win {
  width: min(350px, calc(100vw - 40px));
  max-width: min(350px, calc(100vw - 40px));
}

.dialog--win .ttl--dialog {
  padding: 0.85rem 1.25rem 0.65rem;
}

.dialog__body--win {
  text-align: center;
  padding: 0.35rem 1.25rem 0.85rem;
}

.dialog__body--win p {
  margin-bottom: 0;
}

.win-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.win-card__photo {
  width: 11rem;
  height: 11rem;
  max-width: 100%;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--ilife-rose);
  background: var(--ilife-blush);
}

.win-card__name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: var(--fw-bold);
  color: var(--ilife-text);
  line-height: var(--lh-tight);
}

.win-card__meta {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ilife-muted);
}

.win-card__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.45rem;
  font-size: var(--fs-sm);
}

.win-card__sep {
  color: var(--ilife-rose);
  opacity: 0.8;
}

.win-card__link {
  color: var(--ilife-pink-deep);
  font-weight: var(--fw-medium);
  text-underline-offset: 0.2em;
}

.win-card__link:hover {
  color: var(--ilife-pink-hot);
}

.win-card__link--disabled {
  color: var(--ilife-muted);
  text-decoration: none;
  cursor: not-allowed;
  pointer-events: none;
}

.win-card__link--disabled:hover {
  color: var(--ilife-muted);
}

.dialog__footer--win {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding-bottom: 1.75rem;
}

.dialog__footer--win .btn {
  width: 100%;
  text-align: center;
}

/* --- Help dialog --- */

.dialog--help {
  max-width: min(520px, 94vw);
  max-height: min(92vh, 40rem);
  width: 100%;
}

.dialog--help[open] {
  display: flex;
  flex-direction: column;
}

.dialog--help .help-dialog__title.ttl--dialog {
  flex-shrink: 0;
}

.dialog--help .dialog__body--help {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.25rem 1.5rem 1.25rem;
  scrollbar-gutter: stable;
}

.dialog--help .dialog__footer--help {
  flex-shrink: 0;
  margin-top: auto;
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--ilife-rose);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92) 0%,
    var(--ilife-white) 12%
  );
}

/* ==========================================================================
   14. Help Content
   ========================================================================== */

.help-block {
  margin-bottom: 1.35rem;
}

.help-block:last-child {
  margin-bottom: 0;
}

.help-block__title {
  margin: 0 0 0.5rem;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.06em;
  color: var(--ilife-pink-deep);
  line-height: var(--lh-tight);
}

.help-block__lead {
  margin: 0 0 0.65rem;
  font-size: var(--fs-body);
}

.help-block__note {
  margin: 0 0 0.6rem;
  font-size: var(--fs-sm);
  color: var(--ilife-muted);
}

.help-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.help-list li {
  margin-bottom: 0.45rem;
}

.help-list li:last-child {
  margin-bottom: 0;
}

.help-list--numbered {
  padding-left: 1.35rem;
}

.help-list--compact {
  list-style: none;
  padding-left: 0;
}

.help-list--compact li {
  position: relative;
  padding-left: 1.35rem;
  margin-bottom: 0.4rem;
}

.help-list--compact li:last-child {
  margin-bottom: 0;
}

.help-dot {
  position: absolute;
  left: 0.2rem;
  top: 0.45em;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
}

.help-dot--g {
  background: var(--rush-green);
}
.help-dot--y {
  background: var(--rush-yellow);
}
.help-dot--w {
  background: var(--rush-miss);
}

.help-dl {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}

.help-dl dt {
  margin: 0.65rem 0 0.2rem;
  font-weight: var(--fw-bold);
  color: var(--ilife-text);
}

.help-dl dt:first-child {
  margin-top: 0;
}

.help-dl dd {
  margin: 0 0 0 0.1rem;
  color: var(--ilife-text);
}

/* ==========================================================================
   15. Footer
   ========================================================================== */

.app-footer {
  margin-top: 3.5rem;
  padding: 2rem 0 0;
  border-top: 1px solid var(--ilife-rose);
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  color: var(--ilife-muted);
  line-height: var(--lh-body);
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.app-footer code {
  font-size: 0.875em;
  padding: 0.1em 0.4em;
  background: var(--ilife-blush);
  border-radius: 4px;
  color: var(--ilife-text);
}

.app-footer__sep {
  margin: 0 0.4em;
  opacity: 0.5;
}

/* ==========================================================================
   16. Responsive
   ========================================================================== */

/* --- Tablet: 600px+ --- */

@media (min-width: 600px) {
  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.25rem 2rem;
    align-items: end;
  }

  .toolbar-picks {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 0.85rem;
    align-items: end;
    min-width: 0;
    max-width: min(100%, 42rem);
  }

  .toolbar-picks__label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    letter-spacing: 0.06em;
    color: var(--ilife-muted);
    line-height: 1.3;
  }

  .toolbar-picks__label--group {
    grid-column: 1;
    grid-row: 1;
  }
  .toolbar-picks__label--member {
    grid-column: 3;
    grid-row: 1;
  }

  .toolbar-picks__cell--group {
    grid-column: 1;
    grid-row: 2;
    flex: initial;
    min-width: 0;
  }

  .toolbar-picks__cell--member {
    grid-column: 3;
    grid-row: 2;
    flex: initial;
    min-width: 0;
  }

  .toolbar-picks__no {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    justify-self: center;
    padding: 0 0.1rem;
    font-size: var(--fs-body);
    font-weight: var(--fw-normal);
    color: var(--ilife-text);
    opacity: 0.55;
  }

  .toolbar__actions {
    justify-self: end;
    align-self: end;
    flex-wrap: nowrap;
  }
}

/* --- Narrow tablet: 600–799px --- */

@media (min-width: 600px) and (max-width: 799px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar__actions {
    justify-self: stretch;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .toolbar__actions .btn {
    flex: 1 1 8rem;
    justify-content: center;
  }
}

/* --- Small tablet / phone: ≤719px --- */

@media (max-width: 719px) {
  .history-scroll-hint {
    display: block;
  }

  .history-table {
    min-width: 39rem;
    width: max-content;
    max-width: none;
    table-layout: auto;
  }

  .history-table th:first-child,
  .history-table td:first-child {
    min-width: 5rem;
    max-width: 6.75rem;
  }
}

/* --- Phone: ≤599px --- */

@media (max-width: 599px) {
  :root {
    --history-row-min-height: 4rem;
    --mobile-controls-pad: calc(11.25rem + env(safe-area-inset-bottom, 0px));
  }

  .mode-tabs {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
    align-items: center;
  }

  .mode-tabs__help {
    margin-left: 0;
  }

  .app {
    padding: 1rem 0 var(--mobile-controls-pad);
  }

  .panel--controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
  }

  .history-table th {
    font-size: var(--fs-xs);
    padding: 0.4rem 0.2rem;
  }

  .result-cell {
    font-size: var(--fs-xs);
    padding: 0.4rem 0.25rem;
  }

  .history-cell--name {
    padding: 0.45rem 0.4rem;
  }

  .guess-label {
    font-size: var(--fs-sm);
  }

  .toolbar__actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .toolbar__actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}
