:root {
  --bg0: #0a0d18;
  --bg1: #141a33;
  --ink: #eef1fa;
  --muted: #98a2bd;
  --line: rgba(255, 255, 255, .1);
  --panel: rgba(255, 255, 255, .06);
  --panel2: rgba(255, 255, 255, .11);
  --sheet: #171d37;

  --fire1: #ff9050;  --fire2: #e2283f;
  --water1: #54c2ff; --water2: #2b5ae6;
  --wind1: #63e6a8;  --wind2: #0c9b6c;
  --light1: #fffbe6; --light2: #f5bd41;
  --dark1: #7d66ee;  --dark2: #1a1340;

  --amb: #a895ff;                                         /* いまの場の属性の色 */
  --card-w: clamp(56px, min(9.4vw, 13.4vh), 96px);        /* カードの幅。すべての寸法がこれに連動 */

  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --num: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg0);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.defs { position: absolute; }

/* ---------- 全体 ---------- */
#app {
  position: relative;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(180deg, var(--bg1), var(--bg0));
  overflow: hidden;
}
#app[data-color="fire"]  { --amb: #ff6a45; }
#app[data-color="water"] { --amb: #4aa3ff; }
#app[data-color="wind"]  { --amb: #3fd99a; }
#app[data-color="free"]  { --amb: #a895ff; }
/* 場の属性の色がテーブル全体ににじむ */
#app::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--amb);
  opacity: .22;
  -webkit-mask: radial-gradient(62% 56% at 50% 44%, #000, transparent 74%);
          mask: radial-gradient(62% 56% at 50% 44%, #000, transparent 74%);
  transition: background-color .7s ease;
  pointer-events: none;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.logo { width: 24px; height: 24px; }
.brand-name { font-family: var(--num); font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.round-chip {
  font-family: var(--num);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .08em;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.round-chip.final { background: #ffd166; color: #201a05; border-color: transparent; }
.top-actions { display: flex; gap: 6px; }
.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.ghost-btn:hover { background: var(--panel2); }

/* ---------- テーブル ---------- */
.table {
  position: relative;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(0, 2.2fr) minmax(150px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    ".    top    ."
    "left center right"
    "me   me     me";
  gap: 6px 12px;
  padding: 4px 16px max(12px, env(safe-area-inset-bottom));
  min-height: 0;
}
.seat-left  { grid-area: left; }
.seat-top   { grid-area: top; }
.seat-right { grid-area: right; }

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  align-self: center;
  justify-self: center;
  min-width: 0;
}
.seat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: box-shadow .3s, border-color .3s, background .3s;
  min-width: 168px;
}
.turn > .seat-card,
.me.turn .me-card {
  border-color: var(--amb);
  background: var(--panel2);
  box-shadow: 0 0 0 1px var(--amb), 0 0 30px -6px var(--amb);
}
.avatar {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--num);
  font-weight: 800; font-size: 15px;
  color: #fff;
  background: linear-gradient(140deg, hsl(var(--hue) 72% 64%), hsl(calc(var(--hue) + 28) 62% 40%));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.avatar.you { font-size: 11px; letter-spacing: .04em; }
.seat-info { min-width: 0; }
.seat-name { font-weight: 700; font-size: 14px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.seat-score { font-family: var(--num); font-size: 12px; color: var(--muted); white-space: nowrap; }
.seat-score b { color: var(--ink); font-size: 14px; font-weight: 800; }
.seat-count {
  margin-left: auto;
  padding-left: 6px;
  font-family: var(--num);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
}
.seat-count small { font-family: var(--font); font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 1px; }
.seat-count.low  { color: #ffd166; }
.seat-count.high { color: #ff6b78; }
.think { display: none; gap: 3px; }
.thinking .think { display: inline-flex; }
.think i { width: 4px; height: 4px; border-radius: 50%; background: var(--amb); animation: think 1s infinite; }
.think i:nth-child(2) { animation-delay: .15s; }
.think i:nth-child(3) { animation-delay: .3s; }
@keyframes think { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.seat-hand { display: flex; height: 28px; padding-left: 10px; }
.mini-back {
  width: 19px; height: 27px;
  margin-left: -10px;
  border-radius: 4px;
  background: linear-gradient(155deg, #3d4674, #1c2142);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2), 0 1px 3px rgba(0, 0, 0, .45);
}

/* 行動の吹き出し */
.bubble {
  position: absolute;
  left: 50%; top: 100%;
  translate: -50% 4px;
  z-index: 30;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  color: #151a30;
  font-weight: 800; font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.bubble[data-tone="atk"] { background: #ff4d5e; color: #fff; }
.bubble.show { animation: bubble 1.5s ease both; }
@keyframes bubble {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  12%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}
#me-bubble { top: 0; translate: -50% -115%; }

/* ---------- 場 ---------- */
.center {
  grid-area: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: calc(var(--card-w) * 1.42 + 58px);
}
.ring-wrap {
  position: absolute;
  left: 50%; top: 50%;
  width: calc(var(--card-w) * 4.4);
  aspect-ratio: 1;
  translate: -50% -54%;
  color: var(--amb);
  opacity: .55;
  pointer-events: none;
  transition: color .7s, scale .5s cubic-bezier(.3, 1.4, .5, 1);
}
#app[data-dir="-1"] .ring-wrap { scale: -1 1; }
.ring { width: 100%; height: 100%; overflow: visible; animation: spin 44s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage { position: relative; z-index: 1; display: flex; align-items: center; gap: calc(var(--card-w) * .34); }
.deck {
  position: relative;
  width: var(--card-w);
  height: calc(var(--card-w) * 1.42);
  padding: 0; border: 0; background: none;
  border-radius: calc(var(--card-w) * .11);
  cursor: default;
}
.deck-stack .card { position: absolute; left: 0; top: 0; }
.deck-stack .card:nth-child(1) { translate: -4px 4px; }
.deck-stack .card:nth-child(2) { translate: -2px 2px; }
.deck.can { cursor: pointer; }
.deck.can .deck-stack .card:last-child .card-face { box-shadow: 0 0 0 .25em #fff, 0 .6em 1.4em rgba(0, 0, 0, .45); }
.deck.can:hover .deck-stack .card:last-child { translate: 0 -4px; }
.deck.empty .deck-stack { opacity: .15; }
.deck-count {
  position: absolute;
  right: -9px; bottom: -9px;
  min-width: 30px; height: 30px;
  padding: 0 6px;
  border-radius: 15px;
  display: grid; place-items: center;
  background: #fff; color: #151a30;
  font-family: var(--num); font-weight: 800; font-size: 14px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.deck.low .deck-count { background: #ff4d5e; color: #fff; }

.pile { position: relative; width: var(--card-w); height: calc(var(--card-w) * 1.42); }
.pile::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: calc(var(--card-w) * .11);
  border: 2px dashed rgba(255, 255, 255, .22);
}
.pile .card { position: absolute; left: 0; top: 0; rotate: var(--rot, 0deg); }

.field { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel2);
  font-weight: 700; font-size: 13px;
  white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip.elem {
  border-color: var(--amb);
  background: color-mix(in srgb, var(--amb) 32%, transparent);
  transition: background-color .5s, border-color .5s;
}
.chip.elem.pop { animation: pop .45s ease; }
@keyframes pop { 40% { transform: scale(1.18); } }
.chip.dir { color: var(--muted); }
.chip.dir svg { transition: scale .4s; }
#app[data-dir="-1"] .chip.dir svg { scale: -1 1; }
.chip.pending { background: #ff4d5e; border-color: transparent; color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 77, 94, .25); } }

.banner {
  position: absolute; left: 50%; top: 42%;
  translate: -50% -50%;
  z-index: 40;
  padding: 12px 28px;
  border-radius: 18px;
  background: rgba(10, 13, 24, .88);
  border: 1px solid var(--line);
  font-size: clamp(20px, 4vw, 32px);
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.banner.show { animation: banner 1.5s ease both; }
@keyframes banner {
  0% { opacity: 0; transform: scale(.7); }
  14% { opacity: 1; transform: scale(1.06); }
  22%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: scale(1.04); }
}

/* ---------- 自分 ---------- */
.me { grid-area: me; position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.status { min-height: 22px; text-align: center; font-weight: 700; font-size: 14px; }
.status[data-tone="you"]  { color: #fff; }
.status[data-tone="warn"] { color: #ffd166; }
.status[data-tone="wait"] { color: var(--muted); font-weight: 600; }
.hand {
  position: relative;
  width: 100%; max-width: 1000px;
  margin: 0 auto;
  height: calc(var(--card-w) * 1.64);
  transition: height .25s;
}
.me-bar { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 46px; }
.me-card { min-width: 190px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 800; font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255, 255, 255, .18); }
.btn:active { transform: scale(.97); }
.btn.primary { background: #fff; color: #151a30; border-color: transparent; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.btn.primary:hover { background: #fff; box-shadow: 0 8px 26px rgba(0, 0, 0, .4); }
.btn.danger { background: #ff4d5e; color: #fff; }
.btn.danger:hover { background: #ff4d5e; }
.btn.big { padding: 14px 40px; font-size: 16px; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- カード ---------- */
.card {
  --cw: var(--card-w);
  position: relative;
  display: block;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
  font-size: calc(var(--cw) / 10);   /* カード内の寸法はすべて em */
  padding: 0; border: 0; background: none;
  border-radius: 1.1em;
  color: #fff;
  font-family: var(--font);
  line-height: 1;
}
.card-face {
  position: absolute; inset: 0;
  display: block;
  border-radius: inherit;
  background: linear-gradient(155deg, var(--c1), var(--c2));
  box-shadow: inset 0 0 0 .22em rgba(255, 255, 255, .26), 0 .3em .9em rgba(0, 0, 0, .4);
  overflow: hidden;
}
.e-fire  { --c1: var(--fire1);  --c2: var(--fire2); }
.e-water { --c1: var(--water1); --c2: var(--water2); }
.e-wind  { --c1: var(--wind1);  --c2: var(--wind2); }
.e-light { --c1: var(--light1); --c2: var(--light2); color: #4a3506; }
.e-dark  { --c1: var(--dark1);  --c2: var(--dark2); }
.to-fire  { --t1: var(--fire1);  --t2: var(--fire2); }
.to-water { --t1: var(--water1); --t2: var(--water2); }
.to-wind  { --t1: var(--wind1);  --t2: var(--wind2); }

/* 光沢 */
.card-face::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 70% at 20% 0%, rgba(255, 255, 255, .34), transparent 60%);
  pointer-events: none;
}
/* アタックは斜めのストライプ */
.t-attack .card-face::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(0, 0, 0, .16) 0 .55em, transparent .55em 1.5em);
  pointer-events: none;
}
/* シフトは行き先の色へグラデーション */
.t-shift .card-face { background: linear-gradient(160deg, var(--c1) 0%, var(--c2) 38%, var(--t2) 100%); }

.c-tl {
  position: absolute; left: .7em; top: .7em;
  z-index: 1;
  width: 2.3em; height: 2.3em;
  display: grid; place-items: center;
}
.c-tl svg { width: 100%; height: 100%; filter: drop-shadow(0 .1em .15em rgba(0, 0, 0, .3)); }
.c-tl b { font-family: var(--num); font-size: 1.9em; font-weight: 800; letter-spacing: -.04em; text-shadow: 0 .08em .15em rgba(0, 0, 0, .35); }
.c-art {
  position: absolute; left: 0; right: 0; top: 3.1em; bottom: 3em;
  z-index: 1;
  display: grid; place-items: center;
}
.c-art .g { width: 5.4em; height: 5.4em; filter: drop-shadow(0 .25em .35em rgba(0, 0, 0, .28)); }
.c-art .plus {
  position: absolute; right: .9em; bottom: -.2em;
  font-family: var(--num); font-size: 2.5em; font-weight: 800; letter-spacing: -.04em;
  color: #fff;
  text-shadow: 0 .06em 0 rgba(0, 0, 0, .35), 0 0 .3em rgba(0, 0, 0, .4);
}
.c-art .arrow { position: absolute; left: 1.1em; top: -.4em; width: 2.6em; height: 2.6em; rotate: 38deg; opacity: .95; }
.c-art .to {
  width: 5em; height: 5em;
  margin: 1.2em 0 0 1.4em;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(150deg, var(--t1), var(--t2));
  box-shadow: 0 0 0 .3em rgba(255, 255, 255, .9), 0 .3em .8em rgba(0, 0, 0, .35);
}
.c-art .to svg { width: 3.1em; height: 3.1em; }
.c-art .dots { position: absolute; bottom: .1em; left: 0; right: 0; display: flex; justify-content: center; gap: .5em; }
.t-wild .c-art .g { margin-bottom: 1.6em; }
.c-art .dots i { width: 1.05em; height: 1.05em; border-radius: 50%; box-shadow: 0 0 0 .14em rgba(255, 255, 255, .9); }
.d-fire { background: var(--fire2); } .d-water { background: var(--water2); } .d-wind { background: var(--wind2); }
.c-name {
  position: absolute; left: .85em; bottom: .8em;
  z-index: 1;
  font-size: max(1.22em, 8px);
  font-weight: 800;
  letter-spacing: .02em;
  text-shadow: 0 .08em .2em rgba(0, 0, 0, .3);
}
.e-light .c-name, .e-light .c-tl b { text-shadow: none; }
.c-pt {
  position: absolute; right: .8em; bottom: .75em;
  z-index: 1;
  font-family: var(--num);
  font-size: max(1.2em, 8px);
  font-weight: 800;
  opacity: .82;
}

/* 裏面 */
.card.back .card-face { background: linear-gradient(155deg, #3a4372, #171b36); }
.card.back .g {
  position: absolute; left: 50%; top: 50%;
  width: 62%; height: auto; aspect-ratio: 1;
  translate: -50% -50%;
  opacity: .9;
}

/* 手札 */
.hand .card {
  position: absolute; left: 0; top: 0;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  cursor: default;
}
.hand .card .card-face { transition: transform .16s ease, box-shadow .16s ease, filter .2s ease; }
.hand .card.incoming { visibility: hidden; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable .card-face {
  transform: translateY(-1em);
  box-shadow: 0 0 0 .26em #fff, 0 .9em 1.6em rgba(0, 0, 0, .5);
}
.hand .card.playable:hover .card-face,
.hand .card.playable:focus-visible .card-face { transform: translateY(-2.2em); }
.hand.choosing .card:not(.playable) .card-face { filter: brightness(.5) saturate(.75); }
.hand .card.shake { animation: shake .3s; }
@keyframes shake { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }

/* 飛んでいくカード */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.card.fly { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }

/* ---------- タイトル ---------- */
.start {
  position: fixed; inset: 0;
  z-index: 80;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 20% 20%, rgba(255, 106, 69, .28), transparent 70%),
    radial-gradient(60% 50% at 85% 30%, rgba(74, 163, 255, .28), transparent 70%),
    radial-gradient(70% 55% at 50% 100%, rgba(63, 217, 154, .22), transparent 70%),
    var(--bg0);
  transition: opacity .4s, visibility .4s;
  overflow: auto;
}
.start.gone { opacity: 0; visibility: hidden; }
.start-inner { text-align: center; max-width: 520px; }
.start-logo { width: 84px; height: 84px; animation: spin 24s linear infinite; }
.start h1 {
  margin: 8px 0 12px;
  font-family: var(--num);
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.1;
}
.start h1 span { display: block; font-family: var(--font); font-size: 16px; letter-spacing: .5em; color: var(--muted); font-weight: 700; margin-top: 6px; text-indent: .5em; }
.lead { color: #c9d0e4; margin: 0 0 28px; }
.field-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0 6px; }
.field-label { font-weight: 700; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); }
.seg button {
  border: 0; background: none;
  padding: 7px 18px;
  border-radius: 999px;
  font-weight: 800; font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button[aria-checked="true"] { background: #fff; color: #151a30; }
.level-note { min-height: 3em; margin: 6px 0 0; color: var(--muted); font-size: 12.500px; }
.start-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }

/* ---------- ダイアログ ---------- */
.dlg {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--sheet);
  color: var(--ink);
  padding: 24px;
  width: min(92vw, 560px);
  max-height: 88dvh;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  user-select: text;
}
.dlg::backdrop { background: rgba(5, 7, 15, .62); backdrop-filter: blur(5px); }
.dlg[open] { animation: dlg .25s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes dlg { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.dlg h2 { margin: 0 0 14px; font-size: 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; }
.dlg-kicker { margin: 0 0 2px; font-family: var(--num); font-weight: 800; font-size: 12px; letter-spacing: .14em; color: var(--muted); }
.dlg-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.dlg-result { text-align: center; }
.dlg-result > .btn { margin-top: 18px; }

.dlg-color { width: min(92vw, 400px); text-align: center; }
.color-row { display: flex; justify-content: center; gap: 12px; margin: 4px 0 16px; }
.color-btn {
  width: 92px;
  padding: 14px 0 10px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(155deg, var(--c1), var(--c2));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.color-btn:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px #fff, 0 10px 24px rgba(0, 0, 0, .4); }
.color-btn svg { width: 38px; height: 38px; display: block; margin: 0 auto 4px; }
.color-btn b { display: block; font-size: 18px; }
.color-btn small { display: block; font-size: 11px; font-weight: 700; opacity: .9; margin-top: 2px; }

.score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.score-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 14px 10px 10px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.score-list li.win  { border-color: #ffd166; background: rgba(255, 209, 102, .12); }
.score-list li.lose { border-color: #ff6b78; background: rgba(255, 107, 120, .1); }
.score-list .who b { font-size: 14px; }
.score-list .tag { margin-left: 8px; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #ffd166; color: #201a05; }
.score-list li.lose .tag { background: #ff6b78; color: #fff; }
.mini-hand { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; min-height: 0; }
.mini-hand .card { --cw: 26px; }
.mini-hand .card .c-name, .mini-hand .card .c-pt, .mini-hand .card .c-tl { display: none; }
.mini-hand .card .c-art { inset: 0; }
.mini-hand .card .c-art .to { margin: 0; }
.mini-hand .card .c-art .arrow, .mini-hand .card .c-art .dots { display: none; }
.delta { font-family: var(--num); font-weight: 800; font-size: 18px; text-align: right; min-width: 3.2em; }
.delta.plus { color: #6ee7a8; } .delta.minus { color: #ff8a94; }
.total { font-family: var(--num); text-align: right; min-width: 3.6em; color: var(--muted); font-size: 11px; font-weight: 700; line-height: 1.25; }
.total b { display: block; color: var(--ink); font-size: 17px; font-weight: 800; }
.rank-list .rank { font-family: var(--num); font-weight: 800; font-size: 20px; width: 1.6em; text-align: center; }
.rank-list li { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.rank-list li.first { border-color: #ffd166; background: rgba(255, 209, 102, .14); }

.dlg-rules { width: min(94vw, 680px); padding-right: 12px; }
.dlg-rules .dlg-head { padding-right: 12px; }
.rules-body { overflow: auto; max-height: calc(88dvh - 110px); padding-right: 12px; }
.rules-body h3 { margin: 18px 0 6px; font-size: 14px; color: #cfd6ea; letter-spacing: .06em; }
.rules-body h3:first-child { margin-top: 6px; }
.rules-body ul { margin: 0; padding-left: 1.3em; }
.rules-body li { margin: 3px 0; }
.rules-body .note { margin: 0 0 8px; color: var(--muted); font-size: 12.500px; }
.rules-body kbd { font-family: var(--num); font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--panel2); }
.card-guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.guide-item { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.guide-item .card { --cw: 52px; }
.guide-item b { display: block; font-size: 13.500px; }
.guide-item b small { margin-left: 6px; color: var(--muted); font-weight: 700; font-size: 11px; }
.guide-item p { margin: 2px 0 0; font-size: 12px; color: #c3cbe0; line-height: 1.45; }

.dlg-settings { width: min(92vw, 440px); text-align: center; }
.dlg-settings .dlg-head { text-align: left; }

/* ---------- スマホ ---------- */
@media (max-width: 720px) {
  :root { --card-w: clamp(56px, min(17.5vw, 12vh), 96px); }
  .seat-score .lbl { display: none; }
  .table {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "left   top    right"
      "center center center"
      "me     me     me";
    gap: 6px 6px;
    padding-left: 10px; padding-right: 10px;
  }
  .seat { align-self: start; width: 100%; }
  .seat-card { min-width: 0; width: 100%; padding: 6px 8px 6px 6px; gap: 6px; border-radius: 14px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  .seat-name { font-size: 12px; }
  .seat-score { font-size: 10.500px; }
  .seat-score b { font-size: 12px; }
  .seat-count { font-size: 18px; padding-left: 2px; }
  .seat-hand { display: none; }
  .brand-sub { display: none; }
  .topbar { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .ghost-btn { padding: 6px 11px; font-size: 12px; }
  .me-card { min-width: 0; }
  .me-bar { gap: 8px; }
  .btn { padding: 10px 16px; font-size: 13px; }
  .dlg { padding: 18px; border-radius: 20px; }
  .color-btn { width: 84px; }
  .ring-wrap { width: calc(var(--card-w) * 3.8); }
}
@media (max-height: 560px) {
  .seat-hand { display: none; }
  .center { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .ring, .start-logo { animation: none; }
}
