/* 画面のデザインの案（A〜E）。<html data-theme="a"> のように、web/theme.js が案を決める。
   盤・駒・欄の形は app/style.css と web/online.css のまま。ここでは色・書体・枠・飾りだけを替える。
   どの案でも、木の盤・五角形に漢字の駒・成り駒の赤い字・手番の欄の緑は残す。 */

/* ---- 共通 ---- */
html[data-theme] body,
html[data-theme] .screen:not(.over-board),
html[data-theme] .chat { background: var(--bg-full, var(--bg)); background-attachment: fixed; }
html[data-theme] body { font-family: var(--font-body); font-variant-numeric: lining-nums; }
html[data-theme] .clock { font-variant-numeric: tabular-nums lining-nums; }
html[data-theme] .player-name,
html[data-theme] .card h1,
html[data-theme] .chat h1,
html[data-theme] .message { font-family: var(--font-title, var(--font-body)); }
html[data-theme] #game { position: relative; z-index: 1; }
/* 盤の額の分だけ、マスを小さくする（app/style.css の --cell に、額の幅を足して引く） */
html[data-theme] {
  --cell: min(calc((100vw - 2 * var(--gutter) - var(--rank-w) - 2 * var(--frame-pad, 0px)) / 9),
              calc((100dvh - var(--reserve)) / 11.8),
              60px);
}
/* 盤の外（背景の上）に直接出す文字。暗い背景の案では明るくする */
html[data-theme] .message,
html[data-theme] .coords,
html[data-theme] .extra .note,
html[data-theme] .head .note { color: var(--on-bg, var(--muted)); }
html[data-theme] .extra .note.strong,
html[data-theme] .head .note.strong { color: var(--on-bg-strong, var(--text)); }
html[data-theme] .board-wrap .coords { color: var(--coords, var(--muted)); }
html[data-theme] .board-wrap { padding: var(--frame-pad, 0); background: var(--frame, transparent); border-radius: var(--frame-radius, 0); box-shadow: var(--frame-shadow, none); }

/* 飾りの絵: 画面の上と下に固定し、押す操作の邪魔をしない。
   盤や欄やボタンに重なるときは、web/theme.js が隠す（visibility）。 */
