:root {
  --bg: #141024; --panel: #231c3d; --panel2: #2e2550; --panel3: #3a2f66; --line: #0b0814;
  --text: #f4efe6; --muted: #a79fc4; --p0: #3d7be0; --p0d: #22477f; --p1: #d9473b; --p1d: #7d2420;
  --gold: #f4c542; --accent: #ffe066;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(#ffffff0a 1px, transparent 1px);
  background-size: 8px 8px;
  color: var(--text);
  font-family: 'DotGothic16', 'MS Gothic', monospace;
  min-height: 100vh;
}
img, canvas { image-rendering: pixelated; }
button, select, input { font-family: inherit; }

.px-btn {
  font-size: 16px; color: var(--text); background: var(--panel2); border: 0; padding: 8px 18px; cursor: pointer;
  box-shadow: 0 0 0 3px var(--line), inset -3px -3px 0 rgba(0,0,0,.35), inset 3px 3px 0 rgba(255,255,255,.12);
  margin: 3px;
}
.px-btn:hover:not(:disabled) { background: var(--panel3); }
.px-btn:active:not(:disabled) { transform: translateY(2px); }
.px-btn:disabled { opacity: .35; cursor: default; }
.px-btn.primary { background: #b8862a; color: #1b1426; }
.px-btn.primary:hover:not(:disabled) { background: var(--gold); }
.px-btn.off { opacity: .45; text-decoration: line-through; }
.px-btn.small { font-size: 13px; padding: 4px 10px; }
.px-btn.big { font-size: 20px; padding: 12px 28px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); box-shadow: 0 3px 0 var(--line);
}
.logo { font-size: 22px; letter-spacing: 3px; color: var(--gold); text-shadow: 2px 2px 0 var(--line); }
.logo span { font-size: 13px; color: var(--muted); letter-spacing: 0; }
.round-info { font-size: 16px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; max-width: 1180px; margin: 0 auto; padding: 16px; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.play-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.side-col { background: var(--panel); box-shadow: 0 0 0 3px var(--line); padding: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 100px); }
@media (max-width: 900px) { .side-col { max-height: 300px; } }
.side-col h2 { margin: 0 0 6px; font-size: 16px; color: var(--gold); }
#log { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.6; padding-right: 4px; }
#log .rh { color: var(--gold); margin-top: 6px; }
#log .p0 { color: #9cc2ff; } #log .p1 { color: #ffb0a6; } #log .sys { color: var(--muted); }

.player-bar {
  width: min(480px, 100%); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  background: var(--panel); box-shadow: 0 0 0 3px var(--line); padding: 6px 10px; margin: 8px 0; font-size: 14px;
}
.player-bar .pname { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.player-bar .chip { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--line); }
.player-bar .hearts img { width: 21px; height: 18px; margin-right: 2px; vertical-align: middle; }
.player-bar .hearts.hit { animation: shake .4s; }
.player-bar .info { color: var(--muted); font-size: 13px; margin-left: auto; }
.player-bar .info a { color: var(--accent); cursor: pointer; text-decoration: underline; }
.prio { background: var(--gold); color: var(--line); padding: 0 6px; font-size: 12px; }
.goalpts { color: var(--accent); font-size: 15px; display: inline-flex; align-items: center; gap: 1px; }
.goalpts img { width: 22px; height: 22px; margin-top: -4px; }
.ready { background: #2f7a5a; padding: 0 6px; font-size: 12px; }
/* 相手の手札（裏向き） */
.opp-hand { display: flex; align-items: flex-end; justify-content: center; min-height: 70px; padding-top: 6px; width: min(480px, 100%); }
.mini-back {
  width: 44px; height: 62px; margin: 0 3px; position: relative; flex: none;
  background: #4b3d80; background-image: repeating-linear-gradient(45deg, #5a4a96 0 4px, #4b3d80 4px 8px);
  box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px #2e2550, inset 0 0 0 4px #8b7bd0;
}
.mini-back::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; transform: translate(-50%, -50%) rotate(45deg);
  background: var(--gold); box-shadow: 0 0 0 2px var(--line), inset 0 0 0 3px #b8862a;
}
.mini-back.new { animation: deal .35s ease-out both; }
.opp-hand.many .mini-back { margin: 0 -6px; }
.opp-count { margin-left: 14px; font-size: 22px; color: var(--muted); align-self: center; }
@keyframes deal { 0% { opacity: 0; transform: translateY(-24px); } 100% { opacity: 1; } }

