/* すごろく計算機。色はすべてここの変数で管理する。マスの色は盤面の札に合わせている。 */
:root {
  color-scheme: dark;
  --bg: #121419;
  --surface: #1b1e26;
  --surface-2: #232733;
  --surface-3: #2d3241;
  --line: #3a4152;
  --text: #eef1f6;
  --muted: #a0a8b6;
  --accent: #ffcf3d;
  --accent-text: #1c1500;
  --focus: #8db8ff;
  --plus: #5fd896;
  --minus: #ff7b7b;
  --danger: #ff6161;
  --sq-blue: #2a6cff;
  --sq-red: #ff4a4a;
  --sq-vs: #ffe066;
  --sq-vs-text: #e0150c;
  --sq-shop: #d6ffa4;
  --sq-shop-text: #6c8b8b;
  --sq-event: #ffb7e6;
  --sq-pool: #a3678b;
  --tile-border: #05060a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--focus);
}

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

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.plus {
  color: var(--plus);
}

.minus {
  color: var(--minus);
}

.zero {
  color: var(--muted);
}

.plus,
.minus,
.zero,
.amount-input,
.player-points,
.standing-points,
.catalog-value,
.shop-price,
time {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- ボタン・入力 */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  background: var(--surface-3);
}

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

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button-primary:hover:not(:disabled) {
  background: #ffdb6b;
}

.button-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.button-ghost {
  background: transparent;
  border-color: transparent;
}

.button-small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.button-block {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.icon-button:disabled {
  opacity: 0.35;
}

.text-input,
.amount-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #586178;
  border-radius: 10px;
  background: var(--bg);
}

.amount-input {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
}

.unit-input {
  max-width: 120px;
}

