  :root {
    --blue: #2170a1;
    --orange: #d4702f;
    --teal: #29707f;
    --ink: #24303a;
    --paper: rgba(255,255,255,0.82);
    --paper-brd: rgba(255,255,255,0.7);
    --shadow-sm: 0 2px 8px rgba(20,50,60,0.10);
    --shadow-md: 0 6px 20px rgba(20,50,60,0.14);
    --shadow-lg: 0 14px 40px rgba(20,50,60,0.20);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  body {
    font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
    background: linear-gradient(165deg, #bcd4dd 0%, #e7f1f2 45%, #cfe1e2 100%);
    color: var(--ink);
    min-height: 100dvh;
  }
  body::before {
    content: ""; position: fixed; inset: 0; z-index: -2;
    background: url("../restroom-background.png") center / cover no-repeat;
    opacity: 0.35; filter: saturate(0.8) blur(1px);
  }
  /* うっすらした光のムラで平面的にならないように */
  body::after {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
      radial-gradient(60% 45% at 18% 8%, rgba(255,255,255,0.5), transparent 60%),
      radial-gradient(55% 40% at 88% 92%, rgba(120,160,170,0.28), transparent 60%);
  }
  #app { max-width: 640px; margin: 0 auto; padding: 12px; min-height: 100dvh; display: flex; flex-direction: column; gap: 10px; }
  .card {
    background: var(--paper);
    -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid var(--paper-brd); border-radius: 20px; padding: 14px;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.6);
  }
  button { font-family: inherit; border: none; cursor: pointer; }
  button:disabled { cursor: default; }

  /* menu */
  .hero {
    position: relative; overflow: hidden; margin-top: 16px; padding: 26px 22px;
    border: none; color: #fff;
    background: linear-gradient(150deg, #2c8093 0%, #1c5769 52%, #223f63 100%);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.25);
  }
  .hero::before {
    content: ""; position: absolute; inset: 0; opacity: 0.13; pointer-events: none;
    background-image:
      repeating-linear-gradient(0deg, transparent 0 33px, rgba(255,255,255,0.6) 33px 35px),
      repeating-linear-gradient(90deg, transparent 0 33px, rgba(255,255,255,0.6) 33px 35px);
  }
  .hero::after {
    content: ""; position: absolute; top: -50%; left: -25%; width: 70%; height: 150%;
    background: radial-gradient(closest-side, rgba(255,255,255,0.3), transparent 70%);
    transform: rotate(18deg); pointer-events: none;
  }
  .menu-title { position: relative; font-size: 39px; font-weight: 900; letter-spacing: -1px; line-height: 1.05; text-shadow: 0 3px 12px rgba(0,0,0,0.28); }
  .menu-title .emoji { display: inline-block; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.3)); }
  .hero .menu-sub { position: relative; color: rgba(255,255,255,0.92); }
  .menu-sub { color: #5b6b73; font-weight: 600; margin-top: 10px; line-height: 1.6; font-size: 14px; }
  .badge-row { position: relative; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
  .badge { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.28); border-radius: 999px; padding: 6px 12px; font-size: 11px; font-weight: 800; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  .hint { display: flex; gap: 10px; align-items: baseline; font-size: 13px; font-weight: 600; color: #3d4c54; margin-top: 9px; }
  .hint .ico { flex-shrink: 0; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(41,112,127,0.10); font-size: 14px; }
  .seg { display: flex; background: #e4ecee; border-radius: 12px; padding: 3px; margin-top: 10px; }
  .seg button { flex: 1; padding: 9px 4px; border-radius: 10px; background: transparent; font-weight: 800; font-size: 13px; color: #55666e; }
  .seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
  .online-actions { display: grid; gap: 9px; margin-top: 14px; }
  .online-secondary {
    width: 100%; padding: 13px; border-radius: 14px; background: #e6eef0;
    color: #34474f; font-size: 14px; font-weight: 900;
  }
  .online-error { margin-top: 10px; color: #a43f2e; font-size: 12px; font-weight: 800; line-height: 1.45; }
  .online-code-input {
    width: 100%; margin-top: 14px; padding: 15px 12px; border: 2px solid #c8d8dc;
    border-radius: 14px; background: #fff; color: var(--ink); text-align: center;
    font: 900 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px;
    text-transform: uppercase; outline: none;
  }
  .online-code-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(41,112,127,0.13); }
  .online-lobby { max-width: 520px; margin: 18px auto; text-align: center; }
  .online-lobby h2 { margin: 0; font-size: 22px; font-weight: 900; }
  .room-code {
    margin: 18px 0 12px; padding: 17px 12px; border-radius: 18px; background: #edf4f5;
    color: var(--teal); font: 900 29px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 2px; border: 2px dashed rgba(41,112,127,0.35);
  }
  .room-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .room-actions button { padding: 12px 8px; border-radius: 13px; background: #e5edef; font-size: 13px; font-weight: 900; color: #40545d; }
  .waiting-line, .connection-line {
    margin-top: 18px; padding: 12px; border-radius: 14px; background: rgba(41,112,127,0.09);
    color: #40545d; font-size: 13px; font-weight: 800;
  }
  .connection-line { background: #fff1d2; color: #7a5b19; }
  .wait-dot { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: var(--teal); animation: waitpulse 1.2s ease-in-out infinite; }
  @keyframes waitpulse { 50% { opacity: 0.3; transform: scale(0.72); } }
  .opponent-dock {
    position: absolute; z-index: 9; left: 8px; right: 8px; bottom: 8px;
    display: flex; align-items: center; justify-content: center; min-height: 74px; padding: 16px;
    border: 1px solid var(--paper-brd); border-radius: 18px; background: rgba(255,255,255,0.93);
    color: #52656d; font-size: 14px; font-weight: 900; box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  }
  .submit-note { color: var(--teal); font-size: 11px; font-weight: 900; white-space: nowrap; }
  .start-btn {
    position: relative; overflow: hidden;
    width: 100%; margin-top: 16px; padding: 16px 18px; border-radius: 16px;
    background: linear-gradient(100deg, #17505f, #2f8a86); color: #fff;
    font-size: 16px; font-weight: 900; display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 8px 20px rgba(23,80,95,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
    transition: transform 0.12s, box-shadow 0.12s;
  }
  .start-btn:active { transform: translateY(2px); box-shadow: 0 4px 12px rgba(23,80,95,0.4); }
  .start-btn .go {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
    border-radius: 50%; background: rgba(255,255,255,0.22); font-size: 17px;
  }
  .label { font-weight: 800; font-size: 15px; margin-top: 4px; }
  .foot { font-size: 11px; color: #728088; margin-top: 10px; }
  .howto-btn {
    width: 100%; margin-top: 8px; padding: 12px; border-radius: 14px;
    background: #eef2f3; font-size: 13px; font-weight: 800; color: #46545c;
    transition: transform 0.12s;
  }
  .howto-btn:active { transform: scale(0.98); }
  .overlay .panel.rules { text-align: left; max-height: 84dvh; overflow-y: auto; }
  .overlay .panel.rules h2 { text-align: center; margin-top: 0; }
  .overlay .panel.rules .hint { align-items: center; }

  /* header */
  .hrow { display: flex; align-items: center; gap: 8px; }
  .icon-btn {
    background: linear-gradient(180deg, #fff, #eef4f4); border-radius: 50%; width: 36px; height: 36px;
    font-size: 15px; font-weight: 900; color: #46545c;
    box-shadow: 0 2px 6px rgba(20,50,60,0.16), inset 0 1px 0 rgba(255,255,255,0.9);
    transition: transform 0.12s;
  }
  .icon-btn:active { transform: scale(0.92); }
  .score {
    display: flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 900; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
  }
  .score .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.7); transition: opacity 0.3s, box-shadow 0.3s; }
  .score .dot.won { box-shadow: 0 0 8px currentColor, inset 0 0 0 1.5px rgba(255,255,255,0.7); }
  .mid { flex: 1; text-align: center; min-width: 0; }
  .mid .r { font-size: 12px; font-weight: 900; color: #55666e; letter-spacing: 1px; white-space: nowrap; }
  .mid .c { font-size: 10px; font-weight: 800; color: #8a6a30; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mid .c.quiet { color: #8fa0a8; }

  /* turn banner (HUD内) */
  .turn-label { display: flex; align-items: center; gap: 7px; font-weight: 900; font-size: 14px; }
  .turn-label .dot { width: 12px; height: 12px; border-radius: 50%; }
  .ap { display: flex; align-items: center; gap: 5px; margin-left: auto; font-size: 12px; font-weight: 900; color: #66757d; }
  .ap .pip { width: 20px; height: 13px; border-radius: 4px; background: #d5dcdf; }
  .penalty-badge {
    font-size: 11px; font-weight: 900; color: #fff; padding: 6px 10px; border-radius: 999px;
    background: linear-gradient(90deg, #d9503a, #c23c28);
  }
  .items { font-size: 12px; font-weight: 900; color: var(--teal); background: rgba(41,112,127,0.12); padding: 5px 9px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
  .phase { font-size: 11px; font-weight: 900; color: #fff; padding: 5px 9px; border-radius: 999px; background: var(--teal); white-space: nowrap; flex-shrink: 0; }
  .phase.place { background: #b8691e; }

  /* board stage: 画面全体を1枚のトイレの部屋にして、HUD/手札を上に浮かべる */
  .stage {
    position: relative; flex: 1; min-height: 540px; border-radius: 20px; overflow: hidden;
    box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,0.35);
    --dockH: 136px; /* 下に浮かぶ手札ドックのおおよその高さ (設備の接地位置の基準) */
  }
  /* 天井照明のやわらかい光 */
  .stage::before {
    content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none;
    background:
      radial-gradient(130% 62% at 50% -12%, rgba(255,255,255,0.6), rgba(255,255,255,0) 55%),
      radial-gradient(50% 34% at 24% -4%, rgba(255,251,231,0.5), transparent 70%),
      radial-gradient(50% 34% at 76% -4%, rgba(255,251,231,0.5), transparent 70%);
    mix-blend-mode: screen;
  }
  /* 四隅の陰影で奥行きを出す */
  .stage::after {
    content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: 20px;
    box-shadow: inset 0 -26px 46px rgba(18,38,48,0.22), inset 0 30px 54px rgba(18,38,48,0.14),
                inset 34px 0 40px rgba(18,38,48,0.10), inset -34px 0 40px rgba(18,38,48,0.10);
  }
  .room {
    position: absolute; inset: 0;
    --tileW: 54px; --tileH: 36px; --grout: rgba(120,150,155,0.45);
    background-color: #cddee0;
    background-image:
      /* 上からの光の減衰 */
      linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0) 30%, rgba(66,96,102,0.14)),
      /* アクセントタイルの帯 (壁の余白を埋める) */
      linear-gradient(180deg, transparent 0 26%, rgba(45,110,125,0.20) 26% 33%, rgba(45,110,125,0.08) 33% 34.5%, transparent 34.5%),
      /* タイルの面取りハイライト(左上) */
      repeating-linear-gradient(0deg, rgba(255,255,255,0.28) 0 1.5px, transparent 1.5px var(--tileH)),
      repeating-linear-gradient(90deg, rgba(255,255,255,0.28) 0 1.5px, transparent 1.5px var(--tileW)),
      /* 目地(grout) */
      repeating-linear-gradient(0deg, transparent 0 calc(var(--tileH) - 2px), var(--grout) calc(var(--tileH) - 2px) var(--tileH)),
      repeating-linear-gradient(90deg, transparent 0 calc(var(--tileW) - 2px), var(--grout) calc(var(--tileW) - 2px) var(--tileW)),
      linear-gradient(#d6e6e7, #c0d4d6);
  }
  /* 床(奥行きのあるタイル)+ 巾木。手札ドックの裏まで続く */
  .floor {
    position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--dockH) + 62px); z-index: 1; pointer-events: none;
    background:
      linear-gradient(180deg, rgba(0,0,0,0.12), transparent 22%),
      linear-gradient(180deg, #ece2cf 0%, #ddd0b6 60%, #d2c4a6 100%);
    box-shadow: inset 0 4px 8px rgba(255,255,255,0.35);
  }
  .floor::before {
    content: ""; position: absolute; inset: 0;
    background-image: repeating-linear-gradient(90deg, transparent 0 47px, rgba(150,128,90,0.32) 47px 49px);
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 55%);
            mask-image: linear-gradient(180deg, transparent, #000 55%);
  }
  /* 壁と床の境の巾木 */
  .floor::after {
    content: ""; position: absolute; left: 0; right: 0; top: -7px; height: 7px;
    background: linear-gradient(180deg, #b9c9ca, #9db0b2);
    box-shadow: 0 3px 5px rgba(0,0,0,0.20);
  }
  .fixtures {
    position: absolute; left: 0; right: 0; bottom: calc(var(--dockH) + 16px); z-index: 2;
    display: flex; align-items: flex-end; gap: 5px; padding: 0 12px;
  }
  /* 壁の装飾 (サインプレート + ポスター) */
  .wall-decor {
    position: absolute; left: 7%; right: 7%; top: 17%; z-index: 1;
    display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none;
  }
  .wall-decor .plate {
    width: 54px; height: 54px; border-radius: 12px;
    background: linear-gradient(180deg, #ffffff, #e8f0f1);
    display: flex; align-items: center; justify-content: center; font-size: 30px;
    box-shadow: 0 3px 7px rgba(20,50,60,0.20), inset 0 0 0 2px rgba(150,175,180,0.35);
  }
  .wall-decor .poster {
    transform: rotate(1.6deg); text-align: center;
    background: #fffef5; border-radius: 6px; padding: 9px 14px 8px;
    color: #3d4c54; box-shadow: 0 3px 8px rgba(20,50,60,0.22);
    border-bottom: 4px solid rgba(200,190,150,0.55);
  }
  .wall-decor .poster .big { font-size: 16px; font-weight: 900; letter-spacing: 3px; }
  .wall-decor .poster .small { font-size: 8.5px; font-weight: 700; color: #74838b; margin-top: 3px; letter-spacing: 0.5px; }
  /* 部屋の上に浮かぶHUD */
  .hud-top, .hud-turn, .dock2 {
    position: absolute; z-index: 8;
    background: var(--paper);
    -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid var(--paper-brd);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.6);
  }
  .hud-top { top: 10px; left: 10px; right: 10px; border-radius: 16px; padding: 7px 9px; }
  .hud-turn { top: 66px; left: 10px; right: 10px; border-radius: 14px; padding: 7px 12px 8px; }
  .hud-turn .row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .hud-turn .row2 { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 11px; font-weight: 800; color: #5b6b73; }
  .hud-turn .row2 .warn.danger { color: #c23c28; font-weight: 900; }
  .dock2 { left: 8px; right: 8px; bottom: 8px; z-index: 9; border-radius: 18px; padding: 8px 10px 10px; box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.6); }
  .wall-divider {
    width: 10px; height: 208px; margin: 0 6px; flex-shrink: 0; border-radius: 3px;
    background: linear-gradient(90deg, #eef4f4 0 15%, #c3d3d4 45%, #90a5a7 100%);
    box-shadow: 2px 0 6px rgba(20,50,60,0.25), inset 1px 0 0 rgba(255,255,255,0.6);
  }
  .person-svg, .person-img, .sign-svg, .sign-wrap, .fixture-svg, .fixture-img, .ground-shadow, .fin { pointer-events: none; }
  /* 個室 */
  .stallbox { width: 100px; max-width: 17%; position: relative; flex-shrink: 0; }
  .stallbox .door-btn { background: none; padding: 0; display: block; width: 100%; }
  .stallbox .door-svg { width: 100%; display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.22)); }
  .stallbox .stall-meta {
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%); z-index: 4;
    display: flex; align-items: center; gap: 4px; white-space: nowrap;
    background: rgba(255,255,255,0.95); border-radius: 999px; padding: 3px 8px;
    font-size: 9px; font-weight: 900; color: #3d4c54; box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  }
  .stall-meta .dot { width: 7px; height: 7px; border-radius: 50%; }
  .stallbox.hl::after {
    content: ""; position: absolute; inset: -3px; border-radius: 10px; pointer-events: none;
    border: 2.5px solid rgba(120,215,215,0.95); box-shadow: 0 0 16px rgba(90,200,205,0.6);
    animation: glow 1.1s ease-in-out infinite;
  }
  .knock-fab {
    position: absolute; right: -9px; bottom: 54px; z-index: 5;
    width: 42px; height: 42px; border-radius: 50%;
    background: #fff; border: 2px solid #d6a04a; font-size: 17px;
    box-shadow: 0 3px 9px rgba(0,0,0,0.3);
    animation: glow 1.4s ease-in-out infinite;
  }
  /* 小便器 */
  .urinal { flex: 1; background: none; padding: 0; position: relative; height: 208px; min-width: 0; }
  .urinal .fin { position: absolute; left: -4px; top: 48px; bottom: 40px; width: 5px; border-radius: 3px; background: linear-gradient(90deg, #eef5f6, #bfd2d5); }
  .urinal .fixture-svg, .urinal .fixture-img { position: absolute; left: 50%; transform: translateX(-50%); bottom: 60px; width: 86%; max-width: 60px; }
  .urinal .fixture-img.closed { filter: grayscale(0.85) brightness(0.95); }
  .urinal .fixture-img.stained { filter: sepia(0.4) saturate(1.4) brightness(0.94); }
  .urinal .bubble.durability { background: #fff3d6; color: #8a6a30; }
  .urinal .person-svg, .urinal .person-img { position: absolute; left: 50%; transform: translateX(-50%); bottom: 6px; height: 158px; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.28)); z-index: 2; }
  .urinal .sign-svg, .urinal .sign-wrap { position: absolute; left: 50%; transform: translateX(-50%); bottom: 5px; height: 94px; z-index: 2; }
  .sign-wrap img { height: 100%; display: block; }
  .sign-wrap .sign-label {
    position: absolute; top: 42%; left: 50%; transform: translateX(-50%);
    font-size: 11px; font-weight: 900; color: #6b4e0e; white-space: nowrap;
    text-shadow: 0 0 3px rgba(255,255,255,0.9);
  }
  .urinal .ground-shadow {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    width: 76%; height: 10px; border-radius: 50%; z-index: 1;
    background: radial-gradient(ellipse, rgba(20,35,40,0.32), transparent 68%);
  }
  .urinal .bubble {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 4;
    background: #fff; border-radius: 999px; font-size: 9px; font-weight: 900; padding: 3px 7px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.18); white-space: nowrap;
  }
  .urinal .tag { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 9px; font-weight: 900; color: #4f6269; z-index: 3; }
  .urinal.hl::after {
    content: ""; position: absolute; inset: 34px 2px 10px; border-radius: 16px; pointer-events: none;
    border: 2px solid rgba(64,192,198,0.92);
    background: radial-gradient(120% 85% at 50% 100%, rgba(96,214,218,0.28), transparent 68%);
    box-shadow: 0 0 22px rgba(60,192,198,0.55), inset 0 0 18px rgba(124,228,230,0.35);
    animation: glow 1.2s ease-in-out infinite;
  }
  .urinal.blocked-neighbor::after {
    content: ""; position: absolute; inset: 34px 2px 10px; border-radius: 16px; pointer-events: none;
    border: 2px solid rgba(203,70,55,0.72);
    background: radial-gradient(120% 85% at 50% 100%, rgba(218,78,58,0.15), transparent 68%);
    box-shadow: 0 0 12px rgba(203,70,55,0.24), inset 0 0 14px rgba(218,78,58,0.12);
  }
  .urinal .neighbor-warning {
    position: absolute; top: 38px; left: 50%; transform: translateX(-50%); z-index: 5;
    display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
    padding: 3px 6px; border-radius: 999px; background: rgba(255,244,241,0.96);
    border: 1px solid rgba(203,70,55,0.55); color: #b73529; font-size: 9px; font-weight: 900;
    box-shadow: 0 2px 6px rgba(70,20,15,0.16); pointer-events: none;
  }
  .urinal .neighbor-warning .x { font-size: 12px; line-height: 1; }
  @keyframes glow { 50% { box-shadow: 0 0 6px rgba(38,150,160,0.25); opacity: 0.72; } }
  /* キャラのゆらぎ(待機モーション) */
  @keyframes bob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-2.5px); } }
  .urinal .person-img, .urinal .person-svg { animation: bob 3.6s ease-in-out infinite; }
  @media (max-width: 480px) {
    #app { padding: 8px; }
    .card { padding: 10px; border-radius: 16px; }
    .hrow { gap: 5px; }
    .icon-btn { width: 32px; height: 32px; font-size: 14px; }
    .score { padding: 6px 9px; font-size: 11px; gap: 4px; }
    .score .dot { width: 8px; height: 8px; }
    .mid { overflow: hidden; }
    .mid .r { font-size: 11px; }
    .hand { gap: 5px; }
    .hcard { padding: 6px; min-height: 54px; }
    .stage { min-height: 500px; --dockH: 118px; }
    .hud-top { top: 8px; left: 8px; right: 8px; padding: 6px 7px; }
    .hud-turn { top: 58px; left: 8px; right: 8px; padding: 6px 10px 7px; }
    .hud-turn .row1 { gap: 6px; }
    .turn-label { font-size: 12px; }
    .items, .phase { font-size: 10px; padding: 4px 7px; }
    .fixtures { gap: 2px; padding: 0 6px; }
    .stallbox { width: 68px; max-width: 20%; }
    .wall-divider { height: 148px; margin: 0 3px; }
    .urinal { height: 156px; }
    .urinal .person-svg, .urinal .person-img { height: 114px; }
    .urinal .sign-svg, .urinal .sign-wrap { height: 70px; }
    .sign-wrap .sign-label { font-size: 8px; }
    .urinal .fixture-svg, .urinal .fixture-img { bottom: 46px; }
    .urinal.hl::after { inset: 28px 0 10px; }
    .urinal.blocked-neighbor::after { inset: 28px 0 10px; }
    .urinal .neighbor-warning { top: 28px; padding: 2px 4px; font-size: 8px; }
    .urinal .neighbor-warning .x { font-size: 10px; }
    .knock-fab { width: 36px; height: 36px; bottom: 38px; right: -6px; font-size: 14px; }
    #fx-stack { top: 112px; }
    .wall-decor { top: 27%; }
    .wall-decor .plate { width: 44px; height: 44px; font-size: 24px; }
    .wall-decor .poster .big { font-size: 13px; }
    .wall-decor .poster .small { font-size: 7.5px; }
  }
  .logline { font-size: 11px; font-weight: 800; color: #46545c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* dock */
  .dock-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .dock-top .logline { flex: 1; min-width: 0; }
  .guide { font-size: 11px; font-weight: 800; color: #66757d; flex: 1; }
  .end-btn { padding: 9px 16px; border-radius: 11px; color: #fff; font-size: 13px; font-weight: 900; }
  .end-btn:disabled { opacity: 0.4; }
  .hand { display: grid; gap: 7px; }
  .hand.before-placement { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .hand.after-placement { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hcard {
    position: relative; text-align: left; padding: 8px 7px; border-radius: 14px;
    border: 1px solid rgba(30,60,70,0.10);
    display: flex; flex-direction: column; gap: 3px; min-height: 68px; background: #fff;
    min-width: 0; box-shadow: 0 2px 5px rgba(20,50,60,0.10), inset 0 1px 0 rgba(255,255,255,0.85);
    transition: transform 0.14s cubic-bezier(0.2,1.3,0.4,1), box-shadow 0.14s, border-color 0.14s;
  }
  .hcard::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 42%; border-radius: 14px 14px 40% 40%;
    background: linear-gradient(180deg, rgba(255,255,255,0.6), transparent); pointer-events: none;
  }
  .hcard .t, .hcard .s { white-space: nowrap; }
  .hcard .top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
  .hcard .top > span:first-child {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 9px; font-size: 15px;
    background: rgba(255,255,255,0.75); box-shadow: 0 1px 3px rgba(0,0,0,0.14), inset 0 0 0 1px rgba(255,255,255,0.6);
  }
  .hcard .cost { font-size: 9px; font-weight: 900; color: #46545c; background: rgba(20,50,60,0.10); border-radius: 999px; padding: 3px 6px; }
  .hcard .t { font-size: 12px; font-weight: 900; }
  .hcard .s { font-size: 9px; font-weight: 700; color: #74838b; }
  .hcard .info {
    display: inline-flex; align-items: center; justify-content: center;
    width: 17px; height: 17px; border-radius: 50%; flex-shrink: 0;
    background: rgba(20,50,60,0.10); color: #5b6b73; font-size: 10.5px; font-weight: 900;
  }
  .hcard .info:active { background: rgba(20,50,60,0.22); }
  .hcard.sel {
    border-color: var(--teal); transform: translateY(-6px);
    box-shadow: 0 0 0 2px rgba(41,112,127,0.4), 0 10px 20px rgba(20,50,60,0.22), inset 0 1px 0 rgba(255,255,255,0.85);
  }
  .hcard.sel::after {
    content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
    width: 22px; height: 4px; border-radius: 999px; background: var(--teal); opacity: 0.55;
  }
  .hcard.dim { opacity: 0.4; filter: saturate(0.6); }
  .hcard.c-quick { background: linear-gradient(150deg, #dbf1fa, #fff 75%); }
  .hcard.c-steady { background: linear-gradient(150deg, #bfe6ef, #fff 75%); }
  .hcard.c-fake { background: linear-gradient(150deg, #fdefcf, #fff 75%); }
  .hcard.c-real { background: linear-gradient(150deg, #e9d5c0, #fff 75%); }
  .hcard.c-knock { background: linear-gradient(150deg, #fbdcd5, #fff 75%); }
  .hcard.c-mop { background: linear-gradient(150deg, #daf3e4, #fff 75%); }

  /* overlay & toast */
  .overlay {
    position: fixed; inset: 0; background: rgba(10,25,30,0.55);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20;
    animation: fade 0.3s ease;
  }
  @keyframes fade { from { opacity: 0; } }
  .overlay .panel {
    position: relative; overflow: hidden;
    background: linear-gradient(180deg, #ffffff, #f4f8f9); border-radius: 26px; padding: 28px 26px;
    max-width: 350px; width: 100%; text-align: center;
    box-shadow: 0 24px 60px rgba(8,30,40,0.4), inset 0 1px 0 rgba(255,255,255,0.9);
    animation: pop 0.4s cubic-bezier(0.2,1.4,0.4,1);
  }
  @keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.9); } }
  /* パネル上部の色帯 */
  .overlay .panel::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, var(--accent, var(--teal)), color-mix(in srgb, var(--accent, var(--teal)) 55%, #fff));
  }
  .overlay .emoji { font-size: 52px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15)); animation: trophy 1.4s ease-in-out infinite; }
  @keyframes trophy { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
  .overlay h2 { font-size: 23px; font-weight: 900; margin-top: 10px; letter-spacing: -0.5px; }
  .overlay p { font-size: 13px; font-weight: 600; color: #66757d; margin-top: 8px; line-height: 1.5; }
  .overlay .primary { width: 100%; margin-top: 18px; padding: 14px; border-radius: 14px; color: #fff; font-size: 14px; font-weight: 900; box-shadow: 0 6px 16px rgba(20,50,60,0.25); transition: transform 0.12s; }
  .overlay .primary:active { transform: scale(0.97); }
  .overlay .secondary { width: 100%; margin-top: 8px; padding: 12px; border-radius: 14px; background: #eef2f3; font-size: 13px; font-weight: 800; color: #46545c; }
  .overlay.handoff {
    z-index: 60; background: linear-gradient(155deg, #16333d, #10272f 58%, #1c3e48);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .overlay.handoff .panel { max-width: 330px; }
  .handoff-mark {
    width: 74px; height: 74px; margin: 2px auto 12px; border-radius: 50%;
    display: grid; place-items: center; color: #fff; font-size: 34px;
    box-shadow: 0 10px 24px rgba(10,25,30,0.28), inset 0 0 0 4px rgba(255,255,255,0.28);
  }
  /* 紙吹雪 */
  #confetti { position: fixed; inset: 0; z-index: 21; pointer-events: none; overflow: hidden; }
  #confetti i {
    position: absolute; top: -6vh; width: 9px; height: 14px; border-radius: 2px;
    animation: fall linear forwards;
  }
  @keyframes fall {
    to { transform: translateY(112vh) rotate(720deg); opacity: 0.9; }
  }
  #toast {
    position: fixed; bottom: 165px; left: 50%; transform: translateX(-50%);
    max-width: 88vw; text-align: center; line-height: 1.5;
    background: rgba(20,30,35,0.88); color: #fff; font-size: 12px; font-weight: 800;
    padding: 10px 16px; border-radius: 18px; z-index: 30; pointer-events: none;
    opacity: 0; transition: opacity 0.25s;
  }
  #toast.show { opacity: 1; }

  /* 演出バナー */
  #fx-stack {
    position: fixed; top: 128px; left: 50%; transform: translateX(-50%); z-index: 40;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none; width: max-content; max-width: 92vw;
  }
  .fx-banner {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.97); border-radius: 999px; padding: 10px 20px;
    font-size: 15px; font-weight: 900; color: var(--ink);
    box-shadow: 0 8px 24px rgba(10,40,50,0.28);
    animation: fxin 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
    max-width: 92vw;
  }
  .fx-banner .fx-icon { font-size: 22px; }
  .fx-banner.gold {
    background: linear-gradient(90deg, #fff6d8, #ffe9a8);
    box-shadow: 0 8px 26px rgba(220,160,20,0.5);
  }
  .fx-banner.red {
    background: linear-gradient(90deg, #ffe3dc, #ffc9bd);
    box-shadow: 0 8px 26px rgba(200,60,30,0.45);
  }
  .fx-banner.out { opacity: 0; transform: translateY(-10px); transition: all 0.3s; }
  @keyframes fxin { from { opacity: 0; transform: translateY(-16px) scale(0.85); } }

  .door-btn.shaking { animation: doorshake 0.13s linear infinite; }
  @keyframes doorshake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-3px) rotate(-0.6deg); }
    75% { transform: translateX(3px) rotate(0.6deg); }
    100% { transform: translateX(0); }
  }

  .end-btn.pulse { animation: endpulse 1s ease-in-out infinite; }
  @keyframes endpulse {
    50% { transform: scale(1.07); box-shadow: 0 0 18px rgba(30,90,110,0.65); }
  }
  @media (max-width: 480px) {
    .fx-banner { font-size: 12px; padding: 8px 14px; }
    .fx-banner .fx-icon { font-size: 17px; }
  }

  /* ===== ロゴ ===== */
  .logo-svg, .logo-img { display: block; width: min(100%, 330px); height: auto; position: relative; filter: drop-shadow(0 5px 12px rgba(0,0,0,0.35)); }

  /* ヒーローに立ちのぼる泡 */
  .hero .bub {
    position: absolute; bottom: -26px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle at 32% 30%, rgba(255,255,255,0.95), rgba(255,255,255,0.25) 55%, rgba(255,255,255,0.06));
    animation: rise linear infinite;
  }
  .hero .bub:nth-of-type(1) { left: 10%; width: 13px; height: 13px; animation-duration: 6.5s; }
  .hero .bub:nth-of-type(2) { left: 32%; width: 8px; height: 8px; animation-duration: 5.2s; animation-delay: 1.4s; }
  .hero .bub:nth-of-type(3) { left: 68%; width: 16px; height: 16px; animation-duration: 7.4s; animation-delay: 0.6s; }
  .hero .bub:nth-of-type(4) { left: 87%; width: 10px; height: 10px; animation-duration: 5.8s; animation-delay: 2.4s; }
  @keyframes rise {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    12% { opacity: 0.9; }
    100% { transform: translateY(-150px) translateX(12px); opacity: 0; }
  }
  /* スタートボタンの光沢スイープ */
  .start-btn::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: -45%; width: 32%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,0.38), transparent);
    transform: skewX(-18deg); animation: sheen 3.4s ease-in-out infinite;
  }
  @keyframes sheen { 0%, 55% { left: -45%; } 100% { left: 130%; } }

  /* ===== ハンドカードのSVGアイコン ===== */
  .hcard .top > span:first-child svg { width: 19px; height: 19px; display: block; overflow: visible; }
  .hcard.sel .top > span:first-child { animation: wiggle 1s ease-in-out infinite; }
  @keyframes wiggle { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }

  /* ===== 配置・モップ・ノックの演出 ===== */
  @keyframes arrive {
    0% { transform: translateX(-50%) translateY(-32px) scale(0.7); opacity: 0; }
    60% { transform: translateX(-50%) translateY(3px) scale(1.06); opacity: 1; }
    100% { transform: translateX(-50%) translateY(0) scale(1); }
  }
  .urinal .person-img.arrive, .urinal .person-svg.arrive {
    animation: arrive 0.5s cubic-bezier(0.25, 1.1, 0.4, 1), bob 3.6s ease-in-out 0.55s infinite;
  }
  @keyframes doorpop { 0% { transform: scale(0.92); } 55% { transform: scale(1.05); } 100% { transform: scale(1); } }
  .door-btn.arrive { animation: doorpop 0.42s ease; }
  .mop-spark { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
  .mop-spark i { position: absolute; font-style: normal; font-size: 15px; opacity: 0; animation: spark 0.95s ease forwards; }
  @keyframes spark {
    0% { transform: translateY(8px) scale(0.4) rotate(-15deg); opacity: 0; }
    30% { opacity: 1; }
    100% { transform: translateY(-30px) scale(1.2) rotate(15deg); opacity: 0; }
  }
  @keyframes quake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-4px, 2px); }
    35% { transform: translate(4px, -2px); }
    55% { transform: translate(-3px, -1px); }
    75% { transform: translate(2px, 1px); }
  }
  #app.quake { animation: quake 0.45s linear; }

  /* ===== 勝敗オーバーレイのキャラ ===== */
  .result-scene {
    position: relative; height: 138px; margin-top: 4px;
    display: flex; align-items: flex-end; justify-content: center; gap: 4px;
  }
  .result-scene .burst {
    position: absolute; left: 50%; top: 55%; width: 300px; height: 300px;
    transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
    background: repeating-conic-gradient(color-mix(in srgb, var(--accent, var(--teal)) 15%, transparent) 0 11deg, transparent 11deg 26deg);
    -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%);
            mask-image: radial-gradient(circle, #000 20%, transparent 68%);
    animation: spinslow 18s linear infinite;
  }
  @keyframes spinslow { to { transform: translate(-50%, -50%) rotate(360deg); } }
  .person-result { position: relative; height: 100%; width: auto; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.18)); animation: winpop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1); }
  img.person-result { height: 100%; }
  .person-result.lose-art { height: 76%; transform-origin: 50% 92%; animation: losewob 2.2s ease-in-out infinite; }
  @keyframes winpop { from { transform: translateY(24px) scale(0.5); opacity: 0; } }
  @keyframes losewob { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }

  /* ===== 楽しさポリッシュv3: VS対面 / 臭気 / 擬音 / 緊迫演出 / 洗面台 / 効果音UI ===== */
  /* メニューの VS 対面シーン */
  .vs-scene { position: relative; display: flex; justify-content: center; align-items: flex-end; gap: 38px; height: 112px; margin-top: 18px; }
  .vs-scene .mirror { display: block; height: 100%; transform: scaleX(-1); }
  .vs-scene .person-result { height: 100%; }
  .vs-badge {
    position: absolute; left: 50%; top: 36%; z-index: 2;
    font-size: 27px; font-weight: 900; font-style: italic; color: #ffd75e; letter-spacing: 1px;
    text-shadow: -2px 0 0 #14313d, 2px 0 0 #14313d, 0 -2px 0 #14313d, 0 2px 0 #14313d, 0 5px 12px rgba(0,0,0,0.45);
    transform: translate(-50%, -50%) rotate(-7deg);
    animation: vspulse 1.5s ease-in-out infinite;
  }
  @keyframes vspulse { 50% { transform: translate(-50%, -50%) rotate(-7deg) scale(1.16); } }

  /* 使用済み・閉鎖設備から立ちのぼる臭気 */
  .stink { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 3; pointer-events: none; }
  .urinal .stink { top: 30px; }
  .stallbox .stink { top: 34px; z-index: 5; }
  .stink i {
    width: 4px; height: 17px; border-radius: 4px;
    background: linear-gradient(180deg, rgba(130,165,90,0), rgba(118,148,78,0.72));
    animation: stinkup 1.8s ease-in-out infinite;
  }
  .stink i:nth-child(2) { height: 21px; animation-delay: 0.6s; }
  .stink i:nth-child(3) { animation-delay: 1.2s; }
  @keyframes stinkup {
    0% { transform: translateY(9px) skewX(10deg) scaleY(0.5); opacity: 0; }
    35% { transform: translateY(0) skewX(-10deg) scaleY(1); opacity: 0.85; }
    100% { transform: translateY(-15px) skewX(10deg) scaleY(1.1); opacity: 0; }
  }

  /* コミック風の擬音ポップ */
  .comic-pop {
    position: absolute; z-index: 6; pointer-events: none; white-space: nowrap;
    font-size: 12px; font-weight: 900; color: var(--ink);
    background: #fff; border: 2px solid #24303a; border-radius: 10px; padding: 3px 8px;
    box-shadow: 0 3px 7px rgba(0,0,0,0.25);
  }
  .knock-pop { top: 22px; right: -12px; transform: rotate(7deg); animation: popin 0.4s cubic-bezier(0.2,1.6,0.4,1) both; }
  .door-pop { top: 34px; left: 50%; transform: translateX(-50%) rotate(-5deg); animation: peefade 1.7s ease both; }
  .pee-pop { top: 40px; left: 50%; transform: translateX(-50%) rotate(-5deg); font-size: 11px; animation: peefade 1.9s ease both; }
  @keyframes popin { from { opacity: 0; transform: rotate(7deg) scale(0.4); } }
  @keyframes peefade {
    0% { opacity: 0; transform: translateX(-50%) rotate(-5deg) scale(0.55); }
    12% { opacity: 1; transform: translateX(-50%) rotate(-5deg) scale(1.06); }
    72% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-9px) rotate(-5deg); }
  }

  /* 手番HUDのプレイヤー色アクセント */
  .hud-turn { border-left: 5px solid transparent; transition: border-color 0.25s; }

  /* 置ける場所が残りわずか: 部屋のふちが赤く脈打つ */
  .stage .veil {
    position: absolute; inset: 0; z-index: 7; pointer-events: none; border-radius: 20px;
    box-shadow: inset 0 0 0 3px rgba(217,80,58,0.5), inset 0 0 64px rgba(217,80,58,0.26);
    animation: dangerpulse 1.15s ease-in-out infinite;
  }
  @keyframes dangerpulse { 50% { box-shadow: inset 0 0 0 2px rgba(217,80,58,0.2), inset 0 0 30px rgba(217,80,58,0.1); } }

  /* NPC思考中のドット */
  .think-dots i { display: inline-block; font-style: normal; animation: thinkdot 1.2s infinite; }
  .think-dots i:nth-child(2) { animation-delay: 0.18s; }
  .think-dots i:nth-child(3) { animation-delay: 0.36s; }
  @keyframes thinkdot { 0%, 60%, 100% { opacity: 0.2; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

  /* 壁の洗面台+鏡 */
  .wall-decor .sink-svg { width: 86px; filter: drop-shadow(0 4px 6px rgba(20,50,60,0.22)); }

  /* 王手 (あと1ラウンドで勝利) の王冠 */
  .score .crown { font-size: 12px; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }

  /* 効果音トグル (手札ドック内) */
  .dock-top .icon-btn { width: 34px; height: 34px; font-size: 14px; flex-shrink: 0; }

  @media (max-width: 480px) {
    .vs-scene { height: 96px; gap: 24px; }
    .vs-badge { font-size: 21px; }
    .urinal .stink { top: 22px; }
    .stink i { height: 13px; }
    .stink i:nth-child(2) { height: 16px; }
    .wall-decor .sink-svg { width: 60px; }
    .comic-pop { font-size: 10px; padding: 2px 6px; }
    .dock-top .icon-btn { width: 30px; height: 30px; font-size: 12px; }
  }
  @media (max-width: 360px) {
    .dock2 { padding-inline: 7px; }
    .hand { gap: 4px; }
    .hcard { padding: 6px 4px; min-height: 60px; }
    .hcard .top { gap: 2px; }
    .hcard .top > span:first-child { width: 22px; height: 22px; border-radius: 7px; }
    .hcard .info { width: 14px; height: 14px; font-size: 9px; }
    .hcard .t { font-size: 11px; letter-spacing: -0.3px; }
    .score { padding-inline: 6px; font-size: 10px; }
    .mid .r { font-size: 10px; letter-spacing: 0; }
    .mid .c { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      scroll-behavior: auto !important;
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
    .hero .bub, .start-btn::after, #confetti, .result-scene .burst { display: none !important; }
  }
