/* Game of Chance Yuzu v1.3（土台）。見た目は v1.1「地下の賭場」: 薄暗いコンクリートの部屋・天井の蛍光灯（かすかなちらつき）・すすけた壁。朱と金。
   筆の書体は役の名前と大きな告知だけ。雰囲気だけを借り、作品名・人物・通貨名・絵柄は使わない。
   重い blur・大量の影は使わない（iPhone の GPU）。明るいテーマは作らない。 */
@font-face { font-family: "Dela Gothic One"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/dela-gothic-subset.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #0a0a09; --panel: #151513; --panel-2: #20201d; --conc: #2a2a27; --lamp: #d8e6e0; --line: rgba(230, 230, 210, 0.08); --line-2: rgba(230, 230, 210, 0.15);
  --ink: #e9e6da; --muted: #8a877c; --red: #d63a24; --red-deep: #7e1f12; --gold: #d4a43c; --gold-deep: #6f5a23;
  --lose: #ff4d3a; --win: #f0c25a; --ok: #7fbf8f; --focus: #f3c766;
  --die: #f1ead6; --die-edge: #cfc6ae; --pip: #17120f;
  --space-3xs: 2px; --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px; --space-lg: 24px; --space-xl: 40px;
  --text-xs: 0.8125rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.25rem; --text-xl: 1.5rem; --text-2xl: 2.1rem; --text-3xl: 3rem;
  --r-s: 4px; --r-m: 8px; --r-l: 10px;
  --font-body: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --font-brush: "Dela Gothic One", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --z-dim: 20; --z-stage: 30; --z-modal: 400; --z-toast: 500;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .8 0 0 0 0 .8 0 0 0 0 .75 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --wall: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='420'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.011' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .42 -.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3Cpath d='M40 0 L52 70 L44 130 L60 210 L55 260' stroke='%23050504' stroke-width='1.2' fill='none' opacity='.7'/%3E%3Cpath d='M300 120 L286 190 L296 260 L280 330' stroke='%23050504' stroke-width='1' fill='none' opacity='.6'/%3E%3Cellipse cx='90' cy='330' rx='40' ry='70' fill='%2312100c' opacity='.35'/%3E%3C/svg%3E");
  --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; margin: 0; height: 100%; background: var(--bg); }
