:root {
  /* 黒板・チョーク・方眼紙 */
  --bg: #1f4631;
  --bg2: #173a27;
  --sheet: #1a3d29;
  --panel: rgba(0, 0, 0, 0.16);
  --line: rgba(236, 244, 226, 0.16);
  --text: #f1f4ea;
  --muted: #a9bfae;
  --gold: #f2e27a;
  --accent: #9fd0ff;
  --danger: #ff8a7a;
  --ok: #a6e36b;
  --btn: #245a3b;
  --btn-edge: #3d8a4f;
  --btn-edge-dark: #153b25;
  --paper: #fdfdf8;
  --grid: rgba(120, 170, 225, 0.22);
  --grid-soft: rgba(120, 170, 225, 0.13);
  --round: 'M PLUS Rounded 1c', var(--sans);
  --pencil: #3b3b3b;
  --sans: system-ui, -apple-system, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', Meiryo, sans-serif;
  --hand: 'Yomogi', 'M PLUS Rounded 1c', sans-serif;
  --fire: #e0643a; --water: #3d8fe0; --earth: #7fa34a; --light: #e8c65a; --dark: #8a62b8;
  --wind: #4fc2a8; --thunder: #e6d23a; --poison: #a0c24a; --neutral: #8a8f9c;
  --card-w: 118px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  /* 黒板：消し跡のむらとチョークの粉 */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(60% 40% at 25% 20%, rgba(255, 255, 255, .06), transparent 70%),
    radial-gradient(50% 35% at 80% 75%, rgba(255, 255, 255, .045), transparent 70%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .28)),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, h2, h3, h4, .btn, .logo { font-family: 'M PLUS Rounded 1c', var(--sans); }
h2 { margin: 0; }
h3 { margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
input, select {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font: inherit; min-height: 40px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* 緑の板のボタン：左上が明るい縁、右下が濃い縁 */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--btn); color: var(--text); border: 3px solid var(--btn-edge); border-right-color: var(--btn-edge-dark); border-bottom-color: var(--btn-edge-dark); border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .28);
  min-height: 40px; padding: 8px 16px; font-size: 14px; font-weight: 800; cursor: pointer; transition: transform .1s, background .15s, box-shadow .15s, border-color .15s; line-height: 1.25;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
.btn small { font-family: var(--sans); font-weight: 400; font-size: 11px; opacity: .8; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: #2c6b45; border-color: #a9cf45; border-right-color: #5f8a24; border-bottom-color: #5f8a24; color: #fbfff0; }
.btn.danger { background: #5a2d25; border-color: #b0584a; border-right-color: #3b1a15; border-bottom-color: #3b1a15; color: #ffd9d2; }
.btn.ghost { background: transparent; border-color: rgba(236, 244, 226, .22); box-shadow: none; }
.btn.big { padding: 14px 28px; font-size: 18px; width: min(300px, 100%); min-height: 58px; }
.btn.small { padding: 4px 10px; font-size: 12px; min-height: 30px; border-width: 2px; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: #2b6645; transform: translateY(-1px); }
  .btn.primary:hover:not(:disabled) { background: #347a50; border-color: #c6e65a; border-right-color: #6f9c2a; border-bottom-color: #6f9c2a; }
  .btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .06); }
}
.iconbtn { flex: none; width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--btn-edge); border-right-color: var(--btn-edge-dark); border-bottom-color: var(--btn-edge-dark); background: var(--btn); color: var(--text); font-size: 17px; cursor: pointer; display: grid; place-items: center; padding: 0; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.col-btns { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.col-btns .btn { align-items: flex-start; text-align: left; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ------------------------------------------------ 画面 */
.title-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); text-align: center; }
.title-screen { position: relative; }
/* チョークで書いたタイトルと日付 */
.logo h1 { font-family: var(--hand); font-weight: 400; font-size: clamp(36px, 11vw, 92px); margin: 4px 0; letter-spacing: .06em; color: #f7f6ea; text-shadow: 0 0 1px #fff, 0 0 6px rgba(255, 255, 255, .25), 2px 3px 0 rgba(0, 0, 0, .18); transform: rotate(-2deg); }
.logo .sub { font-family: var(--hand); letter-spacing: .3em; font-size: 12px; color: var(--gold); opacity: .85; }
.logo p { font-family: var(--hand); }
.logo p span { display: inline-block; }
.chalk-date { position: absolute; right: calc(20px + var(--safe-r)); top: calc(24px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; font-family: var(--hand); font-size: 22px; line-height: 1.25; color: rgba(247, 246, 234, .5); text-shadow: 0 0 4px rgba(255, 255, 255, .2); pointer-events: none; }
.chalk-date b { font-weight: 400; font-size: 30px; }
.chalk-date span { font-size: 18px; margin-top: 4px; }
@media (max-width: 520px) { .title-screen { gap: 22px; } .chalk-date { font-size: 15px; right: 10px; top: calc(10px + var(--safe-t)); } .chalk-date b { font-size: 20px; } .chalk-date span { font-size: 13px; } }
.menu-list { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(340px, 100%); }
.menu-main { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.menu-main .btn.big { width: 100%; min-height: 64px; font-size: 19px; }
.menu-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.menu-sub .btn { min-height: 50px; font-size: 15px; }
.menu-sub .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.title-foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.title-foot p { flex-basis: 100%; margin: 4px 0 0; }
.logo h1 { white-space: nowrap; }
/* 横向きのスマホ：タイトルを小さくし、メニューを横に並べて1画面に収める */
@media (max-height: 520px) and (min-width: 560px) {
  .title-screen { gap: 12px; padding-top: calc(10px + var(--safe-t)); padding-bottom: calc(10px + var(--safe-b)); }
  .logo h1 { font-size: clamp(32px, 11vh, 52px); }
  .logo p { display: none; }
  .menu-list { width: min(620px, 100%); gap: 10px; }
  .menu-main { flex-direction: row; gap: 10px; }
  .menu-main .btn.big { min-height: 56px; padding: 8px 12px; }
  .menu-sub { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .menu-sub .btn { min-height: 42px; }
  .menu-sub .btn:last-child:nth-child(odd) { grid-column: auto; }
}
.page { max-width: 1100px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(40px + var(--safe-b)); }
.page.has-bottom { padding-bottom: 0; }
.page.center { text-align: center; padding-top: 12vh; }
.page-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; margin: 0 -16px 4px; padding: 8px 16px; background: linear-gradient(var(--bg) 70%, transparent); }
.btn.back { min-width: 44px; padding: 8px 12px; font-size: 18px; }
.field { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.field input { flex: 1; min-width: 0; max-width: 320px; }
.field input.invalid { outline: 2px solid #e05a5a; }
.deck-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 44%), 1fr)); gap: 8px; }
.deck-tile { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--deck); cursor: pointer; min-height: 64px; }
.deck-tile input { position: absolute; opacity: 0; pointer-events: none; }
.deck-tile b { padding-right: 44px; line-height: 1.3; }
.deck-tile small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.deck-tile i { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: 10px; color: var(--muted); }
.deck-tile .deck-acts { align-self: flex-end; display: flex; gap: 4px; margin-top: 4px; }
.deck-tile .deck-peek { padding: 2px 8px; font-size: 11px; min-height: 0; cursor: pointer; }
.deck-tile.sel { background: rgba(166, 227, 107, .12); border-color: #a6e36b; border-left-color: var(--deck); box-shadow: 0 0 0 1px #a6e36b inset; }
.deck-tile.invalid { opacity: .5; cursor: not-allowed; }
.deck-picker.fold-starters .deck-tile.starter:not(.sel) { display: none; }
.deck-picker .starter-toggle { grid-column: 1 / -1; justify-self: start; }
.bottom-bar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: center; margin: 16px -16px 0; padding: 14px 16px calc(14px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 35%); }
.online-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 20px; }
.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.panel-box h3 { margin: 0; }
.room-code { font-size: clamp(36px, 12vw, 48px); font-weight: 800; letter-spacing: .2em; color: var(--gold); font-family: 'M PLUS Rounded 1c', monospace; }
.copy-row { display: flex; gap: 8px; justify-content: center; margin: 10px auto 20px; max-width: 520px; flex-wrap: wrap; }
.copy-row input { flex: 1 1 200px; min-width: 0; }
.spinner { width: 46px; height: 46px; margin: 24px auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rules section { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px 18px 12px; margin: 12px 0; }
.rules li { margin: 4px 0; }
.rules ul, .rules ol { padding-left: 1.3em; }

/* ------------------------------------------------ カード */
/* 方眼紙に鉛筆で枠を描いた手作りカード。属性は上端の色帯と名前の下の色鉛筆の塗りで表す
   読みやすさ優先：名前・数字は丸ゴシックの太字、効果文はゴシック体で方眼の上に白い下地を敷く */
.card {
  --a: var(--neutral);
  position: relative; width: var(--w, var(--card-w)); aspect-ratio: 5 / 7; flex: none;
  font-size: calc(var(--w, var(--card-w)) / 13);
  border-radius: 0.3em; padding: 0.4em; display: flex; flex-direction: column; gap: 0.3em;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid-soft) 1px, transparent 1px), linear-gradient(90deg, var(--grid-soft) 1px, transparent 1px);
  background-size: 1.05em 1.05em; background-position: -1px -1px;
  border-top: .3em solid var(--a);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 3px 8px rgba(0, 0, 0, .4);
  color: #222; font-family: var(--round); overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card.sm { --w: 96px; }
