:root {
    --bg-light: #e0f7fa;
    --main-color: #ff4081;
    --main-hover: #f50057;
    --border-color: #b2ebf2;
    --text-color: #006064;
    --panel-bg: #ffffff;
    --card-shadow: 0 8px 16px rgba(0, 96, 100, 0.15);
  }

  * {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
  }

  body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-light);
    color: var(--text-color);
    font-family: 'Comic Sans MS', 'Hiragino Maru Gothic ProN', 'Arial Rounded MT Bold', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100dvh;
  }

  /* ====== アプリコンテナ ====== */
  #app-container {
    width: 100%;
    height: 100%;
    max-width: 480px; /* スマホ縦持ちに最適化 */
    background: linear-gradient(180deg, #b2ebf2 0%, #e0f7fa 100%);
    border-left: 4px solid var(--border-color);
    border-right: 4px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
  }

  /* ====== スクリーン管理 ====== */
  .screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
  }
  .screen.active {
    display: flex;
  }

  /* ====== タイトル & 曲選択画面 ====== */
  #title-screen {
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
    text-align: center;
    overflow-y: auto;
  }
  .title-logo-box {
    margin-top: 15px;
  }
  .title-logo {
    font-size: 34px;
    font-weight: bold;
    color: var(--main-color);
    text-shadow: 3px 3px 0 #fff, -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 0 6px 12px rgba(255,64,129,0.2);
    line-height: 1.3;
  }
  .title-sub {
    font-size: 15px;
    color: #00838f;
    font-weight: bold;
    margin-top: 6px;
  }
  
  /* 選曲リスト */
  .song-list-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
  }
  .song-card {
    background: #ffffff;
    border: 3px solid var(--border-color);
    border-radius: 20px;
    padding: 14px 18px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.1s, border-color 0.1s;
  }
  .song-card:active {
    transform: scale(0.97);
  }
  .song-card.selected {
    border-color: var(--main-color);
    background: #fff8fa;
  }
  .song-info {
    text-align: left;
  }
  .song-title {
    font-size: 20px;
    font-weight: bold;
    color: #006064;
  }
  .song-highscore {
    font-size: 12px;
    color: #ff4081;
    font-weight: bold;
    margin-top: 4px;
  }
  .song-icon {
    font-size: 32px;
  }

  .btn-big {
    padding: 16px 50px;
    font-size: 26px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(to bottom, #ff6b8b, #ff4081);
    border: 4px solid #fff;
    border-radius: 40px;
    cursor: pointer;
    box-shadow: 0 6px 0 #d81b60, 0 8px 15px rgba(0,0,0,0.15);
    transition: transform 0.05s, box-shadow 0.05s;
    outline: none;
    margin-bottom: 10px;
  }
  .btn-big:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #d81b60, 0 4px 6px rgba(0,0,0,0.15);
  }

  /* ミュートボタン */
  .mute-btn {
    position: absolute;
    top: 15px; right: 15px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.06);
    z-index: 100;
  }

  /* ====== ゲーム画面 ====== */
  #game-screen {
    background: #b2ebf2;
    justify-content: space-between;
  }

  /* HUD */
  #game-hud {
    height: 64px;
    background: #ffffff;
    border-bottom: 3px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    z-index: 10;
  }
  .hud-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 44px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: bold;
    background: #ef9a9a;
    border: 2px solid #e57373;
    color: #b71c1c;
    border-radius: 24px;
    cursor: pointer;
    box-sizing: border-box;
  }
  .hud-score {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
  }

  /* キャンバスエリア */
  #canvas-container {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #80deea 0%, #e0f7fa 100%);
    overflow: hidden;
  }
  #game-canvas {
    display: block;
    touch-action: none;
  }

  /* カウントダウンオーバーレイ */
  #countdown-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
  }
  #countdown-overlay.active {
    opacity: 1;
  }
  #countdown-number {
    font-size: 100px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 8px 16px rgba(0,0,0,0.3);
    animation: zoom 1s infinite ease-out;
  }
  @keyframes zoom {
    0% { transform: scale(0.4); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1.0); opacity: 0; }
  }

  /* ====== 結果発表画面 ====== */
  #result-screen {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 40%, #fff6e0 0%, #faecd0 100%);
    text-align: center;
  }
  .result-title {
    font-size: 36px;
    font-weight: bold;
    color: var(--main-color);
    text-shadow: 2px 2px 0 #fff;
    margin-bottom: 20px;
  }
  .result-score-box {
    background: #fff;
    border: 4px solid var(--border-color);
    border-radius: 24px;
    padding: 20px 30px;
    margin-bottom: 35px;
    box-shadow: var(--card-shadow);
  }
  .result-score-label {
    font-size: 16px;
    color: #00838f;
    font-weight: bold;
  }
  .result-score-value {
    font-size: 44px;
    font-weight: bold;
    color: #ff4081;
    margin: 8px 0;
  }
  .result-highscore-label {
    font-size: 13px;
    color: #ef5350;
    font-weight: bold;
  }