/* =============================================================
   ARCANUM DUEL — 西洋ファンタジーRPG UI
   石壁・羊皮紙・金の縁取り
   ============================================================= */
:root {
  --stone-0: #0d0b08;
  --stone-1: #171209;
  --stone-2: #241c12;
  --stone-3: #33281a;
  --parch:   #f0e3c2;
  --parch-2: #dcc79b;
  --parch-d: #b8a274;
  --gold:    #c8a44d;
  --gold-l:  #efd28a;
  --gold-d:  #7d6224;
  --blood:   #8b2029;
  --blood-l: #cf4436;
  --arcane:  #4a7fbd;
  --emerald: #4c8a58;
  --text:    #ecdfc2;
  --muted:   #a2957a;

  --font-disp: "Cinzel", "Noto Serif JP", "Times New Roman", serif;
  --font-body: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-ui:   "Noto Serif JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background-color: var(--stone-0);
  background-image:
    var(--grain),
    radial-gradient(1100px 700px at 50% -12%, rgba(200,164,77,.10), transparent 60%),
    radial-gradient(900px 700px at 8% 110%, rgba(74,127,189,.09), transparent 60%),
    linear-gradient(180deg, #14100a, #0b0906);
  overflow: hidden;
  user-select: none;
}
button, input, select { font-family: inherit; color: inherit; }

#app { display: flex; flex-direction: column; height: 100dvh; }

.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -.12em; fill: currentColor; }

