/* 要穴カルタ — 和風 × モダン */
:root {
  --ai: #172238;        /* 藍 */
  --ai-2: #22304d;
  --ai-3: #2c3d60;
  --washi: #f6f1e4;     /* 生成り */
  --washi-2: #ece4d0;
  --sumi: #1b1b1b;      /* 墨 */
  --sumi-2: #4a4339;
  --shu: #c0392b;       /* 朱 */
  --kin: #c9a55a;       /* 金 */
  --matsu: #2f7d4f;
  --line: rgba(27, 27, 27, 0.14);
  --mincho: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Noto Serif JP", "Source Han Serif JP", serif;
  --gothic: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--gothic);
  color: #f3ecdc;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(201, 165, 90, 0.10), transparent 55%),
    radial-gradient(ellipse at 110% 120%, rgba(192, 57, 43, 0.10), transparent 50%),
    var(--ai);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
html.lock, body.lock { overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; width: 100%; touch-action: none; }
button, input, select { font: inherit; }
a { color: var(--kin); }
.hidden { display: none !important; }
.screen { min-height: 100%; }

/* ---------- 汎用パーツ ---------- */
.brand { font-family: var(--mincho); font-weight: 700; letter-spacing: 0.12em; }
.brand .seal {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-right: 0.4em;
  background: var(--shu); color: #fff; border-radius: 4px; font-size: 0.8em; letter-spacing: 0; vertical-align: 0.1em;
}
.panel {
  background: var(--washi); color: var(--sumi); border-radius: 14px; padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.panel h2, .panel h3 { font-family: var(--mincho); margin: 0 0 10px; letter-spacing: 0.06em; }
.panel h3 { font-size: 15px; color: var(--sumi-2); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 18px; }
.panel h3:first-child { margin-top: 0; }
.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 12px 18px; cursor: pointer;
  background: var(--sumi); color: #fff; font-weight: 700; letter-spacing: 0.05em;
  touch-action: manipulation; min-height: 44px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.shu { background: var(--shu); }
.btn.kin { background: var(--kin); color: var(--sumi); }
.btn.ghost { background: transparent; color: inherit; border: 1.5px solid currentColor; }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn.big { font-size: 20px; padding: 16px 28px; width: 100%; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; color: var(--sumi-2); margin-bottom: 4px; }
.input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1.5px solid #cbbf9f; background: #fffdf7; color: var(--sumi);
  font-size: 18px;
}
.input:focus { outline: 3px solid rgba(192, 57, 43, 0.3); border-color: var(--shu); }
.muted { color: #8b8270; font-size: 13px; }
.err { color: var(--shu); font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: rgba(0, 0, 0, 0.06); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.seg { display: inline-flex; border: 1.5px solid var(--sumi); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 12px; font-size: 14px; cursor: pointer; }
.seg input:checked + span { background: var(--sumi); color: #fff; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 参加画面 ---------- */
.center-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.join-card { width: min(420px, 100%); }
.join-card .title { text-align: center; margin: 4px 0 18px; font-size: 28px; }
.join-card .sub { text-align: center; color: var(--sumi-2); font-size: 13px; margin-top: -10px; margin-bottom: 14px; }
.codeinput { font-size: 30px; letter-spacing: 0.4em; text-align: center; font-family: ui-monospace, Menlo, monospace; }

/* ---------- ロビー ---------- */
.lobby { max-width: 760px; margin: 0 auto; padding: 16px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.roomcode { font-family: ui-monospace, Menlo, monospace; font-size: 22px; letter-spacing: 0.15em; }
.plist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fffdf7; border-radius: 8px; border: 1px solid var(--line); }
.plist .nm { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .st { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #e9e1cc; color: var(--sumi-2); }
.plist .st.ok { background: var(--matsu); color: #fff; }
.plist .st.off { background: #999; color: #fff; }
.plist .me { outline: 2px solid var(--shu); }
.plist .rtt { font-size: 11px; color: #8b8270; font-variant-numeric: tabular-nums; }
.summary { font-size: 14px; line-height: 1.8; }
.summary b { font-family: var(--mincho); }

/* ---------- 対戦画面 ---------- */
.game { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hud {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-height: 44px;
  padding-top: max(6px, env(safe-area-inset-top)); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right));
  background: rgba(0, 0, 0, 0.28); border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.hud .remain { font-family: var(--mincho); font-size: 14px; white-space: nowrap; }
.hud .remain b { font-size: 20px; color: var(--kin); margin: 0 2px; font-variant-numeric: tabular-nums; }
.hud .wave { width: 90px; height: 26px; flex: none; }
.hud .scores { flex: 1; display: flex; gap: 6px; overflow: hidden; min-width: 0; justify-content: flex-start; }
.hud .sc { display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 13px; white-space: nowrap; max-width: 9em; min-width: 0; flex: 0 1 auto; }
.hud .sc .n { overflow: hidden; text-overflow: ellipsis; min-width: 1.5em; }
.hud .sc b, .hud .sc .dot { flex: none; }
@media (max-width: 480px) { .hud { gap: 6px; padding-left: 8px; padding-right: 8px; } .hud .wave { width: 48px; } .hud .sc { max-width: 6.5em; padding: 2px 6px; } }
.hud .sc b { font-variant-numeric: tabular-nums; font-size: 15px; }
.hud .sc.me { background: rgba(255, 255, 255, 0.18); outline: 1.5px solid var(--kin); }
.hud .net { font-size: 11px; color: #a9b3c7; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud .net.bad { color: #ff9b8a; }
.board-wrap { flex: 1; position: relative; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); min-height: 0; }
.board-felt {
  position: absolute; inset: 6px; border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #2d4a3a, #24402f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 10px 40px rgba(0, 0, 0, 0.35);
}
.board {
  position: absolute; inset: 52px 14px 14px; display: grid; gap: var(--gap, 6px);
  justify-content: center; align-content: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* 取り札 */
.card {
  --pc: #888;
  width: var(--cw); height: var(--ch); position: relative; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(170deg, #fffbf1 0%, #f6eedb 60%, #efe4ca 100%);
  border: 1px solid #cdbd98; border-radius: calc(var(--cw) * 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 2px 0 #bfae86, 0 4px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer; transition: transform 0.08s ease, opacity 0.4s ease;
  touch-action: none;
}
.card::before {
  content: ""; position: absolute; inset: 7%; border: 1px solid rgba(120, 90, 40, 0.28); border-radius: calc(var(--cw) * 0.04); pointer-events: none;
}
.card .nm {
  writing-mode: vertical-rl; text-orientation: upright; font-family: var(--mincho); font-weight: 800;
  font-size: var(--fs); line-height: 1; letter-spacing: 0.04em; color: #111; pointer-events: none;
}
.card .kn {
  position: absolute; right: 10%; top: 9%; writing-mode: vertical-rl; font-size: calc(var(--fs) * 0.3); color: #7a5b2e; letter-spacing: 0; line-height: 1; pointer-events: none;
}
.card .kn + .nm { margin-left: calc(var(--fs) * 0.25); }
.card.press { transform: scale(0.95); }
.card.taken { opacity: 0.22; cursor: default; box-shadow: none; transform: none; }
.card.taken::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--pc); opacity: 0.55; mix-blend-mode: multiply;
}
.card.taken.none { opacity: 0.16; filter: grayscale(1); }
.card.hit { z-index: 2; animation: hit 0.9s ease-out forwards; }
.card.hit::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 4px solid var(--pc); box-shadow: 0 0 22px var(--pc); }
@keyframes hit { 0% { transform: scale(1); } 18% { transform: scale(1.14); } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 0.4; } }
.card.wrong { animation: shake 0.5s; outline: 3px solid var(--shu); outline-offset: 1px; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.board.locked .card:not(.taken) { filter: grayscale(0.6) brightness(0.85); }

/* 盤面上のメッセージ（タップを邪魔しない） */
.banner {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  background: rgba(15, 20, 32, 0.86); border: 1px solid rgba(201, 165, 90, 0.5); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: 15px; white-space: nowrap; max-width: 94%; overflow: hidden; text-overflow: ellipsis;
}
.banner b { color: var(--kin); font-variant-numeric: tabular-nums; }
.bigcount {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 6;
  font-family: var(--mincho); font-size: min(30vw, 30vh); font-weight: 800; color: rgba(255, 255, 255, 0.92); text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
}
.bigcount.pop { animation: pop 0.9s ease-out; }
@keyframes pop { 0% { transform: scale(1.4); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { opacity: 0.1; } }
.toast {
  position: absolute; left: 50%; top: 8px; transform: translate(-50%, -12px); opacity: 0; transition: all 0.2s ease; z-index: 7; pointer-events: none;
  background: var(--washi); color: var(--sumi); padding: 8px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 94%; text-align: center; font-size: 15px; line-height: 1.35;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--shu); color: #fff; }
.toast.good { background: var(--kin); color: var(--sumi); }
.toast .exp { display: block; font-weight: 400; font-size: 13px; color: var(--sumi-2); font-family: var(--mincho); }
.rotate-hint { font-size: 11px; color: var(--kin); white-space: nowrap; }

/* ---------- 結果 ---------- */
.results { max-width: 900px; margin: 0 auto; padding: 16px; }
.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank-table th, .rank-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.rank-table th { font-size: 12px; color: var(--sumi-2); font-weight: 600; }
.rank-table td.l, .rank-table th.l { text-align: left; }
.rank-table .rk { font-family: var(--mincho); font-weight: 800; font-size: 18px; text-align: center; }
.rank-table tr.me { background: rgba(192, 57, 43, 0.08); }
.table-scroll { overflow-x: auto; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: #fffdf7; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stat .v { font-family: var(--mincho); font-size: 24px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--sumi-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mincho); font-weight: 700; background: #fffdf7; border: 1px solid #cdbd98; padding: 4px 10px; border-radius: 6px; }
.tag small { font-family: var(--gothic); font-weight: 400; color: #8b8270; margin-left: 4px; }
.winner-title { text-align: center; font-family: var(--mincho); font-size: 26px; margin: 6px 0 14px; }

/* ---------- ホスト ---------- */
.host-lobby { display: grid; grid-template-columns: 340px 1fr; gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto; padding-bottom: 110px; }
@media (max-width: 860px) { .host-lobby { grid-template-columns: 1fr; } }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: 100%; max-width: 260px; aspect-ratio: 1; display: block; margin: 0 auto; }
.joinurl { font-family: ui-monospace, Menlo, monospace; font-size: 14px; word-break: break-all; text-align: center; margin: 8px 0; }
.bigcode { text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: 40px; letter-spacing: 0.2em; font-weight: 700; }
.mer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.mer { background: #fffdf7; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.mer-head { display: flex; align-items: center; gap: 8px; }
.mer-head label { flex: 1; display: flex; align-items: center; gap: 6px; font-family: var(--mincho); font-weight: 700; cursor: pointer; }
.mer-head .cnt { font-size: 12px; color: #8b8270; font-variant-numeric: tabular-nums; }
.mer-head .yy { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #e9e1cc; color: var(--sumi-2); font-family: var(--gothic); font-weight: 400; }
.mer-points { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mer-points label { font-size: 13px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 6px; background: #f3ecd9; cursor: pointer; }
.mer-points label.off { opacity: 0.45; text-decoration: line-through; }
.mer-points small { color: #8b8270; }
.bulk { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.poolcount { font-family: var(--mincho); font-size: 18px; }
.poolcount b { font-size: 28px; color: var(--shu); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.num { width: 80px; padding: 6px 8px; border-radius: 8px; border: 1.5px solid #cbbf9f; background: #fffdf7; color: var(--sumi); }
.startbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(15, 20, 32, 0.95); border-top: 1px solid rgba(201, 165, 90, 0.4);
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
}
.startbar .msg { flex: 1; min-width: 200px; font-size: 14px; }
.startbar .msg.err { color: #ff9b8a; }
.host-game .hud .info { font-size: 14px; white-space: nowrap; }
.host-game .hud .wave { width: 200px; height: 34px; }
.host-game-body { flex: 1; display: flex; min-height: 0; }
.host-game-body .board-wrap { flex: 1; }
.side {
  width: 250px; flex: none; padding: 10px; overflow-y: auto; background: rgba(0, 0, 0, 0.2);
}
.side .pl { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); margin-bottom: 6px; }
.side .pl .n { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .pl .s { font-family: var(--mincho); font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.side .pl .sub { font-size: 11px; color: #a9b3c7; }
.side .pl.off { opacity: 0.5; }
.side .last { margin-top: 12px; padding: 10px; border-radius: 10px; background: var(--washi); color: var(--sumi); }
.side .last .q { font-family: var(--mincho); font-size: 14px; }
.side .last .a { font-family: var(--mincho); font-size: 26px; font-weight: 800; }
@media (max-width: 760px) { .side { display: none; } }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); white-space: nowrap; }
.status-pill.warn { background: var(--shu); color: #fff; }
.progress { height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--kin); width: 0; transition: width 0.2s; }

/* ---------- 管理画面 ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 16px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin th { text-align: left; font-size: 12px; color: var(--sumi-2); position: sticky; top: 0; background: var(--washi); }
.admin td .input { font-size: 14px; padding: 6px 8px; }
.admin tr.stale td { background: rgba(192, 57, 43, 0.08); }
.admin tr.playing td { background: rgba(201, 165, 90, 0.25); }
.admin .nm { font-family: var(--mincho); font-weight: 800; font-size: 18px; }
.admin .mer-sep td { background: var(--washi-2); font-family: var(--mincho); font-weight: 700; }

/* ホスト画面をスマホで使う場合（ホスト兼プレイヤー） */
.host-game .hud .scores { display: none; }
@media (max-width: 760px) {
  .host-game .hud .info, .host-game .hud .qn, .host-game #gStatus, .host-game .hud .spacer { display: none; }
  .host-game .hud .scores { display: flex; flex: 1; min-width: 0; }
  .host-game .hud .sc .n { max-width: 3.5em; }
  .host-game .hud .wave { display: none; }
  .host-game .hud .remain { font-size: 12px; }
  .host-game .hud .btn.small { padding: 4px 8px; font-size: 12px; min-height: 30px; }
  .host-lobby { padding: 10px; }
  .startbar { gap: 8px; }
  .startbar .msg { font-size: 12px; min-width: 0; }
  .startbar .btn { white-space: nowrap; padding: 12px 16px !important; font-size: 16px !important; }
}
.plist .host-badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--kin); color: var(--sumi); }

/* =========================================================
   スマホ縦画面専用アプリ
   ========================================================= */
:root { --app-w: 480px; }
body { overscroll-behavior-y: none; }
.screen { max-width: var(--app-w); margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.game { left: max(0px, calc(50% - var(--app-w) / 2)); right: max(0px, calc(50% - var(--app-w) / 2)); }
.startbar { left: max(0px, calc(50% - var(--app-w) / 2)); right: max(0px, calc(50% - var(--app-w) / 2)); }
.startbar .msg { font-size: 12px; min-width: 0; }
.startbar .btn { white-space: nowrap; font-size: 17px; padding: 13px 20px; }
@media (min-width: 520px) {
  body { background-attachment: fixed; }
  .screen, .game { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 0 60px rgba(0, 0, 0, 0.35); }
}
.page { padding: 12px 12px 24px; display: grid; gap: 12px; }
.host-page { padding-bottom: 120px; }
.stack { display: grid; gap: 10px; }
.stack .btn { width: 100%; }
.mer-list { grid-template-columns: 1fr; }
.side { display: none !important; }
.host-game .hud .scores { display: flex; flex: 1; min-width: 0; }
.host-game .hud .wave { display: none; }

/* 上部のアプリバー */
.appbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; min-height: 52px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(23, 34, 56, 0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(201, 165, 90, 0.25); font-family: var(--mincho); font-weight: 700; letter-spacing: 0.08em;
}
.appbar .right { margin-left: auto; font-family: var(--gothic); letter-spacing: 0; }
.appbar .back { appearance: none; border: 0; background: none; color: var(--kin); font: inherit; font-size: 16px; padding: 6px 4px; cursor: pointer; letter-spacing: 0; }

/* タイトル（ホーム） */
.home { display: flex; flex-direction: column; padding: 0 20px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.home-top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: max(40px, env(safe-area-inset-top)); min-height: 320px; }
.home-seal {
  width: 88px; height: 88px; display: grid; place-items: center; border-radius: 14px; background: var(--shu); color: #fff;
  font-family: var(--mincho); font-size: 54px; font-weight: 800; box-shadow: 0 10px 30px rgba(192, 57, 43, 0.4), inset 0 0 0 3px rgba(255, 255, 255, 0.25);
  transform: rotate(-4deg); margin-bottom: 22px;
}
.home-title { font-family: var(--mincho); font-weight: 800; font-size: clamp(40px, 13vw, 56px); letter-spacing: 0.14em; margin: 0; line-height: 1.1; text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); }
.home-sub { font-family: var(--mincho); color: var(--kin); font-size: 18px; letter-spacing: 0.4em; margin: 10px 0 0; padding-left: 0.4em; }
.home-lead { color: #a9b3c7; font-size: 13px; margin-top: 18px; letter-spacing: 0.1em; }
.home-menu { display: grid; gap: 12px; padding-bottom: 8px; }
.home-hello { text-align: center; margin: 0; color: #d9d2c0; }
.home-invite { text-align: center; margin: 0; background: rgba(201, 165, 90, 0.15); border: 1px solid rgba(201, 165, 90, 0.5); border-radius: 10px; padding: 8px; }
.home-btn { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; text-align: left; align-items: center; padding: 16px 20px; font-size: 21px; border-radius: 14px; }
.home-btn .ic { grid-row: span 2; font-size: 30px; }
.home-btn small { font-size: 12px; font-weight: 400; opacity: 0.8; letter-spacing: 0; }
.home-btn:not(.shu) { background: var(--washi); color: var(--sumi); }
.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-links .btn { color: #e8e0cc; border-color: rgba(255, 255, 255, 0.3); font-weight: 600; }

/* 対戦成績 */
.hist-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.hist-row .rk { font-family: var(--mincho); font-weight: 800; font-size: 26px; width: 2.4em; text-align: center; }
.hist-row .rk small { font-size: 12px; }
.hist-row .mid { flex: 1; min-width: 0; font-size: 14px; }

/* 横向きでは「縦にしてください」
   ※ CSS の orientation は「表示領域の縦横」で判定するため、キーボードが出ただけで横向き扱いになる。
     そのため端末そのものの向きを JS（common.js）で判定し、html に .is-landscape を付ける。 */
.rotate-lock { display: none; }
html.is-landscape .rotate-lock {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 1000; background: var(--ai);
  text-align: center; font-family: var(--mincho); font-size: 20px; line-height: 1.8;
}

/* レベル */
.lv { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: #2c3d60; color: var(--kin); font-family: var(--gothic); letter-spacing: 0; vertical-align: 1px; }
.panel .lv { background: var(--sumi); }
.growth { background: #fffdf7; border: 1.5px solid var(--kin); border-radius: 12px; padding: 12px; margin: 8px 0 12px; display: grid; gap: 6px; }
.growth .plus { color: var(--matsu); }
.growth .minus { color: var(--shu); }
.lvup { text-align: center; font-family: var(--mincho); font-weight: 800; font-size: 20px; color: var(--shu); animation: pop 1s ease-out; }
.lvdown { text-align: center; font-family: var(--mincho); font-weight: 700; color: #6b6355; }
.expbar { height: 10px; border-radius: 5px; background: #e6dcc4; overflow: hidden; }
.expbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--kin), var(--shu)); }
.home-level { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(201, 165, 90, 0.35); border-radius: 14px; padding: 12px 14px; display: grid; gap: 6px; }
.home-level .top { display: flex; align-items: baseline; gap: 10px; }
.home-level .big { font-family: var(--mincho); font-weight: 800; font-size: 30px; color: var(--kin); }
.home-level .ttl { font-family: var(--mincho); font-weight: 700; font-size: 16px; }
.home-level .rt { margin-left: auto; font-size: 13px; color: #a9b3c7; }
.home-level .expbar { background: rgba(255, 255, 255, 0.12); height: 8px; }
.home-level .nx { font-size: 11px; color: #a9b3c7; text-align: right; }
.teacher-link { background: none; border: 0; color: #8b8270; font-size: 12px; text-decoration: underline; cursor: pointer; padding: 8px; }
.plist li { gap: 6px; }
.plist .nm { min-width: 3.5em; }
.plist .rtt { display: none; }
@media (min-width: 400px) { .plist .rtt { display: inline; } }
.hud .remain b.hurry { color: #ff8a7a; }
.end-reason { font-size: 14px; color: var(--sumi-2); margin-top: 4px; letter-spacing: 0; }

/* =========================================================
   アイコン（LINE風の丸）・ガチャ・図鑑
   ========================================================= */
.av { --s: 36px; width: var(--s); height: var(--s); border-radius: 50%; display: inline-grid; place-items: center; flex: none; vertical-align: middle; position: relative; padding: calc(var(--s) * 0.07); }
.av-in { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #fffdf6, #efe3c4); overflow: hidden; }
.av-t { font-family: var(--mincho); font-weight: 800; color: #111; line-height: 1; letter-spacing: -0.02em; white-space: nowrap; }
.av-none { padding: 0; }
.av-none .av-t { color: #fff; font-family: var(--gothic); }
.av-N { background: #9a9a9a; }
.av-R { background: linear-gradient(135deg, #5aa7e6, #1f5fa8); }
.av-SR { background: linear-gradient(135deg, #f7dc7a, #c08a1e 60%, #f2d06a); }
.av-SSR { background: conic-gradient(#ff5e62, #ffb347, #fff275, #5dff9a, #4fc3ff, #9b6bff, #ff5ec8, #ff5e62); }
.hud .sc .av { margin-right: 2px; }
.rank-table .av { vertical-align: -8px; }
.home-me { display: flex; align-items: center; justify-content: center; gap: 10px; }
.home-me .home-hello { margin: 0; }
.home-links small { display: block; font-size: 11px; font-weight: 400; color: #c9b98f; margin-top: 2px; }
.home-links .btn { min-height: 54px; }
.home-gacha { border-color: rgba(201, 165, 90, 0.8) !important; color: var(--kin) !important; }
.pts-badge { font-size: 14px; color: var(--kin); }
.pts-get { text-align: center; font-weight: 700; color: var(--sumi-2); }
.pts-get b { color: var(--shu); }

/* レア度の文字色 */
.r-SSR { background: linear-gradient(90deg, #ff5e62, #ffb347, #4fc3ff, #9b6bff); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 900; }
.r-SR { color: #b8860b; font-weight: 900; }
.r-R { color: #1f6fb8; font-weight: 800; }
.r-N { color: #7a7a7a; font-weight: 700; }

/* 札（ガチャ・図鑑） */
.gc {
  --w: 120px; position: relative; width: var(--w); height: calc(var(--w) / 0.7); border-radius: calc(var(--w) * 0.08);
  background: linear-gradient(170deg, #fffbf1, #efe3c6); display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 0 0 calc(var(--w) * 0.04) var(--rc, #9a9a9a), 0 6px 16px rgba(0, 0, 0, 0.35); margin: calc(var(--w) * 0.04);
}
.gc::before { content: ""; position: absolute; inset: 8%; border: 1px solid rgba(120, 90, 40, 0.3); border-radius: 6px; pointer-events: none; }
.gc-N { --rc: #a8a8a8; }
.gc-R { --rc: #3b82c4; }
.gc-SR { --rc: #d4a537; }
.gc-SSR { --rc: #ff7ab6; box-shadow: 0 0 0 calc(var(--w) * 0.04) #fff, 0 0 0 calc(var(--w) * 0.075) #ff7ab6, 0 0 22px rgba(255, 180, 80, 0.8); }
.gc-SSR::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.7) 48%, transparent 66%); background-size: 250% 100%; animation: shine 2.2s infinite; pointer-events: none; }
@keyframes shine { 0% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
.gc-name { writing-mode: vertical-rl; text-orientation: upright; font-family: var(--mincho); font-weight: 800; font-size: calc(var(--w) * 0.26); color: #111; line-height: 1; letter-spacing: 0.04em; }
.gc-rar { position: absolute; top: 5%; left: 7%; font-size: calc(var(--w) * 0.11); font-weight: 900; color: var(--rc); font-family: var(--gothic); }
.gc-SSR .gc-rar { color: #e0408a; }
.gc-code { position: absolute; bottom: 5%; right: 8%; font-size: calc(var(--w) * 0.085); color: #8b7a55; font-family: ui-monospace, Menlo, monospace; }
.gc-new { position: absolute; top: -6px; right: -6px; background: var(--shu); color: #fff; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 999px; z-index: 2; }
.gc-cnt { position: absolute; top: 5%; right: 7%; font-size: calc(var(--w) * 0.1); color: #8b7a55; font-weight: 700; }
.gc-s { --w: 56px; }
.gc-s .gc-name { font-size: calc(var(--w) * 0.27); }
.gc-s .gc-code { display: none; }
.gc-locked { background: #2c3550; box-shadow: 0 0 0 2px #3b4566; cursor: default; }
.gc-locked::before { border-color: rgba(255, 255, 255, 0.08); }
.gc-locked .gc-q { color: #5b6688; font-size: calc(var(--w) * 0.4); font-weight: 800; }
.gc-locked .gc-code { display: block; color: #5b6688; font-size: 9px; }

/* ガチャ画面 */
.gacha-panel { display: grid; gap: 12px; }
.gacha-stage { min-height: 300px; display: grid; place-items: center; border-radius: 12px; background: radial-gradient(ellipse at 50% 40%, #2f4b3c, #1d3326); box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4); padding: 12px; overflow: hidden; }
.gacha-idle { text-align: center; color: #e8dfc8; }
.gacha-deck { position: relative; width: 100px; height: 143px; margin: 0 auto 14px; }
.gacha-deck span { position: absolute; inset: 0; border-radius: 9px; background: linear-gradient(170deg, #c0392b, #8e2a1f); border: 3px solid #f5e6c8; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45); }
.gacha-deck span:nth-child(1) { transform: rotate(-8deg) translate(-6px, 4px); }
.gacha-deck span:nth-child(2) { transform: rotate(5deg) translate(5px, 2px); }
.gacha-deck span:nth-child(3) { animation: bob 2s ease-in-out infinite; }
.gacha-deck span:nth-child(3)::after { content: "穴"; position: absolute; inset: 0; display: grid; place-items: center; color: #f5e6c8; font-family: var(--mincho); font-size: 44px; font-weight: 800; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.gacha-result { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; }
.gacha-result.one .gc { --w: 150px; }
.gacha-result .flip { animation: flipin 0.55s cubic-bezier(.2, .8, .3, 1.2) both; }
@keyframes flipin { 0% { transform: rotateY(90deg) scale(0.6); opacity: 0; } 100% { transform: rotateY(0) scale(1); opacity: 1; } }
.gacha-result.shine-SSR { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.85); } 100% { box-shadow: none; } }
.gacha-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gacha-btns .btn { display: grid; padding: 12px 8px; font-size: 18px; }
.gacha-btns small { font-size: 11px; font-weight: 400; opacity: 0.9; }
.gacha-rates { font-size: 13px; }
.gacha-rates summary { cursor: pointer; font-weight: 700; }
.gacha-rates ul { padding-left: 18px; margin: 6px 0; line-height: 1.8; }

/* 図鑑 */
.zgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 12px; justify-items: center; }
.zgrid .gc { margin: 4px; }

/* 札の詳細（下から出るシート） */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 10, 20, 0.7); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { width: min(var(--app-w), 100%); max-height: 88vh; overflow-y: auto; background: var(--washi); color: var(--sumi); border-radius: 18px 18px 0 0; padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); animation: up 0.25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.gd-top { display: flex; gap: 14px; align-items: center; }
.gd-top .gc { --w: 100px; flex: none; }
.gd-name { font-family: var(--mincho); font-size: 32px; font-weight: 800; }
.gd-kana { color: var(--sumi-2); margin-bottom: 4px; }
.gd-rar { font-size: 22px; margin-top: 4px; }
.gd h4 { margin: 14px 0 6px; font-family: var(--mincho); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.roles { display: flex; flex-wrap: wrap; gap: 6px; }
.role { background: #fffdf7; border: 1px solid #cdbd98; border-radius: 6px; padding: 3px 8px; font-size: 13px; font-weight: 700; }
.gd-loc { margin: 0; line-height: 1.7; font-size: 15px; }
.gc-s .gc-rar { font-size: 9px; top: 3px; left: 5px; }
.gc-s .gc-cnt { font-size: 9px; top: 3px; right: 5px; }
.home-top { min-height: 220px; padding-top: max(20px, env(safe-area-inset-top)); }
.home-seal { width: 64px; height: 64px; font-size: 40px; margin-bottom: 14px; }
.home-title { font-size: clamp(34px, 11vw, 50px); }
.home-lead { margin-top: 10px; }
.home-menu { gap: 10px; }
.home-btn { padding: 12px 18px; font-size: 19px; }
.zgrid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 4px; }
.zgrid .gc-s { --w: 48px; margin: 3px; }

/* 自主練・CPU対戦 */
.home-practice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-practice .btn { background: #2c3d60; color: #fff; border: 1px solid rgba(201, 165, 90, 0.5); display: grid; padding: 10px 8px; font-size: 17px; }
.home-practice small { font-size: 11px; font-weight: 400; color: #c9b98f; }
.chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.chipset label { position: relative; }
.chipset input { position: absolute; opacity: 0; pointer-events: none; }
.chipset span { display: inline-block; padding: 6px 10px; border-radius: 999px; border: 1.5px solid #cbbf9f; font-size: 14px; background: #fffdf7; cursor: pointer; font-family: var(--mincho); font-weight: 700; }
.chipset input:checked + span { background: var(--sumi); color: #fff; border-color: var(--sumi); }
.hud-quit { appearance: none; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; color: #e8e0cc; border-radius: 8px; width: 32px; height: 30px; font-size: 14px; flex: none; cursor: pointer; }
.practice-note { text-align: center; font-size: 13px; color: var(--sumi-2); }

/* サーバーにつながらないときの案内 */
.conn-banner {
  position: fixed; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 2000;
  width: min(440px, calc(100% - 20px)); background: #7a1f16; color: #fff; border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 14px; display: grid; gap: 6px;
}
.conn-banner .conn-sub { font-size: 12px; opacity: 0.9; }
.conn-banner details { font-size: 12px; }
.conn-banner summary { cursor: pointer; text-decoration: underline; }
.conn-banner ol { margin: 6px 0 0; padding-left: 18px; line-height: 1.6; }
.conn-banner .conn-retry { justify-self: start; }

/* 音が止まっているときの案内・アプリ内ブラウザの注意 */
.sound-banner {
  position: fixed; left: 50%; top: max(52px, calc(env(safe-area-inset-top) + 48px)); transform: translateX(-50%); z-index: 1500;
  width: min(420px, calc(100% - 20px)); border: 0; border-radius: 14px; padding: 12px 14px; cursor: pointer;
  background: var(--shu); color: #fff; font: inherit; font-size: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  display: grid; gap: 2px; text-align: center; animation: pulse 1.6s ease-in-out infinite;
}
.sound-banner span { font-size: 13px; opacity: 0.95; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.03); } }
.inapp-warn { background: #fff3cd; color: #5c4400; border: 1px solid #e0c36a; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; margin: 0; }