html { scrollbar-color: var(--gold-deep) var(--bg); }
body { color: var(--ink); font-family: var(--font-body); font-weight: 600; font-size: var(--text-md); line-height: 1.5; -webkit-font-smoothing: antialiased; line-break: strict; word-break: auto-phrase; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
:where(*) { touch-action: pan-x pan-y; }
::selection { background: rgba(212, 164, 60, 0.4); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 800; line-height: 1.15; overflow-wrap: break-word; min-width: 0; text-wrap: balance; }
h1 { font-size: clamp(2.3rem, 10vw, 3.2rem); } h2 { font-size: var(--text-lg); }
p { text-wrap: pretty; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.brush { font-family: var(--font-brush); font-weight: 400; letter-spacing: 0.02em; }
#zawa-layer { position: fixed; inset: 0; z-index: 35; pointer-events: none; overflow: hidden; }
.zawa { position: absolute; color: #f2efe4; opacity: 0; white-space: nowrap; line-height: 1; letter-spacing: 0.02em; -webkit-text-stroke: 0; text-shadow: 3px 0 0 #050505, -3px 0 0 #050505, 0 3px 0 #050505, 0 -3px 0 #050505, 2px 2px 0 #050505, -2px -2px 0 #050505, 2px -2px 0 #050505, -2px 2px 0 #050505; }
.muted { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }

/* 外枠: 上端は ver・つながり・音の切り替えだけ。操作は画面の下 */
#app-shell { display: flex; flex-direction: column; height: 100dvh; max-width: 520px; margin-inline: auto; padding-top: var(--sat); position: relative; background: radial-gradient(ellipse 88% 72% at 50% 42%, rgba(0, 0, 0, 0) 48%, rgba(0, 0, 0, 0.78) 100%), var(--grain), var(--wall), radial-gradient(ellipse 120% 60% at 50% 30%, #23231f 0%, #121311 62%, #0a0a09 100%); }
@media (display-mode: standalone) {
  html { position: static; overflow: visible; height: auto; }
  body { position: static; overflow: visible; height: calc(100lvh + 1px); overscroll-behavior-y: none; }
  #app-shell { height: 100lvh; }
}
#lamp { position: absolute; top: 0; left: 0; right: 0; height: 100%; pointer-events: none; z-index: 1; overflow: hidden; }
#lamp .cord { position: absolute; top: 0; left: 50%; width: 2px; height: 30px; margin-left: -1px; background: #050505; }
#lamp .bulb { position: absolute; top: 28px; left: 50%; width: 22px; height: 28px; margin-left: -11px; border-radius: 50% 50% 46% 46% / 40% 40% 60% 60%; background: radial-gradient(circle at 50% 62%, #fffbe6 0%, #ffe7a0 55%, #c9a24a 100%); box-shadow: 0 0 22px 8px rgba(255, 232, 160, 0.55), 0 0 60px 26px rgba(255, 226, 150, 0.22); animation: flick 7.3s step-end infinite; }
#lamp .bulb::before { content: ""; position: absolute; top: -9px; left: 50%; width: 12px; height: 11px; margin-left: -6px; background: #26231c; border-radius: 2px 2px 0 0; }
#lamp .cone { position: absolute; top: 52px; left: 50%; width: 150%; height: 62%; margin-left: -75%; background: linear-gradient(rgba(255, 238, 190, 0.24), rgba(255, 238, 190, 0.09) 55%, rgba(255, 238, 190, 0.02)); clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%); animation: flick 7.3s step-end infinite; }
@keyframes flick { 0% { opacity: 1; } 61% { opacity: 0.55; } 61.6% { opacity: 1; } 63% { opacity: 0.7; } 63.5% { opacity: 1; } 88% { opacity: 0.8; } 88.4% { opacity: 1; } }
#topbar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: var(--space-xs) var(--space-md); font-size: var(--text-xs); color: var(--muted); min-height: 40px; }
#link-note { color: var(--lose); font-weight: 800; }
#sound-btn { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: var(--space-2xs) var(--space-sm); font-size: var(--text-xs); min-height: 32px; color: var(--ink); }
#sound-btn[aria-pressed="false"] { color: var(--muted); }
#sound-btn[aria-pressed="true"] { border-color: var(--gold-deep); }
#screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scr { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: var(--space-2xs) var(--space-md) var(--space-sm); display: flex; flex-direction: column; gap: var(--space-sm); }
.bar { flex: none; padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + var(--sab)); display: flex; flex-direction: column; gap: var(--space-xs); background: linear-gradient(#17120f, #100c0a); border-top: 1px solid var(--line-2); box-shadow: inset 0 1px 0 rgba(212, 164, 60, 0.18); }
.bar-row { display: flex; gap: var(--space-xs); } .bar-row > * { flex: 1; min-width: 0; }
.hint { font-size: var(--text-sm); color: var(--muted); text-align: center; min-height: 1.4em; }

/* ボタン */
.btn { appearance: none; border: 1px solid var(--line-2); border-radius: var(--r-m); min-height: 52px; padding: 0 var(--space-md); font-weight: 800; font-size: var(--text-md); background: var(--panel-2); color: var(--ink); box-shadow: inset 0 1px 0 rgba(230, 230, 210, 0.08); transition: transform 90ms ease-out, background-color 90ms; cursor: pointer; }
.btn:active:not(:disabled) { transform: translateY(2px) scale(0.99); }
.btn--primary { background: linear-gradient(#e04a30, #b02a18); border-color: #f0705a; color: #fff4e6; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 2px 0 var(--red-deep); }
.btn--ghost { background: rgba(212, 164, 60, 0.07); border-color: var(--gold-deep); box-shadow: none; min-height: 44px; color: var(--gold); font-weight: 800; }
.btn--coral { background: var(--lose); border-color: var(--lose); color: #1a0b08; }
.btn:disabled { background: #17120f; border-color: var(--line); color: #5f564b; box-shadow: none; cursor: not-allowed; }
.btn--sm { min-height: 44px; padding: 0 var(--space-md); font-size: var(--text-sm); }
.btn--big { min-height: 64px; font-size: var(--text-lg); }
.btn--duel { font-size: 1.6rem; letter-spacing: 0.22em; padding-left: 0.4em; font-weight: 900; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.seg .btn { min-height: 48px; padding: 0 var(--space-2xs); font-size: var(--text-sm); }
.seg .btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1a1208; }
.field { width: 100%; min-height: 52px; padding: 0 var(--space-md); border: 1px solid var(--line-2); border-radius: var(--r-m); background: #0f0b09; color: var(--ink); font-size: 16px; }
.field::placeholder { color: #6c665b; font-weight: 500; }
.field:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label.lbl { display: block; font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-2xs); }

/* 面 */
.paper { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: inset 0 1px 0 rgba(212, 164, 60, 0.14); padding: var(--space-md); }
.title-block { position: relative; padding: var(--space-lg) var(--space-2xs) var(--space-xs); display: flex; flex-direction: column; gap: var(--space-xs); }
.title-block h1 { position: relative; color: var(--ink); text-shadow: 0 2px 0 #000; font-size: clamp(1.9rem, 9.4vw, 2.7rem); }
.title-block .intro { position: relative; color: var(--muted); font-size: var(--text-sm); }
.title-rule { height: 3px; width: 64px; background: var(--red); border-radius: 2px; }
.title-block.over { align-items: center; text-align: center; padding-top: var(--space-xl); }
.brush--end { font-size: 4.2rem; line-height: 1; color: var(--win); text-shadow: 0 3px 0 #000; }
.room-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.room { display: flex; align-items: center; gap: var(--space-sm); }
.room-info { flex: 1; min-width: 0; }
.room-info b, .room-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-info span { font-size: var(--text-sm); color: var(--muted); font-weight: 500; }
.room .btn { flex: none; min-width: 84px; }
.row-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); }
.empty { text-align: center; color: var(--muted); padding: var(--space-md) var(--space-xs); }
.join-row { display: flex; gap: var(--space-xs); align-items: flex-start; }
.join-row .field { flex: 1; text-align: center; }
.join-row .btn { flex: none; min-width: 84px; }

/* 待合 */
.code-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); }
.code-block { display: flex; flex-direction: column; gap: var(--space-2xs); min-width: 0; font-size: var(--text-xs); }
.code { font-size: clamp(2.6rem, 12vw, 3.4rem); font-weight: 900; letter-spacing: 0.16em; padding-left: 0.16em; line-height: 1.05; color: var(--win); text-shadow: 0 2px 0 #000; }
.qr { width: 104px; height: 104px; flex: none; image-rendering: pixelated; border-radius: 6px; background: var(--die); padding: var(--space-xs); }
.lobby-seats { display: flex; flex-direction: column; gap: var(--space-xs); }
.lseat { display: flex; align-items: center; gap: var(--space-xs); min-height: 44px; }
.lseat .nm { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: var(--text-xs); padding: var(--space-3xs) var(--space-xs); border-radius: var(--r-s); background: var(--panel-2); color: var(--ink); white-space: nowrap; }
.tag--host { background: var(--red); color: #fff4e6; }
.tag--cpu { background: #2d2a38; color: #c9c4e6; }
.tag--off { color: var(--muted); }
.tag--on { color: var(--ok); }
.setting + .setting { margin-top: var(--space-sm); }

/* 順位 */
.rank-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.rank { display: flex; align-items: center; gap: var(--space-sm); }
.rank .no { font-size: var(--text-2xl); font-weight: 900; width: 1.6ch; text-align: center; flex: none; line-height: 1; }
.rank .nm { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .pt { font-weight: 900; font-size: var(--text-lg); }
.rank.first { border-color: var(--gold); background: linear-gradient(90deg, rgba(212, 164, 60, 0.25), var(--panel) 70%); }
.rank.first .no, .rank.first .pt { color: var(--win); }

/* 役の一覧の板 */
#sheet-root:empty { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--panel); border-top: 1px solid var(--gold-deep); border-radius: var(--r-l) var(--r-l) 0 0; padding: var(--space-md) var(--space-md) calc(var(--space-md) + var(--sab)); display: flex; flex-direction: column; gap: var(--space-sm); }
#toast { position: absolute; left: 16px; right: 16px; bottom: calc(150px + var(--sab)); z-index: var(--z-toast); background: var(--ink); color: #1a1208; padding: var(--space-xs) var(--space-md); border-radius: var(--r-m); text-align: center; font-size: var(--text-sm); font-weight: 800; }
.shake { animation: shake 0.3s ease-out; }
@keyframes shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
@media (max-height: 700px) {
  .brush--end { font-size: 3.2rem; }
}
.body > * { flex-shrink: 0; }

/* v1.2 インターネット公開: 外の人の印・招待の操作・席の管理の板 */
.tag--ext { background: rgba(212, 164, 60, 0.14); color: var(--gold); border: 1px solid var(--gold-deep); }
.ext-mark { flex: none; font-size: 0.6875rem; line-height: 1; padding: 2px 4px; border-radius: var(--r-s); color: var(--gold); border: 1px solid var(--gold-deep); font-weight: 800; }
.stack { display: flex; flex-direction: column; gap: var(--space-xs); }
.stack > .btn { width: 100%; }
.invite-ctl .stack { margin-top: var(--space-xs); }
.invite-state { font-size: var(--text-sm); color: var(--ink); font-weight: 700; }
.invite-state.locked { color: var(--lose); }
.title-block .intro.gate { color: var(--ink); font-size: var(--text-lg); font-weight: 800; line-height: 1.5; }
.manage-seats { display: flex; flex-direction: column; gap: var(--space-xs); }

/* v1.3 ホーム・ゲームの入口（Game of Chance Yuzu） */
.goc-title { display: flex; flex-direction: column; gap: 0; font-family: "Avenir Next", "Futura", "Helvetica Neue", "Segoe UI", system-ui, sans-serif; font-weight: 900; line-height: 0.98; letter-spacing: 0.01em; color: var(--ink); text-shadow: 0 2px 0 #000, 0 0 18px rgba(214, 58, 36, 0.28); font-size: clamp(2.1rem, 11.5vw, 3rem); }
.goc-title .goc-yuzu { color: var(--gold); letter-spacing: 0.14em; font-size: 0.8em; margin-top: 0.12em; padding-left: 0.05em; }
.home-title { padding-top: var(--space-md); }
.door-title { font-size: clamp(2rem, 10vw, 2.8rem); text-shadow: 0 2px 0 #000; }
.game-list { display: flex; flex-direction: column; gap: var(--space-md); }
.game-card { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-md); background: linear-gradient(180deg, rgba(214, 58, 36, 0.12), var(--panel) 46%); border-color: var(--line-2); }
.game-art { align-self: center; width: min(46%, 168px); aspect-ratio: 1; height: auto; border-radius: 22%; background: var(--panel-2); display: block; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6); }
.game-art--none { display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 900; color: var(--gold); border: 1px solid var(--gold-deep); }
.game-info { display: flex; flex-direction: column; gap: var(--space-2xs); text-align: center; }
.game-info h2 { font-size: var(--text-xl); }
.game-tag { color: var(--ink); font-size: var(--text-sm); font-weight: 600; }
.game-meta { color: var(--muted); font-size: var(--text-xs); }
.game-go { width: 100%; min-height: 56px; font-size: var(--text-lg); }
.room-game { color: var(--gold) !important; font-size: var(--text-xs) !important; }
.howto { display: flex; flex-direction: column; gap: var(--space-xs); }
.howto p { font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.lobby-game { font-size: var(--text-sm); color: var(--gold); font-weight: 800; padding: var(--space-xs) var(--space-2xs) 0; }