.board-frame { padding: 8px; background: var(--frame, #3b2a1a); box-shadow: 0 0 0 3px var(--line), inset 0 0 0 3px var(--frame-in, #5a4028); transition: background .3s; }
.board-wrap { position: relative; width: max(260px, min(460px, calc(100vw - 48px), calc(100vh - 400px))); }
.board-wrap canvas { display: block; width: 100%; height: auto; cursor: pointer; }
.board-wrap.shake { animation: shake .35s; }
.board-frame.bigshake { animation: bigshake .55s; }
@keyframes bigshake { 0%,100% { transform: none; } 10% { transform: translate(-9px,4px); } 25% { transform: translate(8px,-5px); } 40% { transform: translate(-6px,3px); } 55% { transform: translate(5px,-2px); } 70% { transform: translate(-3px,1px); } 85% { transform: translate(2px,0); } }
#label-layer, #fx-layer { position: absolute; inset: 0; pointer-events: none; }
.badge {
  position: absolute; width: 22%; transform: translate(-50%, -50%); font-size: clamp(9px, 2.6vw, 13px); line-height: 1;
  width: auto; padding: 1px 2px; color: #fff; box-shadow: 0 0 0 2px var(--line);
}
.badge.o0 { background: var(--p0d); } .badge.o1 { background: var(--p1d); }
.pop {
  position: absolute; transform: translate(-50%, -50%); font-size: 22px; color: #fff; white-space: nowrap;
  text-shadow: 2px 0 0 var(--line), -2px 0 0 var(--line), 0 2px 0 var(--line), 0 -2px 0 var(--line);
  animation: pop 1.1s ease-out forwards;
}
.pop.dmg { color: #ff6b6b; font-size: 28px; }
.pop.cap { color: var(--accent); }
.pop.info { color: #c8f0ff; font-size: 16px; }
@keyframes pop { 0% { opacity: 0; margin-top: 8px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -36px; } }
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-4px,2px); } 40% { transform: translate(4px,-2px); } 60% { transform: translate(-3px,0); } 80% { transform: translate(3px,1px); } }

/* チュートリアル：王様の吹き出し */
.coach {
  width: min(480px, 100%); display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 2px; padding: 10px;
  background: #fff8e6; color: #2a1d10; box-shadow: 0 0 0 3px var(--line), inset 0 0 0 2px #e6c98a;
}
.coach.hidden { display: none; }
.coach.nope { animation: shake .35s; }
.coach img { width: 56px; height: 56px; flex: none; box-shadow: 0 0 0 2px var(--line); }
.coach-body { flex: 1; min-width: 0; }
.coach-title { font-size: 12px; color: #9a6b1e; margin-bottom: 3px; }
.coach-text { font-size: 14px; line-height: 1.6; white-space: pre-line; }
.coach-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.coach-btns .px-btn { font-size: 14px; padding: 6px 12px; margin: 0; }
.tut-blink { animation: tutBlink .5s steps(1) infinite; }
@keyframes tutBlink { 0% { box-shadow: 0 0 0 3px #ff7ad9, 0 0 0 5px var(--line), 0 0 12px #ff7ad9; } 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px var(--line), 0 0 12px var(--accent); } }
.card.tut-target { animation: tutGlow 1s ease-in-out infinite; }
@keyframes tutGlow { 50% { box-shadow: 0 0 0 3px #ff7ad9, 0 0 0 6px var(--line), 0 0 14px #ff7ad9; transform: translateY(-6px); } }
.tut-list { display: flex; flex-direction: column; gap: 8px; }
.tut-item { flex-direction: row !important; justify-content: space-between; font-size: 16px; padding: 10px 16px; }
.tut-item b { color: #6fe08a; }
.hint { min-height: 26px; margin: 6px 0 2px; font-size: 15px; color: var(--accent); text-align: center; }
.hand-label { font-size: 12px; color: var(--muted); }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 172px; padding: 8px 0 4px; }
.hand-row { display: flex; align-items: flex-start; gap: 14px; justify-content: center; }
.piles { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.piles .deck-pile { padding-top: 8px; }
.piles .discard-pile { padding-top: 0; }
.piles .discard-pile .dstack { width: 64px; height: 92px; }
.piles .discard-pile .dstack img { width: 52px; height: 52px; }
@media (max-width: 700px) { .hand-row { flex-direction: column; align-items: center; } }

/* 山札：裏向きカードの束。残り枚数で厚みが変わる */
.deck-pile { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; }
.deck-pile .stack {
  width: 78px; height: 112px; position: relative;
  background: #4b3d80; background-image: repeating-linear-gradient(45deg, #5a4a96 0 5px, #4b3d80 5px 10px);
  box-shadow: 0 0 0 2px var(--line), inset 0 0 0 4px #2e2550, inset 0 0 0 5px #8b7bd0, var(--thick, none);
}
.deck-pile .stack::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%) rotate(45deg);
  background: var(--gold); box-shadow: 0 0 0 2px var(--line), inset 0 0 0 4px #b8862a;
}
.deck-pile .stack.empty { background: none; box-shadow: inset 0 0 0 2px #4b3d80; }
.deck-pile .stack.empty::after { display: none; }
.deck-pile .count { font-size: 13px; color: var(--muted); }
.deck-pile.mini { padding: 0 14px 0 0; align-self: center; }
.deck-pile.mini .stack { width: 40px; height: 58px; }
.deck-pile.mini .stack::after { width: 10px; height: 10px; }

/* 山札の切り直し：束が左右に割れて混ざる */
.deck-pile { position: relative; }
.deck-pile::before, .deck-pile::after {
  content: ''; position: absolute; left: 50%; top: 12px; width: 78px; height: 112px; margin-left: -39px; opacity: 0; pointer-events: none;
  background: #4b3d80; background-image: repeating-linear-gradient(45deg, #5a4a96 0 5px, #4b3d80 5px 10px);
  box-shadow: 0 0 0 2px var(--line), inset 0 0 0 4px #2e2550, inset 0 0 0 5px #8b7bd0;
}
.deck-pile.mini::before, .deck-pile.mini::after { top: 0; width: 40px; height: 58px; margin-left: -27px; }
.deck-pile.shuffling::before { animation: riffleL 1s ease-in-out; }
.deck-pile.shuffling::after { animation: riffleR 1s ease-in-out; }
.deck-pile.shuffling .stack { animation: pileBump 1s ease-in-out; }
.deck-pile .count.shuf { color: var(--accent); }
@keyframes riffleL { 0% { opacity: 1; transform: none; } 20%, 60% { opacity: 1; transform: translateX(-30px) rotate(-12deg); } 40%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: none; } }
@keyframes riffleR { 0% { opacity: 1; transform: none; } 20%, 60% { opacity: 1; transform: translateX(30px) rotate(12deg); } 40%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: none; } }
@keyframes pileBump { 0%, 100% { transform: none; } 40%, 80% { transform: translateY(-4px); } }
.mini-back.new, .opp-backs .mini-back { }
.opp-backs { display: flex; align-items: flex-end; }

/* 手札に加わったカード：山札から飛んできて表に返る */
.card.drawn { animation: drawIn .5s cubic-bezier(.2,.8,.3,1) backwards; animation-delay: var(--delay, 0s); }
@keyframes drawIn {
  0% { transform: translate(var(--dx), var(--dy)) scale(.7) rotateY(180deg); filter: brightness(.4); }
  55% { filter: brightness(.4); }
  60% { filter: brightness(1.4); }
  100% { transform: none; filter: none; }
}
.controls { display: flex; gap: 8px; margin: 6px 0 20px; flex-wrap: wrap; justify-content: center; }

.card {
  width: 104px; height: 160px; position: relative; cursor: pointer; user-select: none;
  background: var(--cbg, #333); color: #fff; padding: 4px; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 0 0 3px var(--line), inset 0 0 0 2px rgba(255,255,255,.25);
  transition: transform .12s;
}
.card:hover { transform: translateY(-4px); }
.card .cname { font-size: 15px; margin: 1px 0 3px; text-shadow: 1px 1px 0 var(--line); }
.card .cart { width: 96px; height: 96px; background: #000; box-shadow: 0 0 0 2px var(--line); }
.card .cart img { width: 96px; height: 96px; display: block; object-fit: cover; }
.card .ctext { font-size: 10px; line-height: 1.3; margin-top: 4px; text-align: left; width: 100%; color: #f4efe6; }
.card.selected { transform: translateY(-12px); box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--line); }
.card.marked { transform: translateY(-12px); box-shadow: 0 0 0 3px #ff6b6b, 0 0 0 6px var(--line); }
.card.marked::after { content: '捨てる'; position: absolute; top: 40%; left: 0; right: 0; text-align: center; background: #000a; color: #ff9c9c; font-size: 16px; }
.card.dead { filter: grayscale(.8) brightness(.6); }
.card.dead::before { content: '使用不可'; position: absolute; top: 4px; right: 4px; font-size: 10px; background: #000a; padding: 0 3px; z-index: 1; }
.card.rare { box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px var(--line); animation: shimmer 2s infinite; }
.card.rare.selected { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--line), 0 0 18px var(--gold); }
@keyframes shimmer { 50% { box-shadow: 0 0 0 3px #fff3b0, 0 0 0 6px var(--line), 0 0 12px var(--gold); } }
.card.back { background: #4b3d80; background-image: repeating-linear-gradient(45deg, #5a4a96 0 6px, #4b3d80 6px 12px); cursor: default; }
.card.back .cname { margin-top: 60px; }
.card.big { transform: scale(1.35); margin: 34px 24px 40px; cursor: default; animation: flip .5s ease-out both; }
.card.big:hover { transform: scale(1.35); }
@keyframes flip { 0% { transform: scale(1.35) rotateY(90deg); } 100% { transform: scale(1.35) rotateY(0); } }

.modal { position: fixed; inset: 0; background: rgba(10,8,20,.78); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); box-shadow: 0 0 0 3px var(--line), inset 0 0 0 3px var(--panel3); padding: 20px 24px; max-width: 640px; width: 100%; max-height: 92vh; overflow-y: auto; }
.modal-box h1 { margin: 0; text-align: center; color: var(--gold); font-size: 44px; letter-spacing: 6px; text-shadow: 4px 4px 0 var(--line); }
.modal-box h2 { margin-top: 0; color: var(--gold); }
.modal-box h3 { color: var(--gold); font-size: 15px; margin-bottom: 4px; }
.modal-box ul { padding-left: 20px; font-size: 14px; line-height: 1.7; }
.modal-box p { font-size: 14px; line-height: 1.7; }
.sub { text-align: center; color: var(--muted); }
.title-art { display: flex; justify-content: center; gap: 6px; margin: 10px 0; }
.title-art img { width: 64px; height: 64px; }
.form .row { display: flex; align-items: center; gap: 12px; margin: 8px 0; font-size: 15px; flex-wrap: wrap; }
.form .row > span { width: 120px; color: var(--muted); }
.form select { background: var(--panel2); color: var(--text); border: 0; box-shadow: 0 0 0 2px var(--line); padding: 3px 6px; font-size: 15px; }
.online-box { display: none; background: var(--panel2); padding: 10px 12px; margin: 8px 0; box-shadow: 0 0 0 2px var(--line); }
.online-box.show { display: block; }
.online-box input, .fb-box textarea { font-family: inherit; font-size: 15px; background: var(--panel); color: var(--text); border: 0; box-shadow: 0 0 0 2px var(--line); padding: 4px 8px; }
.online-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.online-actions .join { display: inline-flex; gap: 4px; align-items: center; }
.online-actions #join-code { width: 7em; text-transform: uppercase; letter-spacing: 3px; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.lobby-box { text-align: center; max-width: 440px; }
.lobby-box .code { font-size: 44px; letter-spacing: 10px; color: var(--gold); text-shadow: 3px 3px 0 var(--line); margin: 8px 0; }
.lobby-box .dots::after { content: '…'; animation: dots 1.2s steps(3) infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }
.fb-box { max-width: 520px; }
.fb-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; flex-wrap: wrap; }
.fb-row > span:first-child { width: 110px; color: var(--muted); }
.fb-row .choice { display: flex; flex-wrap: wrap; gap: 4px 12px; flex: 1; }
.stars button { background: none; border: 0; font-size: 28px; color: #4a4166; cursor: pointer; padding: 0 2px; }
.stars button.on { color: var(--gold); }
.fb-box textarea { width: 100%; height: 90px; resize: vertical; margin-top: 4px; }
.banner { background: #7d2420; color: #fff; padding: 4px 10px; font-size: 13px; margin: 4px 0; }
.sound-box { max-width: 420px; }
#sound-modal, #lobby-modal, #rules-modal, #fb-modal { z-index: 30; } /* タイトル画面の上にも出す（部屋コード・相手を探す画面はタイトルから開く） */
.snd-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.snd-name { width: 4em; }
.snd-toggle { min-width: 4.2em; margin: 0; }
.snd-toggle.on { background: #2f7a5a; }
.snd-row input[type=range] { flex: 1; accent-color: var(--gold); min-width: 0; }
.snd-row input[type=range]:disabled { opacity: .35; }
.snd-val { width: 3em; text-align: right; color: var(--muted); font-size: 13px; }
.sound-test { margin-top: 16px; padding-top: 10px; border-top: 2px solid var(--line); text-align: center; }
.sound-test .st-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.sound-test .px-btn.playing { background: #b8862a; color: #1b1426; }
.btn-row { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 6px; background: var(--panel2); padding: 4px 8px 4px 4px; }
.legend img { width: 32px; height: 32px; }

.reveal-box { text-align: center; max-width: 720px; }
.reveal-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.reveal-side { display: flex; flex-direction: column; align-items: center; min-width: 200px; }
.reveal-side .who { font-size: 18px; }
.reveal-side .desc { font-size: 15px; min-height: 22px; color: var(--accent); }
.reveal-side.o0 .who { color: #9cc2ff; } .reveal-side.o1 .who { color: #ffb0a6; }
.vs { font-size: 32px; color: var(--gold); text-shadow: 3px 3px 0 var(--line); }
.pass-box { text-align: center; max-width: 420px; }
.pass-box .big-name { font-size: 30px; margin: 16px 0; }
.over-box { text-align: center; }
.over-box .result { font-size: 34px; color: var(--gold); text-shadow: 3px 3px 0 var(--line); margin: 6px 0; }
table.stats { margin: 10px auto; border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 3px 10px; border-bottom: 2px solid var(--line); text-align: left; }
/* 捨て札の束（表向き）と、その一覧 */
.discard-pile {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 0;
  background: none; border: 0; color: inherit; font-family: inherit; cursor: pointer;
}
.discard-pile .dstack {
  width: 78px; height: 112px; background: var(--cbg); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--line), inset 0 0 0 2px rgba(255,255,255,.25), 3px 3px 0 #1f1838;
}
.discard-pile .dstack img { width: 64px; height: 64px; box-shadow: 0 0 0 2px var(--line); }
.discard-pile .dstack.empty { background: none; box-shadow: inset 0 0 0 2px #4b3d80; }
.discard-pile .count { font-size: 13px; color: var(--accent); text-decoration: underline; }
.discard-pile:hover .dstack { filter: brightness(1.15); }
.discard-pile.bump .dstack { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: translateY(-6px); } }
.discard-pile.mini { padding: 0 8px 0 0; align-self: center; gap: 2px; }
.discard-pile.mini .dstack { width: 40px; height: 58px; }
.discard-pile.mini .dstack img { width: 32px; height: 32px; }
.discard-pile.mini .count { font-size: 11px; }
.pile-sec { margin: 10px 0 14px; }
.pile-head { color: var(--gold); font-size: 15px; margin-bottom: 6px; }
.pile-head span { color: var(--muted); font-size: 13px; }
.pchips { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.pchip { display: flex; align-items: center; gap: 6px; background: var(--cbg); padding: 4px 8px 4px 4px; box-shadow: 0 0 0 2px var(--line); font-size: 14px; }
.pchip img { width: 32px; height: 32px; box-shadow: 0 0 0 1px var(--line); }
.pchip span { flex: 1; }
.pchip b { color: #fff; text-shadow: 1px 1px 0 var(--line); }
.pile-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ===== タイトル画面（ゲーム画面とは独立した全画面） ===== */
.title-screen {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(ellipse at 50% 30%, #2a2150 0%, #141024 70%);
}
.title-screen::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(#ffffff14 1px, transparent 1px); background-size: 8px 8px;
}
.title-screen.hidden { display: none; }
.title-inner { position: relative; width: min(520px, 100%); padding: 6vh 16px 24px; display: flex; flex-direction: column; align-items: center; flex: 1; }
.title-logo {
  font-size: clamp(44px, 13vw, 76px); letter-spacing: .12em; color: var(--gold); line-height: 1;
  text-shadow: 4px 4px 0 #b8862a, 8px 8px 0 var(--line);
  animation: logoIn .7s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes logoIn { from { transform: translateY(-30px) scale(.9); opacity: 0; } }
.title-screen .sub { font-size: 14px; line-height: 1.7; margin: 14px 0 6px; }
.title-screen .title-art { gap: 4px; margin: 6px 0 18px; }
.title-screen .title-art img { width: clamp(52px, 15vw, 72px); height: auto; box-shadow: 0 0 0 3px var(--line); animation: bob 1.6s ease-in-out infinite; }
.title-screen .title-art img:nth-child(2) { animation-delay: .2s; } .title-screen .title-art img:nth-child(3) { animation-delay: .4s; }
.title-screen .title-art img:nth-child(4) { animation-delay: .6s; } .title-screen .title-art img:nth-child(5) { animation-delay: .8s; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.menu { width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.menu.hidden { display: none; }
.menu-title { text-align: center; color: var(--gold); font-size: 22px; margin-bottom: 4px; }
.menu-btn { width: 100%; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.menu-btn small { font-size: 12px; opacity: .8; }
.menu-btn.hidden { display: none; }
.menu-small { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.menu > .px-btn:not(.menu-btn) { align-self: center; margin-top: 6px; }
.menu .name-row { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; }
.menu input, .fb-box textarea {
  font-family: inherit; font-size: 16px; background: var(--panel); color: var(--text); border: 0;
  box-shadow: 0 0 0 2px var(--line); padding: 6px 8px;
}
.menu .join { display: flex; gap: 6px; justify-content: center; align-items: center; }
.menu #join-code { width: 8em; text-transform: uppercase; letter-spacing: 4px; text-align: center; }
.menu .note { text-align: center; min-height: 1em; }
.menu .form { background: var(--panel); box-shadow: 0 0 0 3px var(--line); padding: 8px 14px 12px; }
.form-head { color: var(--gold); font-size: 14px; margin: 12px 0 2px; }
.menu .sound-test { margin-top: 6px; padding-top: 0; border: 0; text-align: left; }
.title-logo { margin: 0; font-weight: normal; }
.about { position: relative; width: min(520px, 100%); padding: 6px 16px 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.about h2 { font-size: 15px; color: var(--gold); margin: 10px 0 4px; font-weight: normal; }
.about p { margin: 0 0 6px; }
.about ul { margin: 0; padding-left: 18px; }
.about b { color: var(--text); font-weight: normal; }
.title-foot { position: relative; color: var(--muted); font-size: 11px; padding: 8px 0 14px; }

/* タップ操作：ダブルタップでの拡大を防ぐ */
button, canvas, .card, select, input { touch-action: manipulation; }

/* ===== スマホ向け ===== */
@media (max-width: 600px) {
  .topbar { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .logo { font-size: 16px; letter-spacing: 1px; }
  .logo span { display: none; }
  .round-info { font-size: 13px; }
  .top-buttons { display: flex; gap: 2px; overflow-x: auto; max-width: 100%; order: 3; width: 100%; padding-bottom: 2px; }
  .top-buttons .px-btn.small { font-size: 12px; padding: 3px 7px; flex: none; }
  .layout { padding: 6px 8px; gap: 10px; }

  .opp-hand { min-height: 46px; padding-top: 2px; }
  .mini-back { width: 28px; height: 40px; margin: 0 2px; }
  .mini-back::after { width: 8px; height: 8px; }
  .opp-hand.many .mini-back { margin: 0 -4px; }
  .opp-count { font-size: 16px; margin-left: 8px; }
  .deck-pile.mini .stack { width: 28px; height: 40px; }
  .deck-pile.mini::before, .deck-pile.mini::after { width: 28px; height: 40px; margin-left: -21px; }
  .deck-pile.mini .count { font-size: 10px; }

  .player-bar { margin: 5px 0; padding: 4px 8px; gap: 2px 8px; font-size: 12px; }
  .player-bar .pname { font-size: 14px; }
  .player-bar .hearts img { width: 16px; height: 14px; }
  .player-bar .info { font-size: 11px; }
  .board-frame { padding: 5px; }
  .board-wrap { width: min(calc(100vw - 30px), calc(100vh - 330px)); min-width: 240px; }
  .hint { font-size: 13px; min-height: 20px; margin: 4px 0 0; }
  .coach { padding: 8px; gap: 8px; }
  .coach img { width: 40px; height: 40px; }
  .coach-text { font-size: 13px; line-height: 1.5; }

  /* 手札は横にスクロール。山札は左に小さく */
  .hand-row { flex-direction: row; align-items: flex-start; gap: 6px; width: 100%; }
  .piles { gap: 4px; }
  .piles .deck-pile, .deck-pile { padding-top: 6px; gap: 1px; }
  .deck-pile .stack { width: 40px; height: 56px; }
  .deck-pile::before, .deck-pile::after { top: 6px; width: 40px; height: 56px; margin-left: -20px; }
  .deck-pile .stack::after { width: 10px; height: 10px; }
  .deck-pile .count { font-size: 10px; }
  .discard-pile, .piles .discard-pile { padding: 0; gap: 1px; }
  .discard-pile .dstack, .piles .discard-pile .dstack { width: 40px; height: 56px; }
  .discard-pile .dstack img, .piles .discard-pile .dstack img { width: 30px; height: 30px; }
  .discard-pile .count { font-size: 10px; }
  .discard-pile.mini .dstack { width: 28px; height: 40px; }
  .discard-pile.mini .dstack img { width: 22px; height: 22px; }
  .discard-pile.mini .count { font-size: 10px; }
  .pchips { grid-template-columns: repeat(2, 1fr); }
  .pchip { font-size: 13px; }
  .hand { flex-wrap: nowrap; justify-content: center; overflow: hidden; gap: 6px; min-height: 0; padding: 14px 3px 6px; flex: 1; min-width: 0; }
  .hand .card + .card { margin-left: var(--ov, 0px); }
  .card { width: 62px; height: 92px; flex: none; padding: 3px 2px; }
  .card .cname { font-size: 12px; margin: 0 0 3px; white-space: nowrap; align-self: flex-start; padding-left: 2px; }
  .card .cart, .card .cart img { width: 54px; height: 54px; }
  .card .ctext { display: none; } /* 説明は選んだときに案内欄へ */
  .hand .card.selected, .hand .card.marked { z-index: 2; }
  .card.selected, .card.marked { transform: translateY(-8px); }
  .card:hover { transform: none; }
  .card.selected:hover, .card.marked:hover { transform: translateY(-8px); }
  .card.dead::before { font-size: 8px; top: 18px; right: 2px; }
  .controls { margin: 4px 0 12px; gap: 4px; }
  .controls .px-btn { font-size: 15px; padding: 8px 14px; }

  .side-col { max-height: none; }
  .side-col h2 { cursor: pointer; margin: 0; }
  .side-col h2::after { content: ' ▼'; font-size: 11px; color: var(--muted); }
  .side-col.collapsed h2::after { content: ' ▶（タップで開く）'; }
  .side-col.collapsed #log, .side-col.collapsed #btn-copy-log { display: none; }
  #log { max-height: 220px; margin-top: 6px; }

  .modal { padding: 8px; }
  .modal-box { padding: 14px 12px; max-height: 94vh; }
  .reveal-row { flex-wrap: nowrap; gap: 2px; }
  .reveal-side { min-width: 0; flex: 1; }
  .reveal-side .who { font-size: 14px; }
  .reveal-side .desc { font-size: 12px; }
  .vs { font-size: 20px; }
  .card.big { transform: none; margin: 8px 0; width: 104px; height: 160px; animation: flipSmall .5s ease-out both; }
  .card.big .cart, .card.big .cart img { width: 96px; height: 96px; }
  .card.big .ctext { font-size: 10px; max-height: none; }
  .card.big:hover { transform: none; }
  @keyframes flipSmall { 0% { transform: rotateY(90deg); } 100% { transform: none; } }
  .over-box .result { font-size: 26px; }
  table.stats { font-size: 11px; }
  table.stats td, table.stats th { padding: 3px 4px; }
  .lobby-box .code { font-size: 36px; }
  .fb-row > span:first-child { width: 100%; }
  .form .row > span { width: 100px; }
  .px-btn.big { font-size: 18px; padding: 11px 16px; }
}