textarea.text-input {
  resize: vertical;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.field-label {
  margin: 4px 0 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.inline-label .amount-input {
  max-width: 180px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.form-error {
  margin: 0;
  min-height: 0;
  color: var(--minus);
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-section {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-tools .amount-input {
  max-width: 150px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.quick-adds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-adds .chip {
  min-height: 32px;
  font-size: 0.85rem;
  padding: 0 10px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.seg {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.seg + .seg {
  border-left: 1px solid var(--line);
}

.seg.on {
  background: var(--accent);
  color: var(--accent-text);
}

.signed-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.badge-live {
  border-color: var(--accent);
  color: var(--accent);
}

.empty {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty p {
  margin: 4px 0;
}

/* ---------------------------------------------------------------- 上のバー */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  background: rgba(18, 20, 25, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--tile-border);
  border-radius: 4px;
  background: conic-gradient(var(--sq-event) 0 60deg, var(--sq-shop) 0 120deg, var(--sq-vs) 0 180deg, var(--sq-pool) 0 240deg, var(--sq-red) 0 300deg, var(--sq-blue) 0);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  gap: 4px;
}

@media (max-width: 560px) {
  .brand {
    font-size: 0;
    gap: 0;
  }

  .topbar-title {
    color: var(--text);
  }
}

/* ---------------------------------------------------------------- 共通のページ */

.page {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-head p {
  margin: 0;
}

/* ---------------------------------------------------------------- 合言葉 */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 16px;
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.login-card p {
  margin: 0;
}

.login-mark {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.mini-sq {
  display: grid;
  place-items: center;
  height: 44px;
  border: 2px solid var(--tile-border);
  font-weight: 900;
  font-size: 0.7rem;
}

.mini-0 {
  background: var(--sq-event);
  color: #000;
  font-size: 1.3rem;
}

.mini-1 {
  background: var(--sq-shop);
  color: var(--sq-shop-text);
  font-style: italic;
  transform: none;
}

.mini-2 {
  background: var(--sq-vs);
  color: var(--sq-vs-text);
  font-size: 1rem;
}

.mini-3 {
  background: var(--sq-blue);
}

.mini-4 {
  background: var(--sq-red);
}

.mini-5 {
  background: var(--sq-pool);
}

/* ---------------------------------------------------------------- ゲーム一覧 */

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.game-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.game-card:hover {
  border-color: var(--accent);
}

.game-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

/* ---------------------------------------------------------------- ゲームの作成・設定 */

.player-rows {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto;
  gap: 8px;
  align-items: center;
}

.player-row .signed-field {
  min-width: 0;
}

.player-row .seg {
  padding: 0 10px;
}

.table-editor {
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--sq-blue);
  border-radius: 10px;
  display: grid;
  gap: 10px;
}

.table-editor.tone-red {
  border-left-color: var(--sq-red);
}

.table-editor legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: 0.9rem;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.table-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-cell .die {
  --die: 26px;
  flex-shrink: 0;
}

.table-input {
  min-height: 38px;
  padding: 6px 8px;
  font-size: 1rem;
}

.table-fill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-fill .amount-input {
  max-width: 130px;
  min-height: 36px;
  font-size: 1rem;
}

@media (min-width: 720px) {
  .table-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.order-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  counter-reset: order;
}

.order-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  counter-increment: order;
}

.order-list li::before {
  content: counter(order);
  width: 22px;
  color: var(--muted);
  text-align: center;
}

.order-name {
  flex: 1;
  font-weight: 600;
}

/* ---------------------------------------------------------------- ゲーム画面 */

.game {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 12px 12px 0;
  display: grid;
  gap: 16px;
}

.game-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

@media (min-width: 1000px) {
  .game {
    grid-template-columns: minmax(0, 1fr) 380px;
    padding: 16px;
    align-items: start;
  }

  .history {
    position: sticky;
    top: 70px;
    max-height: calc(100dvh - 86px);
    overflow: auto;
  }
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pool-card {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px;
  border: 2px solid var(--tile-border);
  border-radius: 10px;
  background: var(--sq-pool);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.pool-label {
  font-weight: 700;
}

.pool-card strong {
  font-size: 1.6rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pool-card strong.minus {
  color: #ffd0d0;
}

.finished-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
}

.players {
  display: grid;
  gap: 8px;
}

@media (min-width: 640px) {
  .players {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.player-card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.player-card.turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 207, 61, 0.18);
}

.player-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px 4px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.seat {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
}

.turn .seat {
  background: var(--accent);
  color: var(--accent-text);
}

.player-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-points {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.player-points strong {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.player-points small {
  color: var(--muted);
}

.player-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 8px 50px;
  min-height: 36px;
}

.items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.item-chip {
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(214, 255, 164, 0.14);
  color: var(--sq-shop);
  font-size: 0.78rem;
}

.more {
  margin-left: auto;
  width: 32px;
  height: 32px;
}

.flash {
  position: absolute;
  right: 0;
  top: -16px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg);
  font-weight: 800;
  font-size: 0.9rem;
  pointer-events: none;
  animation: flash 3.2s ease-out forwards;
}

.pool-card .flash {
  top: -12px;
  right: 8px;
}

@keyframes flash {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* マスのボタン（盤面の札の色） */
.pad {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  gap: 8px;
  margin: 0 -12px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: rgba(27, 30, 38, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

@media (min-width: 1000px) {
  .pad {
    position: static;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
  }
}

.pad-head,
.pad-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pad-tools {
  justify-content: flex-start;
}

.squares {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 640px) {
  .squares {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.sq {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  min-height: 64px;
  padding: 4px;
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18), 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: transform 0.06s ease;
}

.sq:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.sq:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

@media (min-width: 640px) {
  .sq {
    aspect-ratio: 1;
    min-height: 0;
  }
}

.sq-label {
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1.05;
}

.sq-hint {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.85;
}

.sq-blue {
  background: var(--sq-blue);
  color: #fff;
}

.sq-red {
  background: var(--sq-red);
  color: #fff;
}

.sq-vs {
  background: var(--sq-vs);
  color: #000;
}

.sq-vs .sq-label {
  color: var(--sq-vs-text);
  font-size: 1.8rem;
  letter-spacing: -0.04em;
  -webkit-text-stroke: 1px #6b0000;
}

.sq-shop {
  background: var(--sq-shop);
  color: #2e4040;
}

.sq-shop .sq-label {
  color: var(--sq-shop-text);
  font-style: italic;
  transform: rotate(-12deg);
  font-size: 1.25rem;
}

.sq-event {
  background: var(--sq-event);
  color: #000;
}

.sq-event .sq-label {
  font-size: 2rem;
}

.sq-pool {
  background: var(--sq-pool);
  color: #fff;
}

.sq-pool .sq-label {
  font-size: 1.1rem;
}

.sq-pool .sq-hint {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* 記録 */
.history {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  margin-bottom: 16px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.entries {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
}

.entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 4px 8px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 4px solid transparent;
}

.entry time {
  color: var(--muted);
  font-size: 0.8rem;
  padding-top: 2px;
}

.entry-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.entry-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.entry.undone .entry-summary {
  text-decoration: line-through;
  color: var(--muted);
}

.entry.undone {
  opacity: 0.6;
}

.entry-blue {
  border-left-color: var(--sq-blue);
}

.entry-red {
  border-left-color: var(--sq-red);
}

.entry-vs {
  border-left-color: var(--sq-vs);
}

.entry-shop {
  border-left-color: var(--sq-shop);
}

.entry-event {
  border-left-color: var(--sq-event);
}

.entry-pool {
  border-left-color: var(--sq-pool);
}

.entry-start,
.entry-join {
  border-left-color: var(--muted);
}

/* ---------------------------------------------------------------- ダイアログ */

.sheet {
  width: min(520px, 100%);
  max-width: 100%;
  max-height: min(92dvh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}

.sheet-wide {
  width: min(760px, 100%);
}

.sheet::backdrop {
  background: rgba(5, 6, 10, 0.66);
}

.tone-blue {
  border-top-color: var(--sq-blue);
}

.tone-red {
  border-top-color: var(--sq-red);
}

.tone-vs {
  border-top-color: var(--sq-vs);
}

.tone-shop {
  border-top-color: var(--sq-shop);
}

.tone-event {
  border-top-color: var(--sq-event);
}

.tone-pool {
  border-top-color: var(--sq-pool);
}

@media (max-width: 640px) {
  .sheet,
  .sheet-wide {
    width: 100%;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 1.1rem;
}

.sheet-body {
  display: grid;
  gap: 12px;
  padding: 14px 18px max(18px, env(safe-area-inset-bottom));
}

.sheet-body p {
  margin: 0;
}

.confirm-text {
  white-space: pre-wrap;
}

/* ダイスの目 */
.faces {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.face {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.face.on {
  border-color: var(--accent);
  background: rgba(255, 207, 61, 0.14);
}

.face-amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.die {
  --die: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--die) * 0.06);
  width: var(--die);
  height: var(--die);
  padding: calc(var(--die) * 0.14);
  border-radius: calc(var(--die) * 0.2);
  background: #f6f6f2;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.pip {
  border-radius: 50%;
}

.pip.on {
  background: #111;
}

.die-1 .pip.on {
  background: #d4161b;
  transform: scale(1.25);
}

/* 結果の見込み */
.preview {
  display: grid;
  gap: 6px;
}

.preview:empty {
  display: none;
}

.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.preview-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-from,
.preview-arrow {
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-pool {
  background: rgba(163, 103, 139, 0.22);
}

.pool-message {
  font-size: 1.1rem;
  font-weight: 700;
}

/* SHOP */
.shop-list {
  display: grid;
  gap: 8px;
}

.shop-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.shop-row.on {
  border-color: var(--sq-shop);
  background: rgba(214, 255, 164, 0.07);
}

.shop-info {
  display: grid;
  min-width: 0;
}

.shop-price {
  font-weight: 700;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty {
  min-width: 22px;
  text-align: center;
  font-weight: 800;
}

.shop-sum {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.shop-total {
  font-size: 1.2rem;
  margin-right: auto;
}

/* ？マス */
.event-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 150px;
  padding: 18px 16px;
  border: 2px solid var(--tile-border);
  border-radius: 14px;
  background: var(--sq-event);
  color: #1a0f16;
  text-align: center;
}

.event-card.flip {
  animation: flip 0.45s ease-out;
}

@keyframes flip {
  0% {
    transform: perspective(600px) rotateY(80deg);
    opacity: 0.2;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

.event-mark {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}

.event-title {
  font-size: 1.35rem;
}

.event-desc {
  white-space: pre-wrap;
}

.event-effect {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.82rem;
  font-weight: 700;
}

.row-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-tools select {
  flex: 1;
  min-width: 160px;
}

/* プレイヤーの詳細 */
.player-detail {
  display: grid;
  gap: 2px;
}

.big-points {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.owned-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.owned-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* 順位 */
.ranking {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.ranking li {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.ranking .rank-1 {
  background: rgba(255, 207, 61, 0.16);
  outline: 1px solid var(--accent);
}

.rank-no {
  font-weight: 900;
}

.rank-points {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- トースト */

/* スマホでは画面の上に出す（下はマスのボタンがあるため隠さない） */
.toast-host {
  position: fixed;
  inset: 62px 0 auto 0;
  width: min(520px, calc(100% - 24px));
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  display: grid;
  gap: 8px;
}

.toast-host:not(:popover-open) {
  display: none;
}

@media (min-width: 1000px) {
  .toast-host {
    inset: auto 0 24px 0;
  }
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2a2f3c;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-weight: 600;
}

.toast-error {
  border-color: var(--danger);
}

.toast-action {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

/* ---------------------------------------------------------------- アイテム・イベントの編集 */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab.on {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.catalog-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.catalog-row.inactive {
  opacity: 0.6;
}

.catalog-row .badge {
  grid-column: 2;
}

.catalog-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.catalog-value {
  font-weight: 800;
}

.effect-text {
  color: var(--sq-event);
}

.weight-input {
  max-width: 120px;
}

@media (max-width: 560px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------------------------------------------------------------- 閲覧専用 */

.viewer {
  min-height: 100dvh;
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 6px;
  width: min(900px, 100%);
  margin: 0 auto;
}

.viewer-head h1 {
  font-size: 1.3rem;
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--plus);
  box-shadow: 0 0 0 4px rgba(95, 216, 150, 0.2);
}

.live-dot.off {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 97, 97, 0.2);
}

.viewer-main {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 8px 16px 24px;
  display: grid;
  gap: 12px;
}

.viewer-pool {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 18px;
  border: 2px solid var(--tile-border);
  border-radius: 12px;
  background: var(--sq-pool);
  color: #fff;
  font-weight: 700;
}

.viewer-pool strong {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.viewer-pool strong.minus {
  color: #ffd0d0;
}

.viewer-latest {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.1rem;
}

.viewer-latest.entry-blue {
  border-left-color: var(--sq-blue);
}

.viewer-latest.entry-red {
  border-left-color: var(--sq-red);
}

.viewer-latest.entry-vs {
  border-left-color: var(--sq-vs);
}

.viewer-latest.entry-shop {
  border-left-color: var(--sq-shop);
}

.viewer-latest.entry-event {
  border-left-color: var(--sq-event);
}

.viewer-latest.entry-pool {
  border-left-color: var(--sq-pool);
}

.viewer-board,
.viewer-history {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.viewer-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.viewer-history h2 {
  margin-bottom: 6px;
}

.standings {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.standing {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--surface-2);
}

.standing.turn {
  border-color: var(--accent);
}

.standing .seat {
  width: auto;
  min-width: 32px;
  border-radius: 8px;
  padding: 0 4px;
}

.standing.turn .seat {
  background: var(--accent);
  color: var(--accent-text);
}

.standing-name {
  display: grid;
  min-width: 0;
  font-size: 1.15rem;
}

.standing-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standing-points {
  display: grid;
  justify-items: end;
  grid-template-columns: auto auto;
  column-gap: 4px;
  align-items: baseline;
}

.standing-points strong {
  font-size: 1.7rem;
  font-weight: 900;
}

.standing-points .muted {
  grid-column: 1 / -1;
}

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