.card.md { --w: 118px; }
.card.xl { --w: 260px; }
.a-fire { --a: var(--fire); } .a-water { --a: var(--water); } .a-earth { --a: var(--earth); } .a-light { --a: var(--light); }
.a-dark { --a: var(--dark); } .a-wind { --a: var(--wind); } .a-thunder { --a: var(--thunder); } .a-poison { --a: var(--poison); } .a-neutral { --a: var(--neutral); }
.card.orica { box-shadow: 0 0 0 2px #f2d75a, 0 0 14px rgba(255, 225, 110, .7), 0 3px 8px rgba(0, 0, 0, .4); }
.card.orica::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 30%, rgba(255, 240, 150, .22) 45%, rgba(255, 170, 230, .14) 55%, transparent 70%); }
.c-head { display: flex; align-items: center; gap: 0.25em; min-height: 1.7em; }
/* 鉛筆の線：少しいびつな角丸 */
.c-cost, .c-name, .c-pow, .c-foot .c-type { border: 0.08em solid var(--pencil); background: #fff; }
.c-cost { flex: none; min-width: 1.6em; height: 1.6em; padding: 0 .15em; border-radius: .15em .25em .12em .22em; display: grid; place-items: center; color: #111; font-size: 1.1em; font-weight: 800; line-height: 1; }
.c-cost.energy { font-size: .9em; min-width: 2em; }
.c-cost.trap { font-size: .75em; color: #fff; border: 0; background: #2d2d2d; clip-path: polygon(50% 0, 62% 26%, 92% 12%, 78% 42%, 100% 60%, 72% 68%, 76% 100%, 50% 80%, 24% 100%, 28% 68%, 0 60%, 22% 42%, 8% 12%, 38% 26%); width: 2em; height: 2em; }
.c-cost.down { color: #1a6e1a; border-color: #1a6e1a; background: #e6f7da; }
.c-name { flex: 1; min-width: 0; min-height: 1.6em; padding: .1em .4em; border-radius: .9em .7em .8em .6em / .6em .8em .7em .9em; font-size: 0.85em; font-weight: 700; line-height: 1.2; text-align: center; color: #111; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all;
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--a) 55%, transparent) 62% 94%, transparent 94%), #fff; }
.a-neutral .c-name { background: #fff; }
.c-art { position: relative; flex: 0 1 34%; min-height: 20%; display: grid; place-items: center; font-size: 2.7em; overflow: hidden; border-radius: .08em; background: color-mix(in srgb, var(--a) 12%, transparent); }
.c-art > span { filter: saturate(.8) drop-shadow(.02em .03em 0 rgba(0, 0, 0, .25)); }
.c-orica { position: absolute; top: .3em; right: .2em; font-style: normal; font-size: .26em; font-weight: 800; background: #ffe56b; color: #5a3d00; padding: .05em .45em; border: .08em solid #5a3d00; border-radius: .2em; transform: rotate(6deg); font-family: var(--round); }
.c-text { flex: 1 1 auto; min-height: 0; padding: .3em .4em; font-family: var(--sans); font-size: 0.74em; font-weight: 500; line-height: 1.5; color: #1a1a1a; overflow: hidden;
  background: rgba(255, 255, 255, .92); border: .06em solid rgba(0, 0, 0, .18); border-radius: .2em; }
.c-text .muted { color: #777; }
.card.xl .c-text { overflow: auto; font-size: .7em; }
.c-foot { flex: none; display: flex; gap: .25em; min-height: 1.5em; }
.c-foot.line { min-height: 0; }
.c-foot.line .c-type { font-size: .62em; color: #555; font-weight: 700; }
.c-pow { flex: 0 0 40%; display: grid; place-items: center; border-radius: .2em .12em .25em .15em; font-size: 1em; font-weight: 800; color: #111; line-height: 1.35; }
.c-type { min-width: 0; font-size: 0.66em; font-weight: 700; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-foot .c-type { flex: 1; display: grid; place-items: center; padding: 0 .3em; border-radius: .12em .22em .15em .25em; }
.c-badge { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-3deg); background: #2d2d2d; color: #fff; font-family: var(--round); font-weight: 800; border-radius: .3em; padding: 0.15em 0.7em; font-size: 0.9em; white-space: nowrap; }
.card.unsupported { filter: grayscale(1) brightness(.8); opacity: .8; }
/* 小さいカード（一覧・手札・相手の行動）：効果文は隠して名前・コスト・パワー・絵を大きく。効果はホバー・右クリック・長押しの詳細で読む */
.card.sm, .hand .card, .popup .card { font-size: clamp(9px, calc(var(--w) / 8.5), 13px); gap: .25em; padding: .3em; }
.card.sm :is(.c-text, .c-foot.line, .c-foot .c-type), .hand .card :is(.c-text, .c-foot.line, .c-foot .c-type), .popup .card :is(.c-text, .c-foot.line, .c-foot .c-type) { display: none; }
.card.sm .c-art, .hand .card .c-art, .popup .card .c-art { flex: 1 1 auto; font-size: 2.4em; }
.card.sm .c-name, .hand .card .c-name, .popup .card .c-name { font-size: .88em; }
.card.sm .c-pow, .hand .card .c-pow, .popup .card .c-pow { flex: 1; font-size: 1.1em; }
.card.sm .c-orica, .hand .card .c-orica, .popup .card .c-orica { font-size: .36em; }
/* 過去のバージョン：使われていた時期の付箋 */
.c-ver { position: absolute; left: .15em; bottom: .15em; font-style: normal; font-size: .24em; font-weight: 800; background: #cfe6ff; color: #1d3f66; padding: .05em .4em; border: .08em solid #1d3f66; border-radius: .2em; transform: rotate(-4deg); font-family: var(--round); white-space: nowrap; }
.card.sm .c-ver, .hand .card .c-ver, .popup .card .c-ver { font-size: .32em; }
.card-back { width: var(--w, var(--card-w)); aspect-ratio: 5 / 7; border-radius: .25em; display: grid; place-items: center; background: var(--paper) repeating-linear-gradient(45deg, rgba(60, 60, 60, .12) 0 2px, transparent 2px 7px); box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 3px 8px rgba(0, 0, 0, .4); color: #444; font-size: 28px; font-family: var(--hand); }
.card-back.orica { color: #b58a00; }

/* ------------------------------------------------ 対戦画面 */
body:has(#app.in-game) { overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; }
.game-root { height: 100vh; height: 100dvh; }
.game { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) clamp(240px, 22vw, 300px); height: 100%; user-select: none; -webkit-user-select: none; }
.table {
  --sup-h: 48px; --hw: clamp(88px, 15dvh, 124px); --peek: .72;
  display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; overflow: hidden;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l));
}
.zone { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 5px; }
.panel { border-left: 1px solid var(--line); background: rgba(0, 0, 0, .25); display: flex; flex-direction: column; min-height: 0; }
.preview { padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 1 auto; overflow: auto; max-height: 68%; }
/* --w は font-size にも使うので % は不可（パネル幅から直接計算） */
.preview .card.xl { --w: min(240px, calc(clamp(240px, 22vw, 300px) - 24px), calc(46dvh * 5 / 7)); }
.pv-meta { font-size: 12px; width: 100%; }
.pv-lore { color: var(--muted); font-style: italic; margin: 4px 0; }
.pv-set { color: var(--muted); margin: 2px 0; }
.pv-warn { color: #ffb35c; }
.pv-ver { color: var(--accent); margin: 2px 0; }
.vers { display: flex; flex-direction: column; gap: 6px; }
.vers p { margin: 0; }
.ver-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--text); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; min-height: 32px; }
.chip.on { border-color: var(--accent); background: rgba(159, 208, 255, .18); font-weight: 700; }
.dver { margin-left: 6px; font-size: 11px; color: var(--accent); }
.filter-row select.era { flex: 0 1 auto; }
.log { flex: 1; overflow: auto; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12px; overscroll-behavior: contain; }
.log p { margin: 2px 0; color: #c8c9d2; }
.log p.turn { color: var(--gold); margin-top: 8px; font-weight: 700; }
.waiting-room { margin: auto; text-align: center; }

/* プレイヤー情報 */
.pbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); min-height: 46px; min-width: 0; }
.pbar.active { border-color: rgba(242, 226, 122, .6); box-shadow: 0 0 0 1px rgba(242, 226, 122, .3) inset; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 16px; background: var(--paper); color: #2d2d2d; font-family: var(--hand); border: 3px solid #a6e36b; }
.pbar.op .avatar { border-color: #ff8a7a; }
.pinfo { min-width: 0; flex: 0 1 auto; display: flex; flex-direction: column; line-height: 1.15; }
.pname { font-weight: 700; font-size: 12px; display: flex; gap: 5px; align-items: center; min-width: 0; }
.pname > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tag { flex: none; font-size: 10px; background: rgba(255, 255, 255, .1); border-radius: 6px; padding: 0 5px; color: var(--muted); }
.lp { position: relative; color: var(--muted); display: flex; align-items: baseline; gap: 4px; }
.lp small { font-size: 10px; font-weight: 700; }
.lp b { font-size: 23px; color: #fbfaf0; font-family: var(--hand); font-weight: 400; line-height: 1.1; text-shadow: 0 0 4px rgba(255, 255, 255, .2); }
.lp.hit b { animation: hit .5s; }
.lp.healed b { animation: heal .6s; }
@keyframes hit { 30% { color: var(--danger); transform: scale(1.2); } }
@keyframes heal { 30% { color: var(--ok); } }
.float { position: absolute; left: 100%; top: -4px; margin-left: 4px; font-weight: 800; font-size: 18px; animation: float 1.2s forwards; pointer-events: none; white-space: nowrap; z-index: 3; }
.float.minus { color: var(--danger); } .float.plus { color: var(--ok); }
@keyframes float { to { transform: translateY(-28px); opacity: 0; } }
.stats { flex-shrink: 0; display: flex; gap: 4px; margin-left: auto; align-items: center; min-width: 0; }
.stat { flex: none; display: flex; align-items: center; gap: 3px; background: rgba(0, 0, 0, .28); border-radius: 8px; padding: 3px 7px; font-size: 13px; line-height: 1.3; position: relative; }
.stat b { font-size: 14px; }
.stat.mana b { color: var(--accent); }
.stat[data-act] { cursor: pointer; }
.stat.pile.orica-top { box-shadow: 0 0 0 1px #ffd76a inset, 0 0 10px rgba(255, 215, 106, .5); }
.stat.pile.sideways { transform: rotate(-8deg); }
.stat .deck-ctr { font-style: normal; font-size: .7em; color: #ffd76a; margin-left: 2px; }
.stat.assist { background: rgba(159, 208, 255, .2); color: #d4eaff; font-size: 11px; font-weight: 700; }
.stat.revealed { box-shadow: 0 0 0 1px #7fd6ff inset; }
/* カードの裏面（小）：オリカは金色の裏面なので、相手の手札や山札の一番上にあると分かる */
.mb { flex: none; display: inline-grid; place-items: center; width: 9px; height: 13px; border-radius: 2px; font-style: normal; background: #e9e4d2 repeating-linear-gradient(45deg, rgba(60, 60, 60, .18) 0 1px, transparent 1px 3px); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
.mb.orica { background: linear-gradient(135deg, #fff3a8, #e6b422 55%, #b58a00); box-shadow: 0 0 0 1px #5a3d00, 0 0 6px rgba(255, 215, 106, .9); }
.mb.deck { width: 12px; height: 17px; }
.mb.deck.orica::after { content: '★'; font-size: 9px; line-height: 1; color: #5a3d00; }
.mini-hand { display: inline-flex; align-items: center; }
.mini-hand .mb + .mb { margin-left: clamp(-7px, calc(21px / (var(--n) - 1) - 9px), -4px); }
.mini-hand .mb.orica { position: relative; z-index: 1; transform: translateY(-2px); }
.pbar.choosable, .pbar.targetable { cursor: pointer; box-shadow: 0 0 0 2px var(--danger), 0 0 18px rgba(255, 138, 122, .5); animation: glowbar 1s ease-in-out infinite alternate; }
.pbar.chosen { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(242, 226, 122, .7); }
@keyframes glowbar { to { box-shadow: 0 0 0 2px var(--danger), 0 0 26px rgba(255, 138, 122, .85); } }

/* フィールド・エネルギー・罠 */
.support { flex: none; height: var(--sup-h); display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.energies { flex: 1 1 auto; min-width: 0; display: flex; gap: 4px; align-items: center; padding: 0 2px; }
.mons::-webkit-scrollbar { display: none; }
.traps { flex: 0 1 auto; min-width: 0; display: flex; gap: 4px; }
/* 入りきらない時は手札と同じように重ねて全部見せる */
.es { position: relative; flex: 0 1 calc(var(--sup-h) * .75); min-width: 0; height: 100%; display: flex; align-items: center; }
.es:last-child { flex-shrink: 0; }
.es > .energy, .es > .trap { width: calc(var(--sup-h) * .75); }
.energy .cnt { position: absolute; top: 1px; right: 1px; padding: 0 .3em; border-radius: .7em; background: #2d2d2d; color: #fff; font-style: normal; font-family: var(--round); font-weight: 800; font-size: max(9px, .8em); line-height: 1.35; }
.energy, .trap { position: relative; flex: none; height: 100%; aspect-ratio: 3 / 4; border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(var(--sup-h) / 5); line-height: 1.1; overflow: hidden; }
.energy { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--a) 50%, transparent) 62% 88%, transparent 88%), var(--paper); border: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .35); color: #2d2d2d; font-family: var(--hand); transition: transform .2s, opacity .2s; }
.energy b { font-size: 1.35em; }
.energy.tapped { transform: translateY(3px) scale(.86); opacity: .45; filter: grayscale(.7); }
.energy.tapped::after { content: "済"; position: absolute; font-size: .8em; bottom: 1px; right: 2px; }
.energy.ready { cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 3px #a6e36b; }
.trap { background: var(--paper) repeating-linear-gradient(45deg, rgba(45, 45, 45, .16) 0 2px, transparent 2px 6px); border: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .35); color: #2d2d2d; font-family: var(--hand); }
.trap b { font-size: 1.3em; }
/* オリカの罠は裏面が金色なので、伏せていても相手に分かる */
.trap.orica { background: linear-gradient(135deg, #fff3a8, #e6b422 55%, #b58a00); box-shadow: 0 0 0 1px #5a3d00, 0 0 8px rgba(255, 215, 106, .8); color: #5a3d00; }
.trap small { font-size: .7em; font-weight: 500; text-align: center; line-height: 1.1; padding: 0 2px; max-height: 2.3em; overflow: hidden; }
.fieldcard { flex: 0 0 auto; width: clamp(84px, 16%, 132px); border-radius: 4px; padding: 3px 8px; background-color: var(--paper); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 10px 10px; color: #2d2d2d; font-family: var(--hand); border: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55); font-size: 11px; display: flex; flex-direction: column; justify-content: center; position: relative; cursor: pointer; min-width: 0; line-height: 1.2; }
.fieldcard b { font-size: 12px; font-family: var(--round); font-weight: 700; color: #111; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fieldcard i { position: absolute; right: 5px; top: 3px; font-style: normal; color: #b58a00; font-size: 10px; }
.f-label { color: #4a78b0; font-size: 10px; }
.fieldcard.empty { background: transparent; box-shadow: none; border: 2px dashed rgba(236, 244, 226, .22); font-family: inherit; color: var(--muted); cursor: default; align-items: center; text-align: center; }
.fieldcard.empty .f-label { color: var(--muted); }
.empty { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* モンスター：列の高さに合わせて大きさが変わる */
.mons { --gap: 8px; flex: 1 1 0; min-height: 0; container-type: size; display: flex; align-items: center; gap: var(--gap); overflow-x: auto; overflow-y: hidden; padding: 0 8px; border-radius: 14px; background: rgba(255, 255, 255, .02); border: 2px dashed rgba(236, 244, 226, .13); scrollbar-width: none; }
.mons > :first-child { margin-left: auto; }
.mons > :last-child { margin-right: auto; }
/* 2〜3段（段数と1段の枚数は board.js の fitMons が決める） */
.mons.multi { flex-wrap: wrap; justify-content: center; align-content: center; row-gap: 0; }
.mons.multi > .mon { margin: calc(var(--gap) / 2) 0; }
.mbr { flex-basis: 100%; height: 0; }
.mon {
  --a: var(--neutral);
  /* 高さに収まる大きさ・幅に全員収まる大きさ（ただし小さくなりすぎたら横スクロール）の小さい方 */
  --mh: min(calc((100cqh - 12px - (var(--rows, 1) - 1) * var(--gap)) / var(--rows, 1)), 160px, max(calc((100cqw - 16px - (var(--n, 3) - 1) * var(--gap)) / var(--n, 3) / .75), 92px));
  position: relative; flex: none; height: var(--mh); aspect-ratio: 3 / 4; font-size: calc(var(--mh) / 10.5);
  border-radius: .25em; padding: .35em; display: flex; flex-direction: column; align-items: center; gap: .2em;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid-soft) 1px, transparent 1px), linear-gradient(90deg, var(--grid-soft) 1px, transparent 1px);
  background-size: 1em 1em; border-top: .3em solid var(--a); background-position: -1px -1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 4px 10px rgba(0, 0, 0, .45); transition: transform .2s, box-shadow .2s, filter .2s; color: #222; font-family: var(--round); cursor: pointer;
}
.mon.new { animation: enter .35s ease-out; }
@keyframes enter { from { transform: scale(.6) translateY(-10px) rotate(-6deg); opacity: 0; } }
.mon.orica { box-shadow: 0 0 0 2px #f2d75a, 0 0 14px rgba(255, 225, 110, .8); }
.mon.tapped { transform: rotate(8deg) scale(.94); filter: brightness(.7) saturate(.6); }
.m-name { font-size: .8em; font-weight: 700; color: #111; border: .09em solid var(--pencil); border-radius: .9em .7em .8em .6em / .6em .8em .7em .9em; padding: .05em .3em; width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35;
  background: linear-gradient(transparent 58%, color-mix(in srgb, var(--a) 45%, transparent) 58% 92%, transparent 92%), rgba(255, 255, 255, .75); }
.a-neutral .m-name { background: rgba(255, 255, 255, .75); }
.m-art { font-size: 2.7em; flex: 1; display: grid; place-items: center; line-height: 1; filter: saturate(.75) drop-shadow(.02em .03em 0 rgba(0, 0, 0, .25)); }
.m-keys { position: absolute; left: .25em; top: 1.9em; display: flex; flex-direction: column; gap: .15em; align-items: flex-start; max-width: 80%; }
.m-keys i { font-style: normal; font-size: .64em; font-weight: 700; background: #2d2d2d; color: #fff; border-radius: .15em; padding: 0 .3em; white-space: nowrap; }
.m-pow { font-size: 1.3em; font-weight: 800; line-height: 1.25; min-width: 60%; text-align: center; background: rgba(255, 255, 255, .8); color: #222; border: .07em solid var(--pencil); border-radius: .2em .12em .25em .15em; padding: 0 .4em; }
.m-pow.hurt { color: #d23b2b; border-color: #d23b2b; }
.m-pow.up { color: #1f8a2a; border-color: #1f8a2a; }
.m-pow.down { color: #c8611f; }
.m-ctr { position: absolute; right: .3em; top: 1.9em; font-size: .75em; background: #2d2d2d; color: #ffe56b; border-radius: .2em; padding: 0 .3em; }
.m-neg { position: absolute; top: 45%; font-size: .65em; background: #555; color: #fff; border-radius: .2em; padding: 0 .3em; }
.m-sick { position: absolute; right: .25em; bottom: 1.9em; font-size: 1em; }
.mon.ready { box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 4px #a6e36b, 0 0 16px rgba(166, 227, 107, .55); }
.mon.acting { box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 4px var(--gold), 0 0 20px rgba(242, 226, 122, .7); transform: translateY(-4px); }
.mon.targetable, .mon.choosable, .energy.choosable, .fieldcard.choosable, .trap.choosable { cursor: pointer; box-shadow: 0 0 0 3px var(--danger), 0 0 18px rgba(255, 138, 122, .6); animation: glow 1s ease-in-out infinite alternate; }
.mon.chosen, .energy.chosen, .fieldcard.chosen, .trap.chosen { box-shadow: 0 0 0 4px var(--gold), 0 0 22px rgba(242, 226, 122, .85); transform: translateY(-4px); animation: none; }
.energy.acting, .fieldcard.acting, .trap.acting { box-shadow: 0 0 0 3px var(--gold); }
@keyframes glow { to { box-shadow: 0 0 0 3px var(--danger), 0 0 26px rgba(255, 138, 122, .9); } }
@media (hover: hover) {
  .mon.ready:hover { transform: translateY(-4px); }
  .energy.ready:hover { transform: translateY(-3px); }
  .es:hover { z-index: 2; }
}

/* 案内とボタン */
.actionbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 5px 12px; min-height: 52px; border-radius: 12px;
  background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.actionbar.mine { border-color: rgba(166, 227, 107, .5); }
.actionbar.choosing { border-color: rgba(255, 138, 122, .6); background: rgba(90, 30, 25, .25); }
.prompt { min-width: 0; font-weight: 700; font-family: 'M PLUS Rounded 1c'; font-size: 15px; line-height: 1.3; display: flex; flex-direction: column; }
.prompt small { font-family: var(--sans); font-weight: 400; font-size: 11px; color: var(--muted); }
.buttons { flex: none; display: flex; gap: 6px; }
.btn.end { min-width: 120px; }

/* 手札：枚数が増えると自動で重なる */
.hand { --hand-pad: 6px; flex: none; display: flex; justify-content: center; align-items: flex-start; height: calc(var(--hw) * 1.4 * var(--peek) + var(--hand-pad)); padding: var(--hand-pad) 4px 0; margin-bottom: var(--safe-b); }
.hand .slot { flex: 0 1 var(--hw); min-width: 0; position: relative; }
.hand .slot:last-child { flex-shrink: 0; }
.hand .slot + .slot { margin-left: 4px; }
.hand .card { --w: var(--hw); transition: transform .15s; cursor: pointer; }
.hand .card.playable { box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 4px #a6e36b, 0 0 14px rgba(166, 227, 107, .5); }
.hand .card.dim { opacity: .55; }
.hand .slot.sel { z-index: 6; }
.hand .slot.sel .card { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--gold), 0 6px 20px rgba(0, 0, 0, .6); }
.hand .card .c-badge { top: auto; bottom: 28%; font-size: .75em; opacity: 0; transition: opacity .15s; }
.hand .empty { align-self: center; }
@media (hover: hover) {
  .hand .slot:hover { z-index: 5; }
  .hand .slot:hover .card { transform: translateY(-24%) scale(1.1); }
  .hand .slot:hover .card.playable .c-badge { opacity: 1; }
}

/* 相手の行動の表示 */
.popups { position: fixed; left: 16px; top: 50%; transform: translateY(-50%); z-index: 35; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.popup { background: rgba(16, 42, 27, .95); border: 2px solid var(--btn-edge); border-radius: 14px; padding: 8px 10px; text-align: center; animation: pop .25s ease-out; transition: opacity .5s, transform .5s; }
.popup p { margin: 0 0 6px; font-weight: 700; color: var(--gold); font-size: 13px; }
.popup.small p { margin: 0; }
.popup.out { opacity: 0; transform: translateX(-20px); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
/* エモート：吹き出しは結果の画面より上に出す。選ぶ欄はさらに上 */
.emote-layer { position: fixed; inset: 0; z-index: 42; pointer-events: none; }
.emote-bubble { position: fixed; max-width: min(260px, calc(100vw - 32px)); background: var(--paper); color: var(--pencil); font-family: var(--round); font-weight: 700; font-size: 15px; padding: 8px 14px; border-radius: 16px; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); animation: pop .2s ease-out; transition: opacity .4s; }
.emote-bubble::after { content: ''; position: absolute; left: 18px; border: 8px solid transparent; }
.emote-bubble.op::after { bottom: 100%; border-bottom-color: var(--paper); }
.emote-bubble.me::after { top: 100%; border-top-color: var(--paper); }
.emote-bubble.out { opacity: 0; }
.emote-picker { position: fixed; z-index: 1; pointer-events: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: min(340px, calc(100vw - 16px)); padding: 10px; background: var(--sheet); border: 2px solid var(--btn-edge); border-radius: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, .55); animation: pop .15s ease-out; }
.emote-picker .btn { justify-content: center; white-space: nowrap; font-size: 13px; min-height: 38px; }
.emote-layer:has(.emote-picker) { z-index: 46; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: #173a27; border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; z-index: 60; transition: opacity .4s; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: calc(100vw - 32px); text-align: center; pointer-events: none; }
body:has(#app.in-game) .toast { bottom: auto; top: 42%; }
.toast.error { border-color: var(--danger); }
body:has(#app.builder-page) .toast { bottom: calc(84px + var(--safe-b)); }
.toast.out { opacity: 0; }
.banner { flex: none; padding: 6px 12px; border-radius: 10px; text-align: center; font-size: 13px; }
.banner.warn { background: rgba(255, 170, 60, .15); border: 1px solid rgba(255, 170, 60, .5); }

/* ------------------------------------------------ モーダル */
.overlay { position: fixed; inset: 0; display: none; place-items: center; background: rgba(4, 16, 9, .78); z-index: 40; padding: 16px; }
.overlay.show { display: grid; }
.modal { display: flex; flex-direction: column; background: var(--sheet); border: 2px solid rgba(236, 244, 226, .18); border-radius: 18px; padding: 18px 20px; max-width: 480px; width: 100%; max-height: min(90vh, 90dvh); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); overflow: hidden; }
.modal.wide { max-width: 900px; }
.modal h2, .modal h3 { margin: 0 0 4px; }
.modal p { margin: 4px 0; }
.modal-head { flex: none; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 6px -8px; padding: 6px 8px; }
.modal-foot { flex: none; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding-top: 10px; }
.cards-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0; }
.cards-grid .card { --w: 150px; cursor: pointer; }
.cards-grid.pick .card { transition: transform .12s; }
.cards-grid .card.chosen { box-shadow: 0 0 0 4px var(--gold), 0 0 22px rgba(242, 226, 122, .85); transform: translateY(-4px); }
.result h2 { font-size: 48px; margin: 6px 0; font-family: var(--hand); font-weight: 400; transform: rotate(-3deg); }
.result.win h2 { color: var(--gold); text-shadow: 0 0 10px rgba(242, 226, 122, .5); }
.result.lose h2 { color: #b9c9bd; }

/* ------------------------------------------------ 詳細シート */
.sheet-layer { position: fixed; inset: 0; z-index: 45; display: none; }
.sheet-layer.show { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 16, 9, .6); }
.sheet {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: var(--sheet); border: 2px solid rgba(236, 244, 226, .18); border-radius: 20px; padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  display: flex; gap: 18px; align-items: flex-start; user-select: text;
}
.sheet.fresh { animation: sheetIn .18s ease-out; }
@keyframes sheetIn { from { opacity: 0; transform: translate(-50%, -46%); } }
.sheet-card { flex: none; }
.sheet .card.xl { --w: min(250px, calc(100dvh * 0.5 * 5 / 7)); }
.sheet-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
.sheet-side.full { width: 100%; }
.sheet-side h3 { margin: 0; }
.sheet-side .pv-meta { font-size: 13px; }
.sheet-status { margin: 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); font-size: 13px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.sheet-actions .btn { width: 100%; min-height: 48px; }
.sheet-log .log { border: 1px solid var(--line); border-radius: 12px; max-height: 60dvh; min-height: 200px; }
.help { margin: 0; padding-left: 1.2em; }
.help li { margin: 6px 0; }
.qty { display: flex; align-items: center; gap: 10px; }
.qty .btn { flex: 1; font-size: 22px; min-height: 52px; }
.qty b { flex: 1.4; text-align: center; }

/* ------------------------------------------------ デッキ構築 */
body:has(#app.builder-page) { overflow: hidden; }
.builder { height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 10px; padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l)); }
.b-head { flex: none; display: flex; align-items: center; gap: 8px; }
.b-head .btn { flex: none; white-space: nowrap; }
.b-head .dname { flex: 1 1 auto; min-width: 0; max-width: 360px; font-weight: 700; font-size: 16px; }
.b-head select { flex: 0 1 180px; min-width: 0; margin-left: auto; }
.b-tabs { display: none; }
.b-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); gap: 14px; }
.b-pool { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters #q { flex: 1 1 220px; min-width: 0; }
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-row select { min-width: 0; }
.chk { display: flex; gap: 4px; align-items: center; font-size: 13px; white-space: nowrap; }
.chk input { min-height: 0; }
.free-mode { white-space: normal; margin: 0 0 8px; }
.hint { margin: 6px 0 0; }
.pool { --pw: 112px; flex: 1; min-height: 0; overflow: hidden auto; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--pw), 1fr)); gap: 10px 8px; align-content: start; justify-items: center; margin-top: 6px; padding: 10px 10px 20px; }
.pool .more { grid-column: 1 / -1; text-align: center; }
.pool-more { grid-column: 1 / -1; height: 1px; }
/* 画面外のカードは描かない（content-visibility）。はみ出す枚数札・＋ボタン・光る枠が切れないよう、周りに余白を持たせて負のマージンで打ち消す */
.pool-item { position: relative; padding: 10px; margin: -10px; content-visibility: auto; contain-intrinsic-size: auto calc(var(--pw) + 20px) auto calc(var(--pw) * 1.4 + 20px); }
.pool-item .card { --w: var(--pw); cursor: pointer; transition: transform .12s; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 2px 0 1px rgba(0, 0, 0, .3); }
.pool-item .c-art > span { filter: none; }
.pool-item.in .card { box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 0 4px #a6e36b, 0 2px 0 4px rgba(0, 0, 0, .3); }
.pool-item .card.orica { box-shadow: 0 0 0 2px #f2d75a, 0 0 8px 1px rgba(255, 225, 110, .7); }
.pool-item.in .card.orica { box-shadow: 0 0 0 2px #f2d75a, 0 0 0 5px #a6e36b, 0 0 8px 5px rgba(255, 225, 110, .6); }
.pool-item .cnt { position: absolute; left: 6px; top: 4px; background: #111; color: #fff; font-weight: 800; border-radius: 2px; padding: 0 7px; font-size: 13px; border: 1px solid #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
.pool-item .add { position: absolute; left: 4px; bottom: 4px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #a9cf45; background: #2c6b45; color: #fbfff0; font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; box-shadow: 0 2px 0 rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 0; }
.pool-item .add:active { transform: scale(.9); }
.pool-item .sub { display: none; position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border-radius: 50%; border: 3px solid #e7a08a; background: #7a3326; color: #fff; font-size: 18px; font-weight: 800; line-height: 1; cursor: pointer; box-shadow: 0 2px 0 rgba(0, 0, 0, .45); place-items: center; padding: 0; }
.pool-item.in .sub { display: grid; }
.pool-item .sub:active { transform: scale(.9); }
.pool-item.can .c-foot { margin-left: 24px; }
@media (hover: hover) { .pool-item .card:hover { transform: translateY(-3px); } }
.b-deck { display: flex; flex-direction: column; gap: 6px; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.dcount { font-size: 26px; font-weight: 800; margin: 0; font-family: 'M PLUS Rounded 1c'; line-height: 1.1; }
.dcount small { font-size: 14px; color: var(--muted); }
.dcount.ok { color: var(--ok); }
#dstat p { margin: 2px 0; }
.curve { display: flex; gap: 4px; height: 56px; align-items: flex-end; margin: 4px 0; }
.curve div { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.curve em { font-style: normal; font-size: 9px; color: var(--muted); line-height: 1; }
.curve span { width: 100%; background: rgba(236, 244, 226, .75); border-radius: 3px 3px 0 0; min-height: 1px; }
.curve small { font-size: 10px; color: var(--muted); }
.dlist { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.dlist h4 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.drow { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 6px; border-radius: 8px; background: rgba(255, 255, 255, .04); border-left: 4px solid var(--a); margin-bottom: 3px; font-size: 13px; min-height: 36px; }
.drow.orica { background: rgba(242, 226, 122, .12); }
.dcost { width: 22px; text-align: center; font-weight: 800; color: var(--gold); font-size: 12px; flex: none; }
.dname { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.drow b { min-width: 16px; text-align: center; }
.drow button { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--btn-edge); background: var(--btn); color: #fff; cursor: pointer; font-size: 16px; padding: 0; }
.drow button:active { background: #2f7550; }
.empty-deck { text-align: center; margin-top: 24px; }
.b-tools { flex: none; display: flex; gap: 6px; }
.b-tools .btn { flex: 1; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
.b-deck-foot { flex: none; display: flex; flex-wrap: wrap; gap: 6px; }
.b-deck-foot .btn { flex: 1; }
.b-deck-foot .btn.primary { flex: 1 0 100%; }
.b-deck-foot .btn { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
.b-preview { display: none; }
.b-bottom { display: none; }
@media (min-width: 1100px) and (hover: hover) {
  .b-main { grid-template-columns: minmax(0, 1fr) 300px 250px; }
  .b-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; overflow: auto; }
  .b-preview .card.xl { --w: min(240px, calc(60dvh * 5 / 7)); }
}

/* ------------------------------------------------ 画面が狭い・タッチ操作 */
@media (max-width: 999px), (hover: none) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .panel { display: none; }
  .table { --peek: 1; --hw: clamp(62px, 17vw, 96px); padding-bottom: 2px; }
  .hand { --hand-pad: 14px; }
  .popups { left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); align-items: center; }
  .popup { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
  .popup p { margin: 0; }
  .popup .card { --w: 76px; }
  .popup.out { transform: translateY(-12px); }
}

/* デッキ構築：1列＋タブ */
@media (max-width: 799px) {
  .builder { padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l)); gap: 8px; }
  .b-head .dname { font-size: 15px; }
  .b-head select { flex-basis: 96px; }
  .b-tabs { flex: none; display: flex; background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 3px; gap: 3px; }
  .b-tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
  .b-tabs button.on { background: var(--btn); color: var(--text); box-shadow: inset 0 0 0 2px var(--btn-edge); }
  .b-tabs b { color: var(--gold); margin-left: 4px; }
  .b-main { grid-template-columns: minmax(0, 1fr); }
  .builder[data-tab="pool"] .b-deck, .builder[data-tab="deck"] .b-pool { display: none; }
  .b-deck { background: transparent; border: 0; padding: 0; }
  .b-deck-foot .btn.primary { display: none; }
  .b-deck-foot { justify-content: center; padding-bottom: 8px; }
  .filter-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; }
  .filter-row select { flex: 1 0 auto; padding: 8px 6px; }
  .pool { --pw: calc((100vw - 24px - 20px - 16px) / 3); gap: 12px 8px; }
  .b-bottom { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -12px; padding: 8px 12px calc(8px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(16, 42, 27, .95); }
  .b-bottom span { display: flex; flex-direction: column; line-height: 1.2; }
  .b-bottom b { font-size: 18px; font-family: 'M PLUS Rounded 1c'; }
  .b-bottom b.ok { color: var(--ok); }
  .b-bottom .btn { min-width: 120px; }
}

/* 詳細シート：狭い画面では下から出す */
@media (max-width: 639px) {
  .sheet { top: auto; bottom: 0; transform: translateX(-50%); width: 100%; max-height: 94dvh; border-radius: 20px 20px 0 0; border-bottom: 0;
    flex-direction: column; align-items: center; gap: 10px; padding: 8px 16px calc(14px + var(--safe-b)); }
  .sheet::before { content: ''; flex: none; width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
  .sheet.fresh { animation: sheetUp .22s ease-out; }
  @keyframes sheetUp { from { transform: translate(-50%, 40%); opacity: .4; } }
  .sheet .card.xl { --w: min(250px, 66vw, calc((94dvh - 230px) * 5 / 7)); }
  .sheet-side { width: 100%; }
  .sheet-actions { position: sticky; bottom: calc(-14px - var(--safe-b)); margin: 0 -16px calc(-14px - var(--safe-b)); padding: 8px 16px calc(14px + var(--safe-b)); background: linear-gradient(transparent, var(--sheet) 14px); }
  .overlay { padding: 0; place-items: end center; }
  .overlay:has(.modal.center) { place-items: center; padding: 16px; }
  .modal:not(.center) { border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 94dvh; padding: 16px 12px calc(12px + var(--safe-b)); }
  .modal .cards-grid .card { --w: calc((100vw - 24px - 16px - 4px) / 3); font-size: clamp(9px, calc(var(--w) / 8.5), 13px); gap: .25em; padding: .3em; }
  .modal .cards-grid .card :is(.c-text, .c-foot.line, .c-foot .c-type) { display: none; }
  .modal .cards-grid .card .c-art { flex: 1 1 auto; font-size: 2.4em; }
  .modal .cards-grid .card .c-pow { flex: 1; font-size: 1.1em; }
  .modal-foot .btn { flex: 1 1 40%; }
  .result h2 { font-size: 36px; }
  .actionbar { padding-left: 10px; }
  .prompt { font-size: 14px; }
  .btn.end { min-width: 0; padding: 8px 14px; }
}

/* 小さいスマホ */
@media (max-width: 380px) {
  .table { --sup-h: 36px; padding-left: calc(6px + var(--safe-l)); padding-right: calc(6px + var(--safe-r)); gap: 5px; }
  .avatar { display: none; }
  .stat { padding: 2px 5px; font-size: 12px; }
  .stat b { font-size: 13px; }
  .lp b { font-size: 19px; }
  .pbar { gap: 6px; }
  .actionbar .btn { padding: 8px 10px; font-size: 13px; }
}
@media (max-width: 639px) { .table { --sup-h: 40px; } .mons { --gap: 6px; padding: 0 4px; } .pbar { min-height: 42px; } .fieldcard.empty { width: 56px; padding: 3px 4px; } }

/* 背の低い画面（スマホ横向き・小さいノートPC） */
@media (max-height: 560px) {
  .table { --sup-h: 34px; gap: 4px; padding-top: calc(4px + var(--safe-t)); }
  .pbar { min-height: 38px; padding: 2px 6px; }
  .avatar { width: 28px; height: 28px; font-size: 14px; }
  .lp b { font-size: 18px; }
  .actionbar { min-height: 42px; padding-top: 3px; padding-bottom: 3px; }
  .btn { min-height: 36px; padding: 6px 12px; }
  .hand { --hand-pad: 10px; }
  .sheet .card.xl { --w: min(220px, calc((100dvh - 60px) * 5 / 7)); }
}
@media (max-height: 560px) and (max-width: 999px), (max-height: 560px) and (hover: none) {
  .table { --hw: clamp(56px, 13dvh, 72px); --peek: .75; }
  .hand .slot:first-child ~ .slot { margin-left: 3px; }
}
@media (max-height: 560px) and (orientation: landscape) and (max-width: 999px) {
  .sheet { top: 50%; bottom: auto; transform: translate(-50%, -50%); flex-direction: row; align-items: flex-start; width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 16px); border-radius: 18px; border-bottom: 1px solid var(--line); padding: 12px; }
  .sheet::before { display: none; }
  .sheet .card.xl { --w: calc((100dvh - 50px) * 5 / 7); }
  .sheet-actions { position: static; margin: auto 0 0; padding: 0; background: none; }
  .overlay { place-items: center; padding: 8px; }
  .modal:not(.center) { border-radius: 18px; max-height: calc(100dvh - 16px); border-bottom: 1px solid var(--line); }
  .modal .cards-grid .card { --w: 88px; }
}

/* 横向きで背が低い画面：盤面を左、プレイヤー情報と操作ボタンを右に */
@media (max-height: 560px) and (orientation: landscape) {
  .table {
    --peek: 1; --hw: clamp(50px, 14dvh, 64px);
    display: grid; column-gap: 8px; row-gap: 4px;
    grid-template-columns: minmax(0, 1fr) clamp(170px, 26vw, 230px);
    grid-template-rows: auto auto 1fr 1fr 1fr 1fr auto auto;
    grid-template-areas: 'banner banner' 'osup opbar' 'omons opbar' 'omons act' 'mmons act' 'mmons mpbar' 'msup mpbar' 'hand mpbar';
  }
  .zone { display: contents; }
  .banner { grid-area: banner; }
  .zone.op .pbar { grid-area: opbar; }
  .zone.op .support { grid-area: osup; }
  .zone.op .mons { grid-area: omons; }
  .zone.me .mons { grid-area: mmons; }
  .zone.me .support { grid-area: msup; }
  .zone.me .pbar { grid-area: mpbar; }
  .actionbar { grid-area: act; }
  .hand { grid-area: hand; }
  .pbar { flex-wrap: wrap; align-content: center; align-self: stretch; row-gap: 4px; }
  .pbar .stats { margin-left: 0; flex-wrap: wrap; width: 100%; }
  .pbar .pinfo { flex: 1; }
  .actionbar { flex-direction: column; align-items: stretch; justify-content: center; padding: 6px; text-align: center; }
  .actionbar .prompt { align-items: center; font-size: 13px; }
  .actionbar .buttons { flex-direction: column; }
  .actionbar .btn { width: 100%; }
  .avatar { display: none; }
  .pbar { position: relative; }
  .pbar .iconbtn { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; }
  .pbar.op .pinfo { padding-right: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------ デッキの一覧画像 */
.deck-shot { z-index: 50; }
.shot-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1100px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--sheet); border: 2px solid rgba(236, 244, 226, .18); border-radius: 16px; padding: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center;
}
.shot-box img { display: block; width: 100%; height: auto; border-radius: 8px; }
.shot-box p { margin: 0; }
.shot-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.shot-actions .btn { text-decoration: none; }
.b-bottom [data-shot] { margin-left: auto; }
.b-bottom .btn.undo { min-width: 0; margin-left: auto; padding-left: 14px; padding-right: 14px; }
.b-bottom .btn.undo + [data-shot] { margin-left: 0; }

/* ------------------------------------------------ カードのイラスト（AnokoroImageFolder の画像。読めるまでは絵文字） */
.c-art, .m-art { position: relative; }
.art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .15s; pointer-events: none; mix-blend-mode: multiply; }
.has-img > .art-img { opacity: 1; }
.has-img > span { visibility: hidden; }
.m-art.has-img { filter: none; }
.c-art.has-img > span { filter: none; }
/* 場のモンスター：イラストをカードの幅いっぱい・名前とパワーの裏まで広げて大きく見せる（横長の絵の左右の余白を少し切る） */
.m-art { align-self: stretch; }
/* .m-art は font-size: 2.7em なので、カードの余白 .35em ＝ .13em、名前・パワーの裏まで .5em ≒ .19em */
.m-art .art-img { inset: -.19em -.13em; width: calc(100% + .26em); height: calc(100% + .38em); object-fit: cover; }
.m-name, .m-pow { position: relative; z-index: 1; }

/* ------------------------------------------------ デッキコード */
.code-box { width: min(520px, calc(100% - 32px)); }
.code-box h3 { margin: 0; }
.deck-code {
  width: 100%; resize: vertical; font: 13px/1.5 ui-monospace, Consolas, monospace; word-break: break-all;
  background: rgba(0, 0, 0, .25); color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}

/* ランダムマッチで待っている人の通知 */
.match-banner { position: fixed; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 32px); background: #173a27; border: 1px solid var(--gold); border-radius: 12px; padding: 8px 8px 8px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: banner-in .3s ease-out; }
.match-banner p { margin: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.match-banner small { color: var(--muted); }
.match-banner .btn { flex: none; }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -12px); } }
.lobby-st { margin: 0; color: var(--gold); }
/* ランダムマッチの対戦の条件 */
.opt-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0, 0, 0, 0.14); }
.opt { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; font-size: 13px; cursor: pointer; }
.opt input { min-height: 0; margin: 2px 0 0; }
.opt small { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; margin-top: 1px; }
.opt:has(input:disabled) { cursor: default; opacity: 0.6; }
.push-chk { padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); }
.panel-box.flash { animation: box-flash 1.2s ease-out 2; }
@keyframes box-flash { 50% { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 226, 122, .35); } }

/* ------------------------------------------------ バグ報告 */
.bug-box { text-align: left; align-items: stretch; }
.bug-box label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.bug-box label.bug-check { flex-direction: row; align-items: center; gap: 8px; }
.bug-box input:not([type]) { width: 100%; }
.bug-box input[type=checkbox] { min-height: 0; width: 18px; height: 18px; }

/* ------------------------------------------------ デッキ紹介 */
.post-search select { flex: 0 1 auto; min-width: 0; }
.post-more[hidden] { display: none; }
.post-snip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-likes { align-self: center; color: var(--muted); font-size: 13px; white-space: nowrap; }
.post-likes.on, .post-like.on { color: var(--danger); }
.post-like { white-space: nowrap; }
.post-title { margin: 8px 0 2px; font-size: 20px; }
.post-page > [data-post] > p { margin: 4px 0; }
.post-comment { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; margin: 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.post-acts { justify-content: flex-start; margin: 12px 0; }
.post-shot { margin-top: 8px; }
.post-cards:empty { display: none; }
.post-cards-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.post-cards ul { list-style: none; margin: 0; padding: 6px 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 12px;
  max-height: 180px; overflow: auto; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.post-cards li { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.pc-tab { flex: none; width: 2em; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.pc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-n { flex: none; color: var(--muted); }
.post-shot img { display: block; width: 100%; height: auto; border-radius: 8px; cursor: zoom-in; }

/* ------------------------------------------------ リプレイ */
.actionbar.replaying { border-color: rgba(242, 226, 122, .45); }
.rp-state { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.replay-box { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.replay-ctl { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.replay-ctl .iconbtn { width: 34px; height: 34px; font-size: 14px; }
.replay-ctl .iconbtn.wide { width: auto; padding: 0 6px; font-size: 12px; }
.replay-ctl .iconbtn.play { background: var(--gold); color: #1f2a17; }
.replay-seek { width: 100%; margin: 0; accent-color: var(--gold); }
@media (max-width: 639px) {
  .actionbar.replaying { flex-direction: column; align-items: stretch; padding: 4px 6px; gap: 4px; }
  .actionbar.replaying .prompt { font-size: 13px; }
  .actionbar.replaying .buttons { justify-content: center; }
  .actionbar.replaying .replay-box { width: 100%; }
}
@media (max-width: 380px) { .replay-ctl .iconbtn { width: 30px; height: 32px; } }
/* 横向きで背が低い画面：操作ボタンを1列に収める */
@media (max-height: 560px) and (orientation: landscape) {
  .actionbar.replaying { gap: 2px; padding: 4px; }
  .actionbar.replaying .prompt { font-size: 12px; }
  .replay-ctl { gap: 3px; flex-wrap: nowrap; }
  .replay-ctl .iconbtn { width: 25px; height: 28px; font-size: 11px; border-radius: 7px; }
  .replay-ctl .iconbtn.wide { width: auto; padding: 0 3px; font-size: 10px; }
}
.result-sub { padding-top: 6px; }
.result-sub .btn { flex: 0 1 auto !important; }
.replay-list { display: flex; flex-direction: column; gap: 8px; }
.replay-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.rr-main { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rr-main small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.rr-res.win { color: var(--gold); font-weight: 700; }
.rank-row { flex-wrap: nowrap; }
.rank-row .rr-main { flex: 1 1 auto; }
.rank-no { min-width: 2.2em; text-align: center; font-size: 18px; color: var(--gold); }
.rank-rate { font-size: 18px; font-variant-numeric: tabular-nums; }
.rr-btns { display: flex; gap: 6px; margin-left: auto; }
.deck-new { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.deck-new select { flex: 0 1 auto; min-width: 0; }
.deck-row { border-left: 5px solid #9aa3b5; }
.deck-row .rr-main { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.deck-row .rr-btns { flex-wrap: wrap; }

/* 大会 */
.tourney .t-title { margin: 4px 0 2px; }
.tourney > div + div { margin-top: 14px; }
.t-champ { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px; border-radius: 14px; border: 2px solid var(--gold); background: rgba(242, 226, 122, .1); text-align: center; }
.t-champ span { color: var(--gold); font-weight: 800; }
.t-champ b { font-size: 22px; }
.t-champ small { color: var(--muted); }
.t-next { border-color: var(--ok); }
.t-next p { margin: 0; }
.t-bracket-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.t-bracket { display: flex; gap: 14px; min-width: min-content; padding-bottom: 8px; }
.t-round { display: flex; flex-direction: column; gap: 6px; width: 210px; flex: 0 0 210px; }
.t-ms { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.t-round h4 { margin: 0; text-align: center; color: var(--muted); font-size: 12px; }
.t-match { display: flex; flex-direction: column; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; text-align: left; overflow: hidden; cursor: pointer; }
.t-match:disabled { cursor: default; }
.t-match.live { border-color: var(--accent); }
.t-match.bye { opacity: .6; }
.t-slot { display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-height: 40px; }
.t-slot + .t-slot { border-top: 1px solid var(--line); }
.t-slot span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t-slot b, .t-slot small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-slot b { font-size: 13px; }
.t-slot small { font-size: 10px; color: var(--muted); }
.t-slot em { font-style: normal; font-weight: 800; font-size: 13px; }
.t-slot.win { background: rgba(166, 227, 107, .14); }
.t-slot.win em { color: var(--ok); }
.t-slot.lose { opacity: .5; }
.t-slot.me b { color: var(--gold); }
.t-slot.empty { color: var(--muted); font-size: 12px; }
.t-note { padding: 2px 8px 4px; font-size: 10px; color: var(--muted); }
.replay-row.invalid { opacity: .55; }
.t-create h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.t-create .field { margin: 6px 0; }
.t-create .field select { flex: 1; min-width: 0; max-width: 320px; }
.t-row { display: flex; gap: 12px; flex-wrap: wrap; }
.t-row .field { flex: 1 1 140px; }
.t-rules { margin: 4px 0 8px; padding-left: 18px; color: var(--muted); }
.t-rules li { margin: 1px 0; }
.t-list .t-ms { justify-content: flex-start; }
.t-table-wrap { overflow-x: auto; }
.t-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.t-table th, .t-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.t-table th { color: var(--muted); font-size: 11px; font-weight: 700; }
.t-table td:nth-child(2) { text-align: left; white-space: normal; }
.t-table td small { display: block; color: var(--muted); font-size: 10px; }
.t-table tr.me b { color: var(--gold); }
.t-table tr.out { opacity: .55; }
.t-table tbody tr:first-child td:first-child { color: var(--gold); font-weight: 800; }
.t-pickbox { text-align: left; width: min(520px, 100%); margin: 8px auto; }
.t-pickbox h4 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.replay-row.t-picked { border-color: var(--ok); }
.t-decks .field select { flex: 1; min-width: 0; max-width: 360px; }

/* 更新情報 */
.news-btn { position: relative; }
.new-dot { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #1d1d1d; font-size: 10px; font-weight: 800; line-height: 1.6; vertical-align: middle; }
.news-box { align-items: stretch; text-align: left; }
.news-box h3 { text-align: center; }
/* 一覧だけをスクロールさせて、閉じるボタンはいつも見えるようにする */
.news-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; }
.news-item { border-top: 1px solid var(--line); padding-top: 8px; }
.news-item h4 { margin: 0 0 4px; font-size: 15px; }
.news-item h4 .new-dot { margin: 0 6px 0 0; }
.news-item time { color: var(--muted); font-size: 12px; font-weight: 500; margin-right: 8px; }
.news-item ul { margin: 0; padding-left: 1.3em; font-size: 13px; line-height: 1.6; }

/* チーム戦：メンバーの並び・合言葉・チームの移動 */
.t-members { margin: 6px 0; padding-left: 1.4em; }
.t-members li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; flex-wrap: wrap; }
.t-members li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.t-code { font-family: monospace; font-size: 1.15em; letter-spacing: .1em; }
.t-move { max-width: 160px; }
.t-next ol { margin: 4px 0; }
/* 大会を作る：細かい設定は開いて変える。見出しの下にいまの設定を1行で出す */
.t-sec { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.t-sec > summary { cursor: pointer; padding: 10px 0; display: flex; flex-direction: column; gap: 2px; list-style: none; }
.t-sec > summary::-webkit-details-marker { display: none; }
.t-sec > summary b::before { content: '▸ '; color: var(--muted); }
.t-sec[open] > summary b::before { content: '▾ '; }
.t-sec > summary span { font-size: 12px; color: var(--muted); }
.t-sec[open] > summary span { display: none; }
.t-sec[open] { padding-bottom: 12px; }
.t-sec h4:first-of-type { margin-top: 4px; }
/* 大会の画面：対戦表・順位表・チーム・エントリーを切り替えるタブ */
.t-tabs { display: flex; flex-wrap: wrap; background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 3px; gap: 3px; margin: 16px 0 4px; }
.t-tabs button { flex: 1 1 auto; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; padding: 0 10px; }
.t-tabs button.on { background: var(--btn); color: var(--text); box-shadow: inset 0 0 0 2px var(--btn-edge); }
.t-rulebox { margin: 6px 0 8px; }
.t-rulebox .t-rules { margin-top: 0; }
.tourney .t-when { margin: 2px 0 6px; font-weight: 700; }
.tourney .t-when small { margin-left: 6px; font-weight: 400; }
.t-schedule { width: 100%; text-align: left; }
.t-row .field.t-dt { flex: 1 1 180px; flex-direction: column; align-items: stretch; gap: 4px; }
.t-dt input { max-width: none; }
/* タイトル画面：エントリーを募集中の大会 */
.t-ad-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(420px, 100%); }
.t-ad { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 14px 16px 12px; border: 2px solid var(--gold); border-radius: 14px; background: linear-gradient(160deg, rgba(242, 226, 122, .2), rgba(0, 0, 0, .22)); color: var(--text); font: inherit; cursor: pointer; text-align: center; box-shadow: 0 0 0 0 rgba(242, 226, 122, .5), 0 8px 22px rgba(0, 0, 0, .35); animation: t-ad-glow 2.4s ease-in-out infinite; }
.t-ad:hover { background: linear-gradient(160deg, rgba(242, 226, 122, .3), rgba(0, 0, 0, .18)); }
.t-ad:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.t-ad-badge { padding: 2px 12px; border-radius: 99px; background: var(--gold); color: #2a2a12; font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.t-ad-name { font-family: var(--hand); font-weight: 400; font-size: clamp(22px, 6vw, 30px); line-height: 1.25; color: #fffbe0; overflow-wrap: anywhere; }
.t-ad small { color: var(--muted); font-size: 12px; }
.t-ad small.t-ad-when { color: #fffbe0; font-weight: 700; }
.t-ad-foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; margin-top: 4px; font-size: 13px; }
.t-ad-go { padding: 4px 14px; border-radius: 8px; background: var(--btn); border: 1px solid var(--btn-edge); font-weight: 700; color: var(--gold); }
.t-ad-more { color: var(--gold); }
.t-ad-row { border-color: var(--gold); }
@keyframes t-ad-glow { 50% { box-shadow: 0 0 18px 2px rgba(242, 226, 122, .35), 0 8px 22px rgba(0, 0, 0, .35); } }
@media (prefers-reduced-motion: reduce) { .t-ad { animation: none; } }
@media (max-height: 520px) and (min-width: 560px) {
  .t-ad-wrap { width: min(620px, 100%); }
  .t-ad { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 8px 12px; gap: 4px 10px; }
  .t-ad-name { font-size: 20px; }
  .t-ad small { display: none; }
  .t-ad-foot { margin: 0; }
}

/* 引き継ぎ */
.transfer-box { align-items: stretch; text-align: left; overflow: auto; }
.transfer-box h3 { text-align: center; }
.transfer-box section { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.transfer-box h4 { margin: 0; font-size: 15px; }
.transfer-box .error:empty { display: none; }
[data-code-out] p { text-align: center; }
.transfer-code { font-size: 32px; font-weight: 800; letter-spacing: .12em; text-align: center; font-family: ui-monospace, monospace; user-select: all; }

/* 戦績 */
.stats-page { max-width: 820px; --st-win: var(--gold); --st-lose: #ff8a7a; --st-draw: #8fa396; }
.st-filters { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 4px 0 14px; }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.st-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.st-kpi small, .st-kpi span { color: var(--muted); font-size: 11px; }
.st-kpi b { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-kpi .st-big { font-size: 30px; color: var(--gold); line-height: 1.1; }
@media (max-width: 560px) { .st-kpis { grid-template-columns: repeat(2, 1fr); } }
.st-bar { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, .06); }
.st-bar i { display: block; min-width: 2px; }
.st-bar.empty { opacity: .4; }
i.st-win, .st-legend .st-win { background: var(--st-win); } i.st-lose, .st-legend .st-lose { background: var(--st-lose); } i.st-draw, .st-legend .st-draw { background: var(--st-draw); }
.st-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 2px; font-size: 12px; color: var(--muted); }
.st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.st-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.st-legend i.st-l-recent { height: 3px; background: var(--accent); }
.st-legend i.st-l-total { height: 0; border-top: 2px dashed var(--muted); border-radius: 0; }
.st-card { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.st-card h3 { margin: 0 0 6px; font-size: 15px; }
.st-card > p.small { margin: 0 0 6px; }
.st-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 640px) { .st-two { grid-template-columns: 1fr; } }
.st-svg { display: block; width: 100%; height: auto; max-width: 100%; overflow: visible; touch-action: pan-y; }
.st-svg rect.st-win { fill: var(--st-win); } .st-svg rect.st-lose { fill: var(--st-lose); } .st-svg rect.st-draw { fill: var(--st-draw); }
.st-grid { stroke: var(--line); stroke-width: 1; }
.st-ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: .7; }
.st-ax { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.st-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.st-line.st-l-recent { stroke: var(--accent); }
.st-line.st-l-total { stroke: var(--muted); stroke-dasharray: 5 4; }
.st-dot { stroke: var(--bg); stroke-width: 2; }
.st-dot.st-l-recent { fill: var(--accent); } .st-dot.st-l-total { fill: var(--muted); r: 0; }
.st-cross { stroke: var(--text); stroke-width: 1; opacity: .5; }
.st-hit { fill: transparent; cursor: crosshair; }
.st-tip { position: fixed; z-index: 50; pointer-events: none; white-space: pre-line; padding: 6px 10px; border-radius: 8px; background: #0e2418; border: 1px solid var(--line); color: var(--text); font-size: 12px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.st-rows { display: flex; flex-direction: column; gap: 8px; }
.st-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 3.2em; align-items: center; gap: 10px; }
.st-lab { display: flex; flex-direction: column; min-width: 0; }
.st-lab b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.st-lab small { color: var(--muted); font-size: 11px; }
.st-pct { text-align: right; font-variant-numeric: tabular-nums; }
.st-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; }
.st-head b { font-size: 26px; }
.st-up { color: var(--ok); font-weight: 700; } .st-down { color: var(--st-lose); font-weight: 700; }
.st-match { flex-wrap: nowrap; border-left: 5px solid var(--st-draw); }
.st-m-win { border-left-color: var(--st-win); } .st-m-lose { border-left-color: var(--st-lose); }
.st-res { flex: none; min-width: 4.5em; font-size: 13px; }
.st-m-win .st-res { color: var(--st-win); } .st-m-lose .st-res { color: var(--st-lose); } .st-m-draw .st-res { color: var(--st-draw); }
.st-foot { margin-top: 18px; }
.st-cross[hidden] { display: none; }