/* ---------------- ヘッダー ---------------- */
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px; flex: 0 0 auto; z-index: 20;
  background: linear-gradient(180deg, #241c12, #17110a);
  border-bottom: 1px solid var(--gold-d);
  box-shadow: 0 2px 0 rgba(0,0,0,.6), inset 0 -1px 0 rgba(200,164,77,.18);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-ico { font-size: 22px; color: var(--gold); filter: drop-shadow(0 0 6px rgba(200,164,77,.4)); }
.brand-text { font-family: var(--font-disp); font-size: 15px; letter-spacing: .16em; font-weight: 700; color: var(--gold-l); }
.brand-text em { font-style: normal; display: block; font-size: .62em; letter-spacing: .34em; color: var(--muted); }

.top-stats { display: flex; gap: 16px; margin-left: auto; align-items: center; font-size: 12px; color: var(--muted); }
.top-stats .ico { font-size: 15px; margin-right: 5px; color: var(--gold); }
.top-stats b { color: var(--text); font-family: var(--font-disp); font-size: 14px; }
.stat.conn { color: #7c5f4a; font-size: 11px; letter-spacing: .08em; }
.stat.conn.on { color: var(--emerald); }

.top-actions { display: flex; gap: 6px; align-items: center; }
.user-chip {
  display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 3px 9px 3px 3px;
  background: var(--stone-3); border: 1px solid var(--gold-d); border-radius: 20px; max-width: 150px;
}
.user-chip img { border-radius: 50%; display: block; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 30px; cursor: pointer; font-size: 15px; border-radius: 5px;
  background: linear-gradient(180deg, #3a2f1e, #221a10);
  border: 1px solid var(--gold-d); color: var(--parch-d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10);
  display: inline-flex; align-items: center; justify-content: center; transition: .14s;
}
.icon-btn:hover { color: var(--gold-l); border-color: var(--gold); }

/* ---------------- 画面 ---------------- */
#screens { position: relative; flex: 1 1 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 18px 16px 24px; display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  max-width: 980px; margin: 0 auto; position: relative; padding: 22px 24px;
  background: linear-gradient(180deg, #241c12, #171109);
  background-image: var(--grain), linear-gradient(180deg, #241c12, #171109);
  border: 1px solid var(--gold-d); border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(200,164,77,.16), inset 0 0 60px rgba(0,0,0,.55), 0 14px 44px rgba(0,0,0,.6);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--gold);
  opacity: .75; pointer-events: none;
}
.panel::before { top: 5px; left: 5px; border-right: 0; border-bottom: 0; }
.panel::after  { bottom: 5px; right: 5px; border-left: 0; border-top: 0; }

.panel-title {
  margin: 0 0 16px; font-family: var(--font-disp); font-size: 19px; font-weight: 700;
  letter-spacing: .1em; color: var(--gold-l); display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid rgba(200,164,77,.28);
  text-shadow: 0 2px 4px rgba(0,0,0,.7);
}
.panel-title.center { justify-content: center; border-bottom: 0; }
.panel-title .ico { font-size: 20px; color: var(--gold); }
.panel-title small { font-size: 11px; color: var(--muted); font-family: var(--font-ui); letter-spacing: .04em; margin-left: auto; }
.panel-title small b { color: var(--gold-l); }
.sub {
  font-family: var(--font-disp); font-size: 12px; color: var(--gold); margin: 22px 0 10px;
  letter-spacing: .24em; display: flex; align-items: center; gap: 10px;
}
.sub::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(200,164,77,.5), transparent); }
.panel-foot { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }
.panel-foot.center { justify-content: center; flex-wrap: wrap; }

/* ---------------- ボタン ---------------- */
.btn {
  padding: 10px 18px; cursor: pointer; border-radius: 5px; font-size: 13px; font-weight: 700;
  letter-spacing: .06em; font-family: var(--font-ui);
  background: linear-gradient(180deg, #40331f, #241a0e);
  border: 1px solid var(--gold-d); color: var(--parch);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 0 #0d0a05, 0 4px 10px rgba(0,0,0,.45);
  transition: transform .1s, box-shadow .1s, filter .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.16); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 #0d0a05; }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-l), #b48927);
  border-color: #f2dc9e; color: #2b2009; text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.btn-warn    { background: linear-gradient(180deg, #8b2029, #55131a); border-color: #b04a3f; }
.btn-emerald { background: linear-gradient(180deg, #4c8a58, #29512f); border-color: #6fae7a; width: 100%; }
.btn-ghost   { background: linear-gradient(180deg, #2a2117, #1b150d); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--parch); }

/* ---------------- タイトル ---------------- */
.title-wrap { max-width: 900px; margin: 0 auto; text-align: center; }
.crest {
  width: 62px; height: 62px; margin: 8px auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--gold-l);
  background: radial-gradient(circle at 50% 35%, #3a2d18, #1a1309);
  border: 2px solid var(--gold); box-shadow: 0 0 26px rgba(200,164,77,.28), inset 0 0 16px rgba(0,0,0,.7);
}
.game-title {
  font-family: var(--font-disp); font-size: clamp(30px, 7vw, 56px); margin: 0; font-weight: 700;
  letter-spacing: .14em; color: var(--gold-l);
  text-shadow: 0 2px 0 #6b5320, 0 4px 18px rgba(0,0,0,.8);
}
.game-title em { display: block; font-style: normal; font-family: var(--font-body); font-size: .24em; letter-spacing: .5em; color: var(--muted); margin-top: 10px; text-shadow: none; }
.tagline { color: var(--muted); font-size: 12.5px; margin: 16px auto 22px; max-width: 540px; line-height: 1.9; font-family: var(--font-body); }

.login-box {
  max-width: 420px; margin: 0 auto 24px; padding: 16px;
  background: rgba(20,15,9,.7); border: 1px solid var(--gold-d); border-radius: 6px;
}
#google-btn { display: flex; justify-content: center; min-height: 40px; }
.login-note { font-size: 10.5px; color: var(--muted); margin-top: 10px; line-height: 1.7; }
.name-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; font-size: 11px; color: var(--muted); }
.name-row input, .join-box input {
  background: #12100a; border: 1px solid var(--gold-d); color: var(--parch);
  padding: 8px 12px; border-radius: 4px; font-size: 14px; width: 180px; text-align: center;
  font-family: var(--font-body);
}
.name-row input:focus, .join-box input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200,164,77,.2); }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mode-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; text-align: left;
  background: linear-gradient(180deg, #2a2114, #1a130b);
  border: 1px solid var(--gold-d); border-radius: 6px; color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 4px 14px rgba(0,0,0,.5);
  transition: .16s; position: relative; overflow: hidden;
}
.mode-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.55), 0 0 0 1px rgba(200,164,77,.35); }
.mode-ico {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; color: var(--gold-l);
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #3d2f19, #171009); border: 1px solid var(--gold-d);
}
.mode-card:hover .mode-ico { color: #fff3d2; box-shadow: 0 0 16px rgba(200,164,77,.4); }
.mode-body { display: flex; flex-direction: column; gap: 3px; }
.mode-name { font-family: var(--font-disp); font-weight: 700; font-size: 15px; letter-spacing: .06em; color: var(--gold-l); }
.mode-desc { font-size: 10.5px; color: var(--muted); line-height: 1.6; }
.mini-note { font-size: 10.5px; color: var(--muted); margin-top: 22px; }

/* ---------------- ガチャ ---------------- */
.gacha-panel { max-width: 720px; text-align: center; }
.gacha-lead { font-size: 12.5px; color: var(--muted); line-height: 1.9; }
.r-epic { color: #e0b0ff; }
.chest { margin: 10px auto 6px; width: 190px; cursor: pointer; }
.chest-svg { width: 100%; filter: drop-shadow(0 8px 18px rgba(0,0,0,.65)); transition: transform .2s; }
.chest.shake .chest-svg { animation: chestShake .5s ease; }
@keyframes chestShake {
  0%,100% { transform: none; } 20% { transform: rotate(-5deg) scale(1.03); }
  45% { transform: rotate(5deg) scale(1.05); } 70% { transform: rotate(-3deg); }
}
.chest.open .chest-svg { animation: chestOpen .5s forwards; }
@keyframes chestOpen { to { transform: scale(1.1) translateY(-6px); filter: drop-shadow(0 0 30px rgba(200,164,77,.8)); } }
.gacha-results { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; min-height: 130px; margin: 18px 0; }
.gacha-results .card { animation: reveal .45s cubic-bezier(.2,1.4,.4,1) backwards; }
@keyframes reveal { from { transform: rotateY(90deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 冒険マップ ---------------- */
.map-track { display: flex; flex-direction: column-reverse; gap: 0; }
.map-row { display: flex; justify-content: center; gap: 14px; padding: 10px 0; position: relative; }
.map-row::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-1px);
  background: repeating-linear-gradient(180deg, rgba(200,164,77,.35) 0 6px, transparent 6px 12px);
}
.map-node {
  position: relative; z-index: 1; width: 84px; height: 74px; cursor: pointer; border-radius: 6px;
  background: linear-gradient(180deg, #2a2114, #16100a); border: 1px solid var(--gold-d); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10px; letter-spacing: .06em; transition: .15s;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.map-node .ico { font-size: 24px; color: var(--parch-d); }
.map-node.locked { opacity: .3; cursor: not-allowed; }
.map-node.done { opacity: .45; }
.map-node.done .ico { color: var(--emerald); }
.map-node.avail { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(200,164,77,.4), 0 0 24px rgba(200,164,77,.22); }
.map-node.avail .ico { color: var(--gold-l); }
.map-node.avail:hover { transform: translateY(-3px); background: linear-gradient(180deg, #3a2d19, #1d150c); }
.map-node.boss { width: 190px; border-color: var(--blood-l); }
.map-node.boss .ico { color: var(--blood-l); font-size: 30px; }
.map-info { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(200,164,77,.2); gap: 14px; flex-wrap: wrap; }
.map-hint { font-size: 11.5px; color: var(--muted); }

/* ---------------- 加護 ---------------- */
.relic-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.relic-chip {
  width: 32px; height: 32px; border-radius: 50%; cursor: help;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
  font-family: var(--font-body); color: #2a2009;
  background: radial-gradient(circle at 40% 30%, var(--gold-l), #9a7723);
  border: 1px solid #f0d894; box-shadow: 0 2px 6px rgba(0,0,0,.55);
}
.relic-strip.small .relic-chip { width: 22px; height: 22px; font-size: 10px; }
.relic-strip.big .relic-chip { width: 46px; height: 46px; font-size: 20px; }
.relic-chip.pulse { animation: relicPulse .55s ease; }
@keyframes relicPulse { 0%{transform:scale(1)} 40%{transform:scale(1.5); box-shadow:0 0 22px var(--gold-l)} 100%{transform:scale(1)} }

/* ---------------- 戦闘 ---------------- */
.battlefield { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; height: 100%; position: relative; }

.foes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.foe {
  flex: 1 1 160px; max-width: 260px; padding: 9px 11px; cursor: pointer; border-radius: 6px; position: relative;
  background: linear-gradient(180deg, #2a1a15, #170f0a);
  border: 1px solid #5c3a2a; transition: .15s;
}
.foe.targetable:hover { border-color: var(--blood-l); transform: translateY(-2px); }
.foe.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 20px rgba(200,164,77,.3); }
.foe.dead { opacity: .32; filter: grayscale(1); }
.foe.turn { border-color: var(--gold); }
.foe-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.foe-portrait {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 5px; font-size: 19px;
  display: flex; align-items: center; justify-content: center; color: var(--blood-l);
  background: radial-gradient(circle at 50% 30%, #3b241c, #150d09); border: 1px solid #5c3a2a;
}
.foe-name { font-family: var(--font-disp); font-weight: 700; letter-spacing: .04em; }
.foe-meta { font-size: 10px; color: var(--muted); margin-left: auto; text-align: right; line-height: 1.5; }
.foe.turn .foe-name { color: var(--gold-l); }
.foe .poison { color: #9be07a; }
.foe.hurt { animation: hurt .32s; }
@keyframes hurt { 0%,100%{transform:none} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.hpbar { position: relative; height: 14px; margin-top: 6px; border-radius: 7px; overflow: hidden;
  background: #170d0a; border: 1px solid rgba(200,164,77,.35); box-shadow: inset 0 2px 5px rgba(0,0,0,.7); }
.hpbar.big { height: 20px; border-radius: 10px; }
.hpfill { height: 100%; width: 100%; border-radius: 7px 0 0 7px;
  background: linear-gradient(180deg, #d9564a, #8b2029); transition: width .45s cubic-bezier(.2,.9,.2,1); }
.hpfill.mine { background: linear-gradient(180deg, #6fbe7f, #33703f); }
.hptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; font-family: var(--font-disp); text-shadow: 0 1px 3px #000; }

.arena { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 130px; }
.attack-board { display: flex; align-items: center; gap: 16px; min-height: 62px; }
.atk-attr {
  font-family: var(--font-disp); font-size: 12px; letter-spacing: .2em; padding: 8px 12px; border-radius: 4px;
  border: 1px solid var(--gold-d); color: var(--muted); min-width: 92px; text-align: center;
}
.atk-attr.on { color: #fff; border-color: currentColor; box-shadow: 0 0 18px currentColor; }
.atk-power { font-family: var(--font-disp); font-size: clamp(34px, 9vw, 62px); font-weight: 700; line-height: 1;
  color: var(--gold-l); text-shadow: 0 3px 0 #6b5320, 0 6px 22px rgba(0,0,0,.8); }
.atk-power small { display: block; font-size: 10px; letter-spacing: .4em; color: var(--muted); text-shadow: none; margin-top: 4px; }
.atk-steps { font-size: 11px; color: var(--muted); line-height: 1.8; min-width: 110px; }
.atk-steps b { color: var(--gold-l); }
.bump { animation: bump .2s ease; }
@keyframes bump { 0%{transform:scale(1)} 45%{transform:scale(1.28)} 100%{transform:scale(1)} }

.played-row { display: flex; gap: 8px; min-height: 78px; align-items: center; }
.battle-log { font-size: 11px; color: var(--muted); text-align: center; max-height: 40px; overflow: hidden; line-height: 1.8; }

.me { padding: 9px 12px; border-radius: 6px; background: linear-gradient(180deg, #1c2417, #10140c); border: 1px solid #3f5636; }
.me-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.me-name { font-family: var(--font-disp); font-weight: 700; letter-spacing: .06em; }
.me-turn { font-size: 10px; padding: 2px 9px; border-radius: 10px; background: #2b2416; color: var(--muted); border: 1px solid var(--gold-d); }
.me-turn.active { background: var(--gold); color: #241a06; border-color: var(--gold-l); animation: pip 1.3s ease-in-out infinite; }
@keyframes pip { 50% { box-shadow: 0 0 16px var(--gold); } }

/* ---------------- カード（羊皮紙） ---------------- */
.card {
  width: 84px; height: 116px; flex: 0 0 auto; position: relative; cursor: pointer; border-radius: 7px;
  padding: 5px 6px; display: flex; flex-direction: column; gap: 3px; color: #2b2114;
  background: linear-gradient(165deg, #f4e8ca 0%, #e2cfa4 62%, #cdb684 100%);
  border: 2px solid #6f5620;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), inset 0 -8px 18px rgba(120,95,45,.22), 0 5px 12px rgba(0,0,0,.6);
  transition: transform .15s cubic-bezier(.2,.9,.2,1), box-shadow .15s;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 14px 22px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.5); z-index: 5; }
.card.sel { transform: translateY(-12px); border-color: var(--gold-l); z-index: 6;
  box-shadow: 0 0 0 2px var(--gold-l), 0 0 22px rgba(232,200,122,.5), 0 14px 22px rgba(0,0,0,.6); }
.card.sel::after {
  content: attr(data-badge); position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--gold-l); color: #2b2009; font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 8px;
  white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.5); line-height: 1.4;
}
.card.dim { opacity: .4; filter: saturate(.5); }
.card-top { display: flex; align-items: center; gap: 5px; }
.rune {
  width: 20px; height: 20px; flex: 0 0 auto; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.4);
}
.card-kind { font-size: 8px; letter-spacing: .12em; color: #6b5a34; margin-left: auto; }
.card-name { font-family: var(--font-body); font-size: 11px; font-weight: 700; line-height: 1.25; }
.card-power { font-family: var(--font-disp); font-size: 21px; font-weight: 700; line-height: 1; color: #7a2419; }
.card-text { font-size: 8px; line-height: 1.35; color: #5e4e2e; margin-top: auto; }
.card-rarity { position: absolute; right: 4px; bottom: 3px; font-size: 8px; font-weight: 700; }
.card.rare  { border-color: #3f6fa8; }
.card.rare .card-rarity { color: #2c5c93; }
.card.epic  { border-color: #8b5cc7; box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), 0 0 18px rgba(139,92,199,.45), 0 5px 12px rgba(0,0,0,.6); }
.card.epic .card-rarity { color: #6c34ad; }
.card.mini { width: 66px; height: 92px; padding: 4px 5px; }
.card.mini .card-name { font-size: 9px; }
.card.mini .card-power { font-size: 16px; }
.card.mini .card-text { display: none; }
.card.tiny { width: 46px; height: 64px; padding: 3px; }
.card.tiny .card-name, .card.tiny .card-text, .card.tiny .card-kind { display: none; }
.card.scoring { animation: scorePop .34s ease; }
@keyframes scorePop { 0%{transform:translateY(0)} 45%{transform:translateY(-16px) scale(1.12)} 100%{transform:translateY(0)} }

/* ---------------- 手札 ---------------- */
/* 手札レーンは position:relative + z-index で他のUIより手前に置き、
   カードが持ち上がる分（最大12px＋バッジ9px）を padding で確保して切れないようにする */
.hand-zone {
  flex: 0 0 auto; position: relative; z-index: 12;
  border-top: 1px solid rgba(200,164,77,.2); padding-top: 2px;
  background: linear-gradient(180deg, rgba(13,11,8,0), rgba(13,11,8,.9) 26%);
}
.hand-rail {
  display: flex; gap: 8px; justify-content: center;
  padding: 30px 8px 10px;          /* ← 上の余白がカードの持ち上がりを吸収する */
  overflow-x: auto; overflow-y: hidden;
  min-height: 158px; scrollbar-width: thin;
}
.hand-rail::-webkit-scrollbar { height: 6px; }
.hand-rail::-webkit-scrollbar-thumb { background: rgba(200,164,77,.35); border-radius: 3px; }
.hand-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hand-tip { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 6px; }

/* ---------------- 防御ウィンドウ ---------------- */
.react-layer {
  position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(60,10,10,.72), rgba(6,4,3,.94));
  backdrop-filter: blur(3px); animation: fade .16s;
}
.react-box { text-align: center; padding: 20px; max-width: 660px; }
.react-title { font-family: var(--font-disp); font-size: 24px; letter-spacing: .18em; color: var(--blood-l);
  text-shadow: 0 0 22px rgba(207,68,54,.6); animation: alarm .8s ease-in-out infinite; }
@keyframes alarm { 50% { opacity: .55; } }
.react-attack { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; }
.react-attack b { font-family: var(--font-disp); font-size: 44px; color: #fff; text-shadow: 0 0 24px rgba(207,68,54,.8); }
.react-attack .rune { width: 34px; height: 34px; font-size: 15px; }
.react-note { font-size: 11px; color: var(--muted); }
.react-timer { height: 5px; background: #2a1a12; border-radius: 3px; overflow: hidden; margin: 6px auto 14px; max-width: 420px; }
.react-timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--blood-l), var(--gold-l)); }
.react-cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; min-height: 120px; }
.react-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card.blocks { box-shadow: 0 0 0 2px var(--emerald), 0 0 20px rgba(76,138,88,.6); }

/* ---------------- 商人 ---------------- */
.shop-body { display: grid; grid-template-columns: 1fr 230px; gap: 22px; }
.shop-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.shop-item { text-align: center; }
.shop-item .price { font-family: var(--font-disp); font-size: 12px; color: var(--gold-l); margin-top: 5px; }
.shop-item.sold { opacity: .25; pointer-events: none; }
.shop-item .buy { margin-top: 5px; padding: 4px 12px; font-size: 11px; }
.service-card {
  width: 158px; padding: 14px 12px; text-align: center; cursor: pointer; border-radius: 6px;
  background: linear-gradient(180deg, #2a2114, #16100a); border: 1px solid var(--gold-d); transition: .15s;
}
.service-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.service-card.sold { opacity: .25; pointer-events: none; }
.service-card .s-ico { font-size: 24px; color: var(--gold-l); }
.service-card .s-name { font-family: var(--font-disp); font-size: 13px; margin: 7px 0 4px; color: var(--gold-l); }
.service-card .s-desc { font-size: 10px; color: var(--muted); line-height: 1.5; }
.service-card .price { font-family: var(--font-disp); font-size: 12px; color: var(--gold-l); margin-top: 7px; }
.shop-side { display: flex; flex-direction: column; gap: 12px; }
.shop-note { font-size: 10px; color: var(--muted); line-height: 1.7; }

/* ---------------- 出来事 ---------------- */
.event-panel { max-width: 620px; text-align: center; }
.event-art { font-size: 48px; color: var(--gold-l); margin-bottom: 8px; }
.event-text { font-family: var(--font-body); font-size: 13px; color: var(--muted); line-height: 2.1; }
.event-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

/* ---------------- ロビー ---------------- */
.lobby-panel { max-width: 640px; }
.lobby-status { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.lobby-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.seat-select { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.seat-select select { background: #12100a; border: 1px solid var(--gold-d); color: var(--parch); padding: 7px 8px; border-radius: 4px; }
.join-box { display: flex; gap: 6px; }
.join-box input { width: 120px; text-transform: uppercase; letter-spacing: .3em; }
.room-view { margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(200,164,77,.2); }
.room-code { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.room-code b { font-family: var(--font-disp); font-size: 30px; color: var(--gold-l); letter-spacing: .3em; margin: 0 6px 0 10px; }
.room-players { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; }
.room-players li { background: #1d1710; border: 1px solid var(--gold-d); border-radius: 4px; padding: 9px 13px; font-size: 12.5px; display: flex; justify-content: space-between; }
.room-players .rd { color: var(--emerald); font-size: 11px; }
.lobby-deck { margin-top: 20px; }
.deck-summary, .deck-grid { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 実績 ---------------- */
.achv-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.achv-stats b { font-family: var(--font-disp); color: var(--gold-l); font-size: 16px; }
.achv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 12px; }
.achv {
  display: flex; gap: 11px; align-items: center; padding: 10px 12px; border-radius: 6px;
  background: linear-gradient(180deg, #211a10, #14100a); border: 1px solid #3a2f1c; opacity: .55;
}
.achv.got { opacity: 1; border-color: var(--gold); box-shadow: 0 0 0 1px rgba(200,164,77,.25); }
.achv-medal {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; font-family: var(--font-body);
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
  background: #2a2114; border: 1px solid #4a3c22; color: var(--muted);
}
.achv.got .achv-medal { background: radial-gradient(circle at 40% 30%, var(--gold-l), #96731f); color: #2a2009; border-color: #f0d894; }
.achv-name { font-family: var(--font-disp); font-size: 12.5px; color: var(--text); }
.achv.got .achv-name { color: var(--gold-l); }
.achv-desc { font-size: 10px; color: var(--muted); line-height: 1.5; }
.ranking { padding-left: 22px; font-size: 12px; color: var(--muted); line-height: 2; }
.ranking b { color: var(--gold-l); font-family: var(--font-disp); }

/* ---------------- オーバーレイ ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 200; padding: 16px; display: flex; align-items: center; justify-content: center;
  background: rgba(6,4,3,.9); backdrop-filter: blur(5px); animation: fade .2s;
}
.overlay-box {
  max-width: 560px; width: 100%; text-align: center; padding: 26px 24px; border-radius: 7px;
  background: linear-gradient(180deg, #241c12, #15100a);
  border: 1px solid var(--gold); position: relative;
  box-shadow: inset 0 0 0 1px rgba(200,164,77,.2), 0 20px 60px rgba(0,0,0,.75);
  max-height: 88dvh; overflow-y: auto;
}
.overlay-box h2 { font-family: var(--font-disp); margin: 0 0 12px; font-size: 27px; letter-spacing: .12em; color: var(--gold-l); }
.overlay-box .win { color: var(--gold-l); text-shadow: 0 0 26px rgba(200,164,77,.6); }
.overlay-box .lose { color: var(--blood-l); }
.overlay-box p { font-size: 12.5px; color: var(--muted); line-height: 2; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.reward-row { display: flex; gap: 12px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.help-list { text-align: left; font-size: 12px; line-height: 2.05; color: var(--muted); }
.help-list b { color: var(--gold-l); }
.attr-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 14px; text-align: left; }
.attr-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.unlock-row { display: flex; gap: 10px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }

/* ---------------- 広告 ---------------- */
.ad-slot {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #191309, #100c07);
  border-top: 1px solid rgba(200,164,77,.22); border-bottom: 1px solid rgba(200,164,77,.22);
  color: #5f5540; font-size: 10px; letter-spacing: .2em;
}
.ad-slot::after {
  content: "PR"; position: absolute; top: 2px; left: 6px; font-size: 8px; color: #6d6046; letter-spacing: .1em;
}
.ad-leaderboard { min-height: 66px; }
.ad-banner { min-height: 58px; margin-top: 14px; border-radius: 4px; border: 1px solid rgba(200,164,77,.22); }
.ad-rect { min-height: 250px; width: 100%; border-radius: 4px; border: 1px solid rgba(200,164,77,.22); }
.ad-slot.hidden { display: none; }
@media (max-width: 720px) { .ad-leaderboard { min-height: 52px; } }

/* ---------------- 演出 ---------------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.fx-num { position: absolute; font-family: var(--font-disp); font-weight: 700; font-size: 34px; white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0,0,0,.6), 0 0 22px currentColor; animation: fxUp 1s cubic-bezier(.2,.8,.3,1) forwards; }
@keyframes fxUp {
  0% { transform: translate(-50%,0) scale(.5); opacity: 0; }
  18% { transform: translate(-50%,-16px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%,-86px) scale(1); opacity: 0; }
}
.fx-pop { position: absolute; font-family: var(--font-disp); font-weight: 700; font-size: 15px; animation: fxUp .85s forwards; }
.fx-particle { position: absolute; width: 6px; height: 6px; border-radius: 50%; animation: fxPart .85s ease-out forwards; }
@keyframes fxPart { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }
.fx-flash { position: absolute; inset: 0; background: #ffe9b8; opacity: 0; animation: flash .28s ease-out; }
@keyframes flash { 0%{opacity:.5} 100%{opacity:0} }
.shake-s { animation: shk .26s; } .shake-m { animation: shk .4s; } .shake-l { animation: shk .58s; }
@keyframes shk {
  0%,100% { transform: none; } 12% { transform: translate(-7px,4px) rotate(-.4deg); }
  30% { transform: translate(8px,-6px) rotate(.5deg); } 50% { transform: translate(-10px,3px) rotate(-.6deg); }
  70% { transform: translate(6px,6px) rotate(.4deg); } 88% { transform: translate(-3px,-2px); }
}
#toast-layer { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 18px; font-size: 12px; border-radius: 4px; animation: toastIn .28s ease;
  background: linear-gradient(180deg, #2a2114, #16100a); border: 1px solid var(--gold-d);
  box-shadow: 0 6px 18px rgba(0,0,0,.6);
}
.toast.bad { border-color: var(--blood-l); color: #ffc9bd; }
.toast.good { border-color: var(--emerald); color: #c6ebc9; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

/* ---------------- SEO用の説明セクション ---------------- */
.about {
  max-width: 720px; margin: 44px auto 0; padding: 26px 24px; text-align: left;
  background: linear-gradient(180deg, rgba(36,28,18,.85), rgba(19,14,9,.85));
  border: 1px solid rgba(200,164,77,.28); border-radius: 6px;
  font-family: var(--font-body); color: var(--muted); font-size: 13px; line-height: 2;
  user-select: text;
}
.about h2 {
  font-family: var(--font-disp); font-size: 15px; color: var(--gold-l); letter-spacing: .08em;
  margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(200,164,77,.2);
}
.about h2:first-child { margin-top: 0; }
.about p { margin: 0 0 12px; }
.about ol, .about ul { margin: 0; padding-left: 1.4em; }
.about li { margin-bottom: 8px; }
.about b { color: var(--text); }
.about dt { color: var(--gold-l); font-weight: 700; margin-top: 12px; }
.about dd { margin: 0 0 4px; padding-left: 1em; }

/* ---------------- レスポンシブ ---------------- */
@media (max-width: 820px) {
  .shop-body { grid-template-columns: 1fr; }
  .card { width: 70px; height: 100px; }
  .card-name { font-size: 10px; }
  .card-power { font-size: 18px; }
  .hand-rail { justify-content: flex-start; min-height: 120px; }
  .screen { padding: 12px 10px 20px; }
  .panel { padding: 16px 14px; }
  .brand-text em { display: none; }
  .btn { padding: 9px 13px; font-size: 12px; }
  .attack-board { flex-direction: column; gap: 6px; }
  .atk-steps { display: none; }
  .foes { gap: 8px; }
  .foe { flex: 1 1 130px; padding: 7px 9px; }
}
@media (max-height: 660px) {
  .ad-leaderboard { display: none; }
  .card { height: 96px; }
  .hand-rail { min-height: 132px; padding-top: 24px; }
}

/* ==================== スマートフォン対応 ==================== */

/* ノッチ / ホームバーを避ける */
#topbar { padding-top: calc(8px + env(safe-area-inset-top)); }
#app > .ad-slot:last-child { padding-bottom: env(safe-area-inset-bottom); }
.screen { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }

/* タップの取りこぼし・二重タップ拡大を防ぐ */
button, .card, .map-node, .foe, .mode-card, .service-card, .relic-chip { touch-action: manipulation; }

/* タッチ端末では hover の浮き上がりを無効化し、押した瞬間の反応に置き換える */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), 0 5px 12px rgba(0,0,0,.6); }
  .card:active { transform: translateY(-6px) scale(1.03); }
  .card.sel { transform: translateY(-14px); }
  .mode-card:hover, .map-node.avail:hover, .service-card:hover, .foe.targetable:hover { transform: none; }
  .btn:hover:not(:disabled) { transform: none; filter: none; }
  .btn:active:not(:disabled) { filter: brightness(1.2); }
}

@media (max-width: 560px) {
  #topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .brand-text { font-size: 12px; letter-spacing: .1em; }
  .top-stats { gap: 10px; font-size: 11px; }
  .user-chip { max-width: 92px; font-size: 10px; }

  /* 手札は横スクロール + スナップ、指で掴みやすいサイズを維持 */
  .hand-rail {
    justify-content: flex-start; gap: 6px; padding: 26px 10px 10px;
    min-height: 134px;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  }
  .hand-rail .card { scroll-snap-align: center; }
  .card { width: 66px; height: 94px; }
  .card-name { font-size: 9.5px; }
  .card-power { font-size: 17px; }
  .card .rune { width: 18px; height: 18px; font-size: 9px; }

  /* ボタンは指のサイズを確保 */
  .btn { min-height: 44px; padding: 10px 14px; }
  .hand-actions { gap: 6px; }
  .hand-actions .btn { flex: 1 1 auto; min-width: 96px; }
  #btn-pray { font-size: 11px; }

  /* 相手パネルは2列まで */
  .foes { gap: 6px; }
  .foe { flex: 1 1 calc(50% - 6px); max-width: none; padding: 6px 8px; }
  .foe-portrait { width: 28px; height: 28px; font-size: 16px; }
  .foe-name { font-size: 11px; }
  .foe-meta { font-size: 9px; }

  .atk-power { font-size: 40px; }
  .played-row { min-height: 62px; }
  .played-row .card.mini { width: 54px; height: 76px; }

  .game-title { font-size: 30px; letter-spacing: .08em; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { padding: 12px 13px; }
  .about { padding: 18px 15px; font-size: 12.5px; line-height: 1.95; margin-top: 30px; }

  .react-box { padding: 14px 10px; }
  .react-title { font-size: 19px; letter-spacing: .12em; }
  .react-attack b { font-size: 34px; }
  .react-cards { gap: 6px; min-height: 100px; }
  .react-actions .btn { flex: 1 1 auto; }

  .service-card { width: calc(50% - 6px); }
  .overlay-box { padding: 18px 14px; }
  .overlay-box h2 { font-size: 21px; }
  .achv-grid { grid-template-columns: 1fr; }
}

/* 横向きの低い画面 */
@media (max-height: 480px) and (orientation: landscape) {
  .ad-leaderboard, .ad-banner { display: none; }
  .hand-rail { min-height: 112px; padding-top: 22px; }
  .card { width: 58px; height: 82px; }
  .arena { min-height: 80px; }
  .atk-power { font-size: 30px; }
}
