
  :root {
    --washi: #f4ece0;
    --washi-dark: #e6d8c3;
    --card: #fbf7ef;
    --ink: #2c241d;
    --ink-sub: #6c5f52;
    --vermilion: #c9472e;
    --vermilion-dark: #9c301c;
    --gold: #d99b26;
    --gold-light: #ffdf85;
    --forest: #2f5e46;
    --forest-light: #478564;
    --indigo: #293859;
    --night: #162036;
    --border: #d5c5ab;
    --shadow: 0 4px 16px rgba(44, 36, 29, 0.13);
    --font: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif;
    --font-ui: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  }

  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  html, body {
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    background: var(--washi);
    color: var(--ink);
    font-family: var(--font-ui);
    background-image:
      radial-gradient(circle at 15% 10%, rgba(217, 155, 38, 0.09), transparent 42%),
      radial-gradient(circle at 85% 90%, rgba(47, 94, 70, 0.09), transparent 45%);
  }

  button {
    font-family: inherit;
  }

  /* トップバー */
  #topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: linear-gradient(180deg, #2d221c 0%, #201712 100%);
    color: #fdf7ec;
    border-bottom: 3px solid var(--vermilion);
    padding: 8px 12px;
    box-shadow: 0 3px 14px rgba(18, 12, 8, 0.28);
  }

  .topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
  }

  .brand-title {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #fff6e5;
  }

  .rank-chip {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(217, 155, 38, 0.25);
    border: 1px solid rgba(255, 223, 133, 0.55);
    color: var(--gold-light);
    margin-left: 4px;
  }

  .hud-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
  }

  .stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 248, 236, 0.1);
    border: 1px solid rgba(255, 223, 133, 0.35);
    border-radius: 999px;
    padding: 4px 11px;
  }

  .stat-pill.virtue-pill {
    border-color: rgba(138, 228, 185, 0.45);
    background: rgba(47, 94, 70, 0.35);
  }

  .stat-label {
    font-size: 10.5px;
    color: #dfd0ba;
    font-weight: 700;
  }

  .stat-value {
    font-size: 15.5px;
    font-weight: 900;
    color: var(--gold-light);
    font-variant-numeric: tabular-nums;
  }

  .virtue-pill .stat-value {
    color: #a9f0c8;
  }

  .stat-sub {
    font-size: 11px;
    color: #a9e5c1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .phase-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 800;
  }

  .phase-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffd466;
    box-shadow: 0 0 8px #ffd466;
  }

  .phase-bar-wrap {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    overflow: hidden;
  }

  .phase-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--gold-light);
    transition: width 0.25s linear;
  }

  .top-actions {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .btn-top {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
    color: #f3e7d5;
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }
  .btn-top:hover {
    background: rgba(217, 155, 38, 0.28);
    border-color: var(--gold-light);
  }
  .btn-top.danger:hover {
    background: rgba(201, 71, 46, 0.42);
    border-color: #f08a75;
  }

  /* メインレイアウト */
  #main-layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1.42fr) minmax(320px, 1fr);
    gap: 14px;
    align-items: start;
  }

  .col-left, .col-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .card {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 13px;
    background: linear-gradient(180deg, #f3e7d3 0%, #eadbc2 100%);
    border-bottom: 1px solid var(--border);
  }

  .card-title {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 800;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .card-note {
    font-size: 11px;
    color: var(--ink-sub);
    font-weight: 700;
  }

  /* 境内ビュー（写真イラスト背景 ＋ 灯籠グロー ＋ SVG前景） */
  #shrine-stage-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 800 / 430;
    background: #162036;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
  }

  #bg-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
  }

  #bg-cover-frame {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
  }

  .bg-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
    pointer-events: none;
    will-change: opacity;
  }

  #bg-img-day   { z-index: 1; opacity: 1; }
  #bg-img-dusk  { z-index: 2; opacity: 0; }
  #bg-img-night { z-index: 3; opacity: 0; }

  /* 提灯（灯籠）グローレイヤー：背景画像と同一フレーム内に配置し座標変換を完全一致 */
  #bg-lantern-glows {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
  }

  .lantern-point {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    transition: opacity 0.45s ease;
  }

  .lantern-window-halo {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(var(--glow-size, 110px) * var(--l-scale, 1));
    height: calc(var(--glow-size, 110px) * var(--l-scale, 1));
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
      circle,
      rgba(255, 232, 150, 0.92) 0%,
      rgba(255, 174, 72, 0.56) 28%,
      rgba(255, 130, 46, 0.20) 60%,
      rgba(255, 112, 34, 0) 100%
    );
    animation: lanternFlicker 3.2s ease-in-out infinite;
  }

  .lantern-window-core {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(var(--core-size, 24px) * var(--l-scale, 1));
    height: calc(var(--core-size, 28px) * var(--l-scale, 1));
    transform: translate(-50%, -50%);
    border-radius: 42%;
    background: radial-gradient(
      ellipse at center,
      rgba(255, 250, 218, 0.98) 0%,
      rgba(255, 214, 110, 0.85) 45%,
      rgba(255, 152, 56, 0) 100%
    );
  }

  .lantern-ground-pool {
    position: absolute;
    left: 0;
    top: calc(var(--pool-drop, 54px) * var(--l-scale, 1));
    width: calc(var(--pool-w, 76px) * var(--l-scale, 1));
    height: calc(var(--pool-h, 24px) * var(--l-scale, 1));
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
      ellipse at center,
      rgba(255, 206, 112, 0.52) 0%,
      rgba(255, 154, 64, 0.22) 52%,
      rgba(255, 130, 42, 0) 100%
    );
  }

  @keyframes lanternFlicker {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.06); }
  }

  /* 祭り開催中の全体グロー強調 */
  #bg-festival-glow {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0;
    background: radial-gradient(
      ellipse at 52% 52%,
      rgba(255, 202, 108, 0.34) 0%,
      rgba(255, 142, 66, 0.16) 45%,
      rgba(255, 110, 40, 0) 78%
    );
    transition: opacity 0.6s ease;
  }

  /* 前景SVG（屋台・追加施設・来訪者・蛍・花火） */
  #shrine-svg {
    position: relative;
    z-index: 6;
    display: block;
    width: 100%;
    height: 100%;
  }

  .stage-hint {
    position: absolute;
    left: 10px;
    bottom: 8px;
    z-index: 12;
    background: rgba(24, 18, 14, 0.72);
    color: #fff6e5;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 223, 133, 0.35);
    pointer-events: none;
  }

  .night-status-badge {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 12;
    background: rgba(20, 26, 44, 0.76);
    color: #ffe8b0;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 212, 112, 0.4);
    pointer-events: none;
  }

  /* アクティブイベントバナー（境内上部左） */
  #active-event-banner {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 13;
    display: none;
    align-items: center;
    gap: 7px;
    background: linear-gradient(90deg, rgba(168, 48, 28, 0.92), rgba(217, 155, 38, 0.92));
    color: #fffaf0;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1.5px solid #ffebb3;
    font-size: 11.5px;
    font-weight: 900;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    pointer-events: none;
  }
  #active-event-banner.show {
    display: inline-flex;
  }

  /* 迷子の妖怪クリック可能バナー */
  #stray-yokai-btn {
    position: absolute;
    left: 50%;
    bottom: 42px;
    transform: translateX(-50%);
    z-index: 14;
    display: none;
    align-items: center;
    gap: 7px;
    border: 2px solid #9df2c6;
    background: rgba(22, 54, 40, 0.92);
    color: #ecfff5;
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 12.5px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    animation: pulseSoft 1.2s ease-in-out infinite;
  }
  #stray-yokai-btn.show {
    display: inline-flex;
  }

  @keyframes pulseSoft {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
  }

  .float-coin {
    position: absolute;
    font-size: 14px;
    font-weight: 900;
    color: #fff4c2;
    text-shadow: 0 2px 6px rgba(24, 14, 6, 0.9), 0 0 8px rgba(255, 196, 66, 0.7);
    pointer-events: none;
    animation: floatUp 0.85s ease-out forwards;
    z-index: 15;
  }

  @keyframes floatUp {
    0% { opacity: 1; transform: translate(-50%, 0) scale(0.95); }
    100% { opacity: 0; transform: translate(-50%, -34px) scale(1.1); }
  }

  @keyframes fireflyFloat {
    0%, 100% { transform: translate(0, 0); opacity: 0.28; }
    50% { transform: translate(6px, -8px); opacity: 0.95; }
  }
  .firefly { animation: fireflyFloat 3.2s ease-in-out infinite; }

  /* 右カラムタブナビゲーション */
  .tab-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    background: #e9dcc6;
    padding: 5px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
  }

  .tab-btn {
    position: relative;
    border: none;
    border-radius: 9px;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 800;
    color: var(--ink-sub);
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .tab-btn.active {
    background: var(--card);
    color: var(--vermilion-dark);
    box-shadow: 0 2px 6px rgba(44, 36, 29, 0.12);
  }

  .tab-pane {
    display: none;
    flex-direction: column;
    gap: 10px;
  }
  .tab-pane.active {
    display: flex;
  }

  /* 施設リスト */
  .facility-list {
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
  }

  .fac-item {
    background: #fffdf8;
    border: 1.5px solid #dfd1ba;
    border-radius: 11px;
    padding: 10px 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .fac-item.can-buy { border-color: #d6a249; }
  .fac-item.locked {
    opacity: 0.65;
    background: #f2eadc;
    border-style: dashed;
  }

  .fac-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .fac-id {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .fac-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(44, 36, 29, 0.14);
    background: #f7ebd4;
    overflow: hidden;
    padding: 2px;
  }

  .fac-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    pointer-events: none;
  }

  .fac-name {
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 800;
    color: var(--ink);
  }

  .fac-tag {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 4px;
    vertical-align: middle;
  }
  .tag-common { background: #f7e4b6; color: #7a520b; }
  .tag-lively { background: #f8d5cc; color: #8c2817; }
  .tag-quiet  { background: #cfe8d9; color: #1e4d36; }
  .tag-grand  { background: #d6dff2; color: #22355c; }

  .fac-lv {
    font-size: 12px;
    font-weight: 900;
    color: var(--vermilion-dark);
    background: #f5e9d6;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .fac-desc {
    font-size: 11px;
    color: var(--ink-sub);
    line-height: 1.45;
  }

  .fac-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .fac-rate {
    font-size: 11px;
    font-weight: 800;
    color: var(--forest);
  }

  .btn-buy {
    border: none;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 900;
    color: #fffaf0;
    background: linear-gradient(180deg, #d45238 0%, #b13922 100%);
    box-shadow: 0 3px 0 #7b2313;
    cursor: pointer;
    white-space: nowrap;
  }
  .btn-buy:hover:not(:disabled) { filter: brightness(1.07); }
  .btn-buy:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #7b2313; }
  .btn-buy:disabled {
    background: #bfb5a4;
    color: #f6f1e8;
    box-shadow: 0 2px 0 #998e7c;
    cursor: not-allowed;
  }

  /* 祭り・遷宮カード */
  .festival-card {
    background: linear-gradient(180deg, #fff8e6 0%, #f6e7c8 100%);
    border: 2px solid #d99b26;
    border-radius: 14px;
    padding: 12px 13px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .fest-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .fest-title {
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 900;
    color: #7c3b0e;
  }

  .fest-progress-text {
    font-size: 11.5px;
    font-weight: 800;
    color: #8c5514;
    font-variant-numeric: tabular-nums;
  }

  .fest-bar {
    width: 100%;
    height: 9px;
    background: #e5d4b1;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid #d1ba8a;
  }

  .fest-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d99b26, #e05a38);
    transition: width 0.25s ease;
  }

  .btn-festival {
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: #2b1808;
    background: linear-gradient(135deg, #ffe58f 0%, #f5b342 100%);
    box-shadow: 0 4px 0 #a36a10;
    cursor: pointer;
  }
  .btn-festival:hover:not(:disabled) { filter: brightness(1.06); }
  .btn-festival:disabled {
    background: #d9ccb4;
    color: #7d705d;
    box-shadow: 0 2px 0 #b5a68c;
    cursor: not-allowed;
  }

  /* 図鑑グリッド */
  .dex-summary {
    padding: 8px 12px;
    background: #f8f1e4;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--ink-sub);
  }

  .dex-grid {
    padding: 9px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    max-height: 510px;
    overflow-y: auto;
  }

  .dex-card {
    background: #fffdf8;
    border: 1.5px solid #dfd1ba;
    border-radius: 10px;
    padding: 7px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .dex-card.rare {
    border-color: #d99b26;
    background: #fffaf0;
  }
  .dex-card.unknown {
    background: #f1e9db;
    opacity: 0.78;
  }

  .dex-avatar {
    width: 40px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    background: #f4ead7;
    border: 1px solid #d9c8ad;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .dex-info {
    min-width: 0;
    flex: 1;
  }

  .dex-name {
    font-size: 12px;
    font-weight: 900;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .dex-rare-tag {
    font-size: 9px;
    font-weight: 900;
    padding: 0 5px;
    border-radius: 999px;
    background: #d99b26;
    color: #fffaf0;
  }

  .dex-cond {
    font-size: 10px;
    color: var(--ink-sub);
    line-height: 1.35;
    margin-top: 2px;
  }

  .dex-cnt {
    font-size: 10px;
    font-weight: 800;
    color: var(--forest);
    margin-top: 2px;
  }

  /* 実績リスト */
  .ach-list {
    padding: 9px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 510px;
    overflow-y: auto;
  }

  .ach-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f3ecdf;
    border: 1.5px solid #ddd0ba;
  }
  .ach-row.done {
    background: #fffaf0;
    border-color: #d99b26;
  }

  .ach-name {
    font-size: 12px;
    font-weight: 900;
    color: var(--ink);
  }
  .ach-desc {
    font-size: 10.5px;
    color: var(--ink-sub);
    margin-top: 1px;
  }
  .ach-status {
    font-size: 10.5px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .ach-status.done { background: #d99b26; color: #fffaf0; }
  .ach-status.todo { background: #ded3c0; color: #6c5f52; }

  /* 遷宮・神徳タブ */
  .sengu-box {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .sengu-panel {
    background: linear-gradient(180deg, #eef6f1 0%, #e1efe7 100%);
    border: 1.5px solid #8ab89f;
    border-radius: 12px;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .btn-sengu {
    border: none;
    border-radius: 9px;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(180deg, #3c7d5c 0%, #26543d 100%);
    box-shadow: 0 3px 0 #173828;
    cursor: pointer;
  }
  .btn-sengu:disabled {
    background: #b7c2bc;
    box-shadow: 0 2px 0 #95a19a;
    cursor: not-allowed;
  }

  .virtue-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 360px;
    overflow-y: auto;
  }

  /* 来訪ログ */
  .visit-bias-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 13px;
    background: #f8f1e4;
    border-bottom: 1px dashed var(--border);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-sub);
  }

  .bias-meter {
    flex: 1;
    max-width: 150px;
    height: 7px;
    border-radius: 999px;
    background: #d8c8ae;
    overflow: hidden;
    display: flex;
  }
  .bias-human { background: var(--vermilion); transition: width 0.35s ease; }
  .bias-yokai { background: var(--forest); transition: width 0.35s ease; }

  #visit-log-list {
    list-style: none;
    margin: 0;
    padding: 8px 11px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 175px;
  }

  .log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    background: #fffdf8;
    border: 1px solid #e7dac5;
    font-size: 11.5px;
  }
  .log-row.is-yokai  { background: #f2f8f4; border-color: #c2decb; }
  .log-row.is-human  { background: #fff8f3; border-color: #f0d2c4; }
  .log-row.is-system { background: #fdf6e4; border-color: #e6cfa0; }
  .log-row.is-event  {
    background: linear-gradient(90deg, #fff3d4 0%, #fde4c8 100%);
    border: 1.5px solid #d99b26;
  }

  .log-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .log-badge {
    font-size: 9.5px;
    font-weight: 900;
    padding: 1px 6px;
    border-radius: 999px;
    flex-shrink: 0;
  }
  .badge-human { background: #f8d5cc; color: #8c2817; }
  .badge-yokai { background: #cfe8d9; color: #1b4d34; }
  .badge-sys   { background: #f4e0b1; color: #754e0b; }
  .badge-event { background: #c9472e; color: #fffaf0; }

  .log-text {
    color: var(--ink);
    font-weight: 600;
  }

  .log-time {
    font-size: 10px;
    color: var(--ink-sub);
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* トースト通知 */
  #toast-wrap {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 7px;
    pointer-events: none;
  }

  .toast {
    background: #241b16;
    color: #fff6e5;
    border: 2px solid var(--gold);
    border-radius: 11px;
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
    max-width: 310px;
    animation: toastIn 0.25s ease-out;
  }
  .toast small {
    display: block;
    color: var(--gold-light);
    font-size: 10.5px;
    margin-top: 2px;
  }

  @keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* モーダル共通 */
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(18, 14, 12, 0.78);
    backdrop-filter: blur(4px);
  }
  .overlay.show { display: flex; }

  .modal {
    width: min(94vw, 500px);
    max-height: 92dvh;
    overflow-y: auto;
    background: var(--card);
    border: 2.5px solid var(--vermilion);
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.52);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .modal-title {
    margin: 0;
    font-family: var(--font);
    font-size: 22px;
    font-weight: 900;
    color: var(--vermilion-dark);
  }

  .modal-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.65;
    color: var(--ink);
  }

  .offline-big-num {
    font-family: var(--font);
    font-size: 30px;
    font-weight: 900;
    color: var(--vermilion-dark);
    background: #fff3d4;
    border: 2px solid #d99b26;
    border-radius: 12px;
    padding: 12px 10px;
  }

  .modal-summary {
    background: #f5ecdc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 11.5px;
  }
  .sum-box strong {
    display: block;
    font-size: 15px;
    color: var(--vermilion-dark);
    margin-top: 2px;
  }

  .modal-btns {
    display: flex;
    gap: 9px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .btn-primary {
    flex: 1;
    min-width: 140px;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 900;
    color: #fffaf0;
    background: linear-gradient(180deg, #d45238 0%, #b13922 100%);
    box-shadow: 0 3px 0 #7b2313;
    cursor: pointer;
  }

  .btn-secondary {
    flex: 1;
    min-width: 140px;
    border: 1.5px solid #bca98e;
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 800;
    color: var(--ink);
    background: #efe4d1;
    cursor: pointer;
  }

  .btn-x {
    border: 1.5px solid #2c241d;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    background: #1f1b18;
    cursor: pointer;
    width: 100%;
  }

  .studio-link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    border-radius: 11px;
    background: #f5ecdc;
    border: 1.5px solid #cbb692;
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
  }
  .studio-link-card:hover {
    border-color: var(--vermilion);
    background: #fbf3e2;
  }
  .studio-link-sub {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--ink-sub);
    margin-top: 1px;
  }

  .lang-switch {
    display: inline-flex;
    background: #e9dcc6;
    border: 1.5px solid #cbb692;
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
  }
  .lang-btn {
    border: none;
    background: transparent;
    color: var(--ink-sub);
    font-size: 11px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
  }
  .lang-btn.active {
    background: var(--vermilion);
    color: #fffaf0;
  }

  @media (max-width: 900px) {
    #main-layout {
      grid-template-columns: 1fr;
      padding: 9px;
      gap: 10px;
    }
    .dex-grid { grid-template-columns: 1fr; }
    .brand-title { font-size: 15px; }
    .stat-value { font-size: 14px; }
  }