.theme-deco { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.theme-deco .deco-top, .theme-deco .deco-bottom { position: absolute; left: 0; right: 0; }
.theme-deco .deco-top { top: env(safe-area-inset-top); }
.theme-deco .deco-bottom { bottom: 0; }
.theme-deco svg { display: block; width: 100%; }
@keyframes theme-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes theme-steam { 0%, 100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(-4px); opacity: .3; } }
.theme-deco .sway { animation: theme-sway 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.theme-deco .steam { animation: theme-steam 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .theme-deco .sway, .theme-deco .steam { animation: none; }
}

/* ---- A 浮世絵: 藍・生成り・朱。和紙に青海波 ---- */
html[data-theme="a"] {
  --bg: #f4e9d3; --text: #1b2a44; --muted: #3b4a63; --panel: #f7ecd5; --panel-border: #1d3f6e;
  --board: #e9c98b; --board-line: #3d2b18; --piece: #f8e8c4; --piece-edge: #8b6a3b; --piece-text: #1d140c;
  --button: #1d3f6e; --button-text: #f7ecd5; --active: #2f7d4a; --danger: #b8342a; --check: #b8342a;
  --bg-full: linear-gradient(rgba(244, 233, 211, .45), rgba(244, 233, 211, .45)), var(--pat-seigaiha) 0 0 / 48px 24px, #f4e9d3;
  --font-body: "Lora", "Shippori Mincho", serif;
  --font-title: "Cormorant Garamond", "Shippori Mincho", serif;
  --frame: #1d3f6e; --frame-pad: 6px; --coords: #f7ecd5; --frame-shadow: 4px 4px 0 rgba(29, 63, 110, .3);
}
html[data-theme="a"] .player { border: 2px solid #1d3f6e; border-radius: 0; box-shadow: 3px 3px 0 #1d3f6e; }
html[data-theme="a"] .player.to-move { border-color: var(--active); box-shadow: 3px 3px 0 var(--active), 0 0 0 2px var(--active) inset; }
html[data-theme="a"] .player-name { font-size: calc(15px * var(--k)); font-weight: 700; }
html[data-theme="a"] .hand, html[data-theme="a"] .card, html[data-theme="a"] .modal-box { border-radius: 0; }
html[data-theme="a"] .card { border: 2px solid #1d3f6e; box-shadow: 4px 4px 0 #1d3f6e; }
html[data-theme="a"] button, html[data-theme="a"] .card .buttons a.button, html[data-theme="a"] .extra a.button.next, html[data-theme="a"] .card .buttons button, html[data-theme="a"] .modal-buttons button { border-radius: 2px; }
html[data-theme="a"] .side-mark { color: #b8342a; }

/* ---- B 縁側の午後: 板の間に差す夕方の光 ---- */
html[data-theme="b"] {
  --bg: #7b4e2b; --text: #3a2614; --muted: #6b4a2c; --panel: #fff8ea; --panel-border: #e2c49a;
  --board: #e5b56d; --board-line: #4b2e14; --piece: #f9e4b8; --piece-edge: #8e6430; --piece-text: #1d140c;
  --button: #8a4f1e; --button-text: #fff8ea; --active: #3f8a52; --danger: #a8331f; --check: #b3261e;
  --bg-full: linear-gradient(115deg, rgba(255, 206, 130, 0) 20%, rgba(255, 206, 130, .3) 34%, rgba(255, 206, 130, .05) 48%, rgba(255, 206, 130, .26) 60%, rgba(255, 206, 130, 0) 75%),
    repeating-linear-gradient(90deg, #7b4e2b 0 46px, #83552f 46px 47.5px, #76492a 47.5px 92px, #5f3a1f 92px 93.5px);
  --on-bg: #fff3dc; --on-bg-strong: #fffaf0;
  --font-body: "Lora", "Zen Old Mincho", serif;
  --frame: #6a4220; --frame-pad: 6px; --frame-radius: 6px; --coords: #f6dfb4; --frame-shadow: 0 14px 26px rgba(30, 15, 5, .5);
}
html[data-theme="b"] .player { border-radius: 14px; border-color: transparent; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }
html[data-theme="b"] .player.to-move { border-color: var(--active); box-shadow: 0 0 0 2px var(--active) inset, 0 0 0 3px rgba(63, 138, 82, .35), 0 4px 12px rgba(0, 0, 0, .18); }
html[data-theme="b"] .hand { background: rgba(40, 22, 10, .28); border-color: rgba(255, 230, 190, .25); }
html[data-theme="b"] .message { font-style: italic; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
html[data-theme="b"] .extra .next.secondary,
html[data-theme="b"] .extra a.button.next.secondary,
html[data-theme="b"] .extra .voice-toggle,
html[data-theme="b"] .lang-select { color: var(--text); background: var(--panel); }
/* 問い合わせのチャットは文字が多いので、板の間ではなく、明るい地にする */
html[data-theme="b"] .chat { --bg-full: #f6ead4; }
html[data-theme="b"] .card .trust, html[data-theme="b"] .url-box, html[data-theme="b"] .dev-field, html[data-theme="b"] .kifu-row { background: #f6ead4; }
html[data-theme="b"] .side-mark { color: #a5642a; }
.theme-deco-b .deco-bottom { display: flex; justify-content: flex-end; padding: 0 10px 12px; }
.theme-deco-b .deco-bottom .tea { width: 56px; height: 56px; }

/* ---- C 着物の文様: 自分と相手の欄を、別の文様で塗り分ける ---- */
html[data-theme="c"] {
  --bg: #f4efe6; --text: #1c1c1c; --muted: #4a4540; --panel: #fffaf2; --panel-border: #1c1c1c;
  --board: #edcd92; --board-line: #1c1c1c; --piece: #fbf1d9; --piece-edge: #6b5a3a; --piece-text: #1d140c;
  --button: #1c1c1c; --button-text: #f4efe6; --active: #2f8a57; --danger: #b7282e; --check: #b7282e;
  --font-body: "Josefin Sans", "Zen Kaku Gothic New", sans-serif;
  --frame: #1c1c1c; --frame-pad: 6px; --coords: #f4efe6;
}
html[data-theme="c"] .player { border: 2px solid #1c1c1c; border-radius: 0; padding-left: 42px; }
html[data-theme="c"] .player.top { background: linear-gradient(90deg, transparent 30px, #1c1c1c 30px 32px, transparent 32px), var(--pat-yagasuri) left top / 24px auto repeat-y, var(--panel); background-size: auto, 30px auto, auto; }
html[data-theme="c"] .player.bottom { background: linear-gradient(90deg, transparent 30px, #1c1c1c 30px 32px, transparent 32px), var(--pat-kanoko-red) left top / 20px 20px repeat-y, var(--panel); background-size: auto, 30px 30px, auto; }
html[data-theme="c"] .player.to-move { box-shadow: none; outline: 3px solid var(--active); outline-offset: 2px; }
html[data-theme="c"] .side-mark { letter-spacing: .08em; }
html[data-theme="c"] .hand, html[data-theme="c"] .card, html[data-theme="c"] .modal-box { border-radius: 0; border-color: #1c1c1c; }
html[data-theme="c"] button, html[data-theme="c"] .card .buttons a.button, html[data-theme="c"] .extra a.button.next, html[data-theme="c"] .card .buttons button, html[data-theme="c"] .modal-buttons button { border-radius: 0; letter-spacing: .06em; }
.theme-deco-c .band { height: 22px; background: var(--pat-ichimatsu) 0 0 / 22px 22px; }
.theme-deco-c .kamon { position: absolute; right: -50px; bottom: -40px; width: 260px; height: 260px; color: #1c1c1c; opacity: .06; }

/* ---- D 墨と刀: 黒漆の中に木の盤 ---- */
html[data-theme="d"] {
  --bg: #0d0b09; --text: #efe6d3; --muted: #b9ad95; --panel: #17120e; --panel-border: rgba(216, 180, 106, .45);
  --board: #dcae63; --board-line: #2a190a; --piece: #f3dfb4; --piece-edge: #7a5426; --piece-text: #1d140c;
  --button: #a8231b; --button-text: #f6efe0; --active: #5fbf7c; --danger: #ff8a75; --check: #ff8a75;
  --bg-full: radial-gradient(circle at 88% 9%, rgba(239, 230, 207, .22) 0, rgba(239, 230, 207, .07) 70px, transparent 120px),
    radial-gradient(120% 70% at 50% 45%, #2a1c12 0%, #0d0b09 60%, #050404 100%);
  --on-bg: #cfc5b0; --on-bg-strong: #f3e8cf;
  --font-body: "Lora", "Shippori Mincho", serif;
  --font-title: "Cinzel", "Shippori Mincho", serif;
  --frame: linear-gradient(135deg, #3a2614, #1a110a); --frame-pad: 7px; --coords: #d8b46a;
  --frame-shadow: 0 0 0 1px #d8b46a, 0 0 40px rgba(220, 160, 80, .18), 0 20px 40px rgba(0, 0, 0, .6);
}
html[data-theme="d"] .player { background: linear-gradient(180deg, #1b1611, #100d0a); }
html[data-theme="d"] .player.to-move { box-shadow: 0 0 0 2px var(--active) inset, 0 0 18px rgba(95, 191, 124, .35); }
html[data-theme="d"] .side-mark { color: #d8b46a; }
html[data-theme="d"] .hand { background: rgba(23, 18, 14, .85); }
html[data-theme="d"] .hand-count { background: #d8b46a; color: #17120e; }
html[data-theme="d"] .message { letter-spacing: .04em; }
html[data-theme="d"] .modal-buttons button.secondary,
html[data-theme="d"] .card .buttons .secondary { color: var(--text); }
html[data-theme="d"] .google-slot { background: #f6efe0; border-radius: 8px; padding: 6px; }

/* ---- E 縁日の遊び: 提灯と鹿の子、丸い欄 ---- */
html[data-theme="e"] {
  --bg: #fff7e6; --text: #3b2a20; --muted: #6b5446; --panel: #ffffff; --panel-border: #ffd9a8;
  --board: #f2cc80; --board-line: #6b4a1e; --piece: #fff3d6; --piece-edge: #a0763b; --piece-text: #1d140c;
  --button: #e8473a; --button-text: #ffffff; --active: #3fbf6f; --danger: #e8473a; --check: #d93a2e;
  --bg-full: var(--pat-kanoko) 0 0 / 44px 44px, #fff7e6;
  --font-body: "Fredoka", "Zen Maru Gothic", sans-serif;
  --frame: #e8473a; --frame-pad: 7px; --frame-radius: 16px; --coords: #fff3d6; --frame-shadow: 0 5px 0 #b32e23;
}
html[data-theme="e"] .player { border: 3px solid #ffd9a8; border-radius: 22px; }
html[data-theme="e"] .player.to-move { border-color: var(--active); box-shadow: 0 0 0 4px rgba(63, 191, 111, .25); }
html[data-theme="e"] .side-mark { color: #e8473a; }
html[data-theme="e"] .hand { border-radius: 16px; border-width: 2px; }
html[data-theme="e"] button, html[data-theme="e"] .card .buttons a.button, html[data-theme="e"] .extra a.button.next, html[data-theme="e"] .card .buttons button, html[data-theme="e"] .modal-buttons button { border-radius: 999px; }
html[data-theme="e"] .card, html[data-theme="e"] .modal-box { border-radius: 22px; border: 3px solid #ffd9a8; }
html[data-theme="e"] .message { color: #2a5b72; font-weight: 600; }

/* ---- トップページ・プライバシーポリシー（ログイン前。5 分ごとに切り替わる） ---- */
html[data-theme] body { transition: opacity .4s ease; }
html.theme-fade body { opacity: 0; }
html[data-theme] .page h1 { font-family: var(--font-hero, var(--font-title, var(--font-body))); overflow-wrap: break-word; hyphens: auto; }
/* 絵の高さを先に空けておく（絵が入ったときに、下の文が動かないように）。縦横の比は、案ごとの絵の viewBox */
.page .hero { margin: 0 calc(-1 * var(--gutter)) 8px; aspect-ratio: 390 / 330; }
html[data-theme="b"] .page .hero { aspect-ratio: 390 / 360; }
html[data-theme="c"] .page .hero { aspect-ratio: 390 / 320; }
html[data-theme="d"] .page .hero { aspect-ratio: 390 / 380; }
.page .hero svg { display: block; width: 100%; height: 100%; }
@media (min-width: 640px) { .page .hero { margin: 0 0 8px; border-radius: 14px; overflow: hidden; } }
.page h1 .kana { display: block; margin-top: 6px; font-size: 0.42em; font-weight: 600; letter-spacing: .06em; opacity: .85; }
.page .tagline { margin: 4px 0 18px; font-size: calc(17px * var(--k)); line-height: 1.5; text-align: center; }
.page .tagline span { display: none; }
html[data-theme="a"] .tagline [data-for="a"], html[data-theme="b"] .tagline [data-for="b"], html[data-theme="c"] .tagline [data-for="c"],
html[data-theme="d"] .tagline [data-for="d"], html[data-theme="e"] .tagline [data-for="e"] { display: inline; }
html[data-theme] .page .notice, html[data-theme].inapp .page .inapp-guide, html[data-theme] .inapp .page .inapp-guide { background: var(--panel); }
html[data-theme] .page th { background: var(--panel); }
/* 絵の動き */
@keyframes theme-spin { to { transform: rotate(360deg); } }
@keyframes theme-fan { 0% { transform: scale(.2) rotate(-60deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes theme-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes theme-foam { 0%, 100% { opacity: .9; } 50% { opacity: .55; } }
.hero .sway { animation: theme-sway 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.hero .sway:nth-child(2n) { animation-delay: -1.4s; }
.hero .steam { animation: theme-steam 2.6s ease-in-out infinite; }
.hero .spin { animation: theme-spin 1.1s linear infinite; transform-box: fill-box; transform-origin: center; }
.hero .fan { animation: theme-fan 1.6s cubic-bezier(.2, .8, .2, 1) .3s both; transform-box: view-box; transform-origin: 195px 286px; }
.hero .bob { animation: theme-bob 2.6s ease-in-out infinite; }
.hero .spray { animation: theme-foam 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  html[data-theme] body { transition: none; }
  .hero .sway, .hero .steam, .hero .spin, .hero .fan, .hero .bob, .hero .spray { animation: none; }
}
/* 案ごとの題とキャッチコピー */
html[data-theme="a"] { --font-hero: "Cormorant Garamond", "Shippori Mincho", serif; }
html[data-theme="a"] .page h1 { color: #1b2a44; letter-spacing: .02em; }
html[data-theme="a"] .page .tagline { font-style: italic; color: #2b4c7e; }
html[data-theme="a"] .page h1 .kana, html[data-theme="a"] .page h1 .sub { color: #b8342a; font-family: "Lora", "Shippori Mincho", serif; }
html[data-theme="a"] .page h2 { display: flex; align-items: center; gap: 10px; }
html[data-theme="a"] .page h2::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, #b8342a 0 10px, transparent 10px 14px); }
html[data-theme="b"]:has(main.page) { --bg-full: #f6ead4; --font-hero: "Lora", "Zen Old Mincho", serif; }
html[data-theme="b"] .page h1 { font-style: italic; color: #4a2a12; }
html[data-theme="b"] .page h1 .kana, html[data-theme="b"] .page h1 .sub { font-style: normal; color: #a5642a; }
html[data-theme="b"] .page .tagline { color: #7a4a20; }
html[data-theme="b"] .page .cta { border-radius: 14px; box-shadow: 0 6px 16px rgba(184, 102, 42, .35); }
html[data-theme="c"] { --font-hero: "Josefin Sans", "Zen Kaku Gothic New", sans-serif; }
html[data-theme="c"] .page h1 { letter-spacing: .14em; text-transform: uppercase; }
html[data-theme="c"] .page h1 .kana { color: #b7282e; text-transform: none; }
html[data-theme="c"] .page h1 .sub { text-transform: none; letter-spacing: .04em; }
html[data-theme="c"] .page h2 { letter-spacing: .12em; }
html[data-theme="d"] { --font-hero: "Cinzel", "Yuji Syuku", serif; }
html[data-theme="d"] .page h1 { color: #d8b46a; letter-spacing: .1em; }
html[data-theme="d"] .page h1 .kana, html[data-theme="d"] .page h1 .sub { color: #b9a988; font-family: "Lora", "Shippori Mincho", serif; letter-spacing: .04em; }
html[data-theme="d"] .page .tagline { font-style: italic; }
html[data-theme="d"] .page h2 { color: #d8b46a; }
html[data-theme="d"] .page .cta { border: 1px solid #d8b46a; }
html[data-theme="e"] { --font-hero: "Fredoka", "Mochiy Pop One", sans-serif; }
html[data-theme="e"] .page h1 { color: #e8473a; text-shadow: 3px 3px 0 #ffd23f; }
html[data-theme="e"] .page h1 .kana, html[data-theme="e"] .page h1 .sub { color: #2a5b72; text-shadow: none; font-family: "Zen Maru Gothic", sans-serif; }
html[data-theme="e"] .page .tagline { font-weight: 600; }
html[data-theme="e"] .page .cta { border-radius: 999px; box-shadow: 0 5px 0 #b32e23; }
html[data-theme="e"] .page h2 { color: #2a5b72; }
html[lang="ja"] .page .tagline { font-style: normal; }
html[data-theme="a"] .page .cta, html[data-theme="c"] .page .cta { border-radius: 2px; }
