    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
-webkit-tap-highlight-color: transparent;
    }

    :root {
      --color-p1: #4caf50;
      --color-p2: #e57373;
    }

    body {
      font-family: 'Hiragino Kaku Gothic ProN', sans-serif;
      background: #f0f4f8;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      overscroll-behavior: none;
  /* ピンチズームやダブルタップズームを無効化 */
  touch-action: pan-x pan-y;
  /* iOS Safari向けのダブルタップズーム防止 */
  -webkit-text-size-adjust: 100%;
    }

    body.game-active {
      overflow: hidden;
      position: fixed;
      width: 100%;
      height: 100%;
    }

    /*===== 共通 ===== */
    .screen { display: none; width: 100%; max-width: 900px; padding: 20px; }
    .screen.active { display: flex; flex-direction: column; align-items: center; }

    h1 { font-size: 2rem; color: #333; margin-bottom: 24px; }
    h2 { font-size: 1.4rem; color: #444; margin-bottom: 20px; }

    .btn {
      margin-top:1em;
      padding: 14px 32px;
      font-size: 1.1rem;
      border: none;
      border-radius: 12px;
      cursor: pointer;
      background: #4a90d9;
      color: white;
      transition: background 0.2s, transform 0.1s;
    }
    .btn:hover { background: #357abd; }
    .btn:active { transform: scale(0.97); }
    .btn:disabled { background: #aaa; cursor: default; }

    /* ===== キャラ選択画面 ===== */
    .chara-select-wrap {
      display: flex;
      justify-content: space-around;
      width: 100%;
      gap: 20px;
      flex-wrap: wrap;
    }

    .player-select-panel {
      background: white;
      border-radius: 16px;
      padding: 20px;
      flex: 1;
      min-width: 280px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .player-select-panel h3 {
      text-align: center;
      font-size: 1.2rem;
      margin-bottom: 16px;
    }

    .chara-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 10px;
      margin-bottom: 16px;
    }

    .chara-option {
      width: 100%;
      aspect-ratio: 1;
      border-radius: 50%;
      border: 3px solid transparent;
      cursor: pointer;
      overflow: hidden;
      transition: border-color 0.2s, transform 0.1s;
      background: #eee;
      position: relative;
      touch-action: manipulation;
    }

    .chara-option img {
      width: 85%;
      height: 85%;
      object-fit: contain;
      border-radius: 0;position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      pointer-events: none;
      -webkit-user-drag: none;}

    .chara-option:hover { transform: scale(1.05); }
    .chara-option.selected-p1 { border-color: var(--color-p1); box-shadow: 0 0 8px var(--color-p1); }
    .chara-option.selected-p2 { border-color: var(--color-p2); box-shadow: 0 0 8px var(--color-p2); }
    .chara-option.disabled-chara {
      cursor: not-allowed;
      filter: grayscale(100%);
      opacity: 0.5;
    }

    .selected-preview {
      text-align: center;
      margin-top: 10px;
    }

    .preview-placeholder {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      background-color: #eee;
      background-size: 85% !important;
      background-position: center !important;
      background-repeat: no-repeat !important;
      margin: 0 auto;
    }

    /* ===== 枚数・絵柄選択画面 ===== */
    .select-section {
      width: 100%;
      margin-bottom: 28px;
    }

    .select-section h3 {
      font-size: 1.1rem;
      color: #555;
      margin-bottom: 14px;
      text-align: center;
    }

    .count-options,
    .theme-options {
      display: flex;
      gap: 16px;
      flex-wrap: wrap;
      justify-content: center;
    }

    .count-btn {
      width: 100px;
      height: 100px;
      font-size: 1.5rem;
      font-weight: bold;
      border-radius: 16px;
      border: 3px solid #4a90d9;
      background: white;
      color: #4a90d9;
      cursor: pointer;
      transition: all 0.2s;
      touch-action: manipulation;
    }

    .count-btn:hover, .count-btn.selected {
      background: #4a90d9;
      color: white;
    }

    .theme-btn {
      width: 120px;
      height: 80px;
      font-size: 1.05rem;
      font-weight: bold;
      border-radius: 16px;
      border: 3px solid #f0a500;
      background: white;
      color: #f0a500;
      cursor: pointer;
      transition: all 0.2s;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      line-height: 1.3;
      touch-action: manipulation;
    }

    .theme-btn .theme-emoji {
      font-size: 1.6rem;
    }

    .theme-btn:hover, .theme-btn.selected {
      background: #f0a500;
      color: white;
    }

    /* =====ゲーム画面 ===== */
    #game-screen {
      max-width: 1000px;
      height: 100vh;
      justify-content: flex-start;
      padding: 12px 20px 60px;
      overflow: hidden;
    }

    .game-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      margin-bottom: 10px;
      background: white;
      border-radius: 16px;
      padding: 10px 20px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.08);
      flex-shrink: 0;
    }

    .player-status {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      transition: all 0.3s;
    }

    .player-status .face-img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      object-fit: contain;
      object-position: center;
      background: #eee;
      padding: 8%;
      border: 3px solid transparent;
      transition: filter 0.3s, border-color 0.3s, box-shadow 0.3s;pointer-events: none;
      -webkit-user-drag: none;
    }

    #status-p1.active .face-img {
      filter: none;
      border-color: var(--color-p1);
      box-shadow: 0 0 10px var(--color-p1);
    }
    #status-p2.active .face-img {
      filter: none;
      border-color: var(--color-p2);
      box-shadow: 0 0 10px var(--color-p2);
    }

    .player-status.inactive .face-img {
      filter: grayscale(100%);
      border-color: #ccc;
    }

    #status-p1 .player-name { color: var(--color-p1); font-size: 0.9rem; font-weight: bold; }
    #status-p2 .player-name { color: var(--color-p2); font-size: 0.9rem; font-weight: bold; }

    #score-p1 { font-size: 1.1rem; font-weight: bold; color: var(--color-p1); }
    #score-p2 { font-size: 1.1rem; font-weight: bold; color: var(--color-p2); }

    .turn-indicator {
      font-size: 1.2rem;
      font-weight: bold;
      text-align: center;
    }.turn-indicator.turn-p1 { color: var(--color-p1); }
    .turn-indicator.turn-p2 { color: var(--color-p2); }

    /* ===== カードグリッド ===== */
    #card-grid {
      display: grid;
      gap: 6px;
      width: 100%;
      flex-shrink: 0;
    }

.card {
      cursor: pointer;
      perspective: 600px;
      border-radius: 10px;
      touch-action: manipulation;
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
  /* カード上での拡大・縮小・パン操作をすべて無効化 */
  touch-action: none;
    }

    /* 画像の長押し保存・ドラッグを防止しつつタップは通す設定 */
    .card img {
      pointer-events: none;
      -webkit-user-drag: none;
      -webkit-touch-callout: none;
    }

    .card-inner {
      width: 100%;
      height: 100%;
      position: relative;
      transform-style: preserve-3d;
      transition: transform 0.4s;
      border-radius: 10px;}

    .card.flipped .card-inner { transform: rotateY(180deg); }

    .card-back, .card-face {
      position: absolute;
      width: 100%;
      height: 100%;
      backface-visibility: hidden;
      border-radius: 10px;
      overflow: hidden;
      border: 2px solid #ccc;
    }

    .card-back { background: #4a90d9; }

    .card-back img,
    .card-face img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      pointer-events: none;
      -webkit-user-drag: none;
      draggable: false;
    }

    .card-face {
      background: white;
      transform: rotateY(180deg);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .card-face img { width: 90%; height: 90%; object-fit: contain; }

    .card.matched-p1 .card-face {
      background: #c8f7c5;
      border-color: var(--color-p1);
    }

    .card.matched-p2 .card-face {
      background: #f7c5c5;
      border-color: var(--color-p2);
    }

    /* ===== 結果画面 ===== */
    .result-wrap {
      display: flex;
      justify-content: center;
      align-items: flex-end;
      gap: 60px;
      margin: 30px 0;
    }

    .result-player {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
    }

    .result-player img {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      object-fit: contain;
      object-position: center;
      background: #eee;
      padding: 8%;
      border: 4px solid #ccc;
      transition: filter 0.5s, border-color 0.5s, box-shadow 0.5s;
      pointer-events: none;
      -webkit-user-drag: none;
    }

    .result-player.winner img {
      filter: none;
      border-color: #f9a825;
      box-shadow: 0 0 20px #f9a825;
    }

    .result-player.loser img {
      filter: grayscale(100%);
    }

    #result-p1 .result-name { color: var(--color-p1); font-size: 1rem; font-weight: bold; }
    #result-p2 .result-name { color: var(--color-p2); font-size: 1rem; font-weight: bold; }

    #result-score-p1 { font-size: 1.4rem; font-weight: bold; color: var(--color-p1); }
    #result-score-p2 { font-size: 1.4rem; font-weight: bold; color: var(--color-p2); }

    .result-player .crown {
      font-size: 2rem;
      visibility: hidden;
    }

    .result-player.winner .crown { visibility: visible; }

    .result-title {
      font-size: 1.8rem;
      font-weight: bold;
      margin-bottom: 10px;
      text-align: center;
    }

    /* ===== ロゴ ===== */
    #logo {
      position: fixed;
      bottom: 16px;
      right: 16px;
      width: 180px;
      opacity: 0.85;
      pointer-events: none;
    }