/* 
  すべての要素および疑似要素に対して、iPhone長押し時の選択ハイライト、
  ルーペ（虫眼鏡）、およびコピーメニューを完全に禁止します。
  また、タップ時の不自然なグレーのフラッシュ（ハイライト）も透明化します。
*/
*, *::before, *::after {
    user-select: none;
    -webkit-user-select: none;      /* iOS Safari用 */
    -webkit-touch-callout: none;    /* iOSでの長押しリンク・メニュー抑止 */
    -webkit-tap-highlight-color: transparent; /* タップ時の枠線消去 */
}

body {
    background-color: #222;
    color: #fff;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* 100vh固定にし、PC・スマホ問わず絶対にスクロール・はみ出しを起こさない設定 */
    height: 100vh;
    height: 100dvh; /* 近年のモバイルブラウザ用動的ビューポート対応 */
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}

h1 {
    margin: 0 0 4px 0;
    font-size: 20px;
    text-align: center;
}

/* 
  【デフォルト設定：スマホなどの縦長画面 (横幅 500px 以下)】
  スマホ全般（iPhone含む）では、画面幅を十分に活用できるよう
  「最大横幅 320px」まで引き伸ばして表示領域を最大化します。
*/
#app-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(92vw, 320px); 
    box-sizing: border-box;
}

/* 
  【PC・タブレット・横長画面 (横幅 501px 以上)】
  パソコンなどの横長画面では、画面の高さ(36vh)を基準にし、
  下が絶対にはみ出さないよう自動縮小を維持します。
*/
@media (min-width: 501px) {
    #app-wrapper {
        width: min(90vw, 280px, 36vh);
    }
}

/* 自動アップデート通知バナーのデザイン設定 */
#update-banner {
    background-color: #ffbb33;
    color: #222;
    font-size: 11px;
    font-weight: bold;
    width: 100%;
    padding: 6px 12px;
    margin-bottom: 8px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    animation: slideDown 0.3s ease;
}

#btn-update-reload {
    background-color: #222;
    color: #ffbb33;
    border: none;
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin: 0;
    box-shadow: none;
}

#btn-update-reload:active {
    background-color: #444;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#status-board {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
}

#stats {
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#next-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#next-label {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 2px;
    font-weight: bold;
}

#nextCanvas {
    border: 2px solid #444;
    background-color: #111;
    display: block;
}

#game-container {
    position: relative;
    width: 100%;          
    aspect-ratio: 3 / 5;  
}

canvas#gameCanvas {
    width: 100%;          
    height: 100%;
    border: 4px solid #444;
    background-color: #111;
    box-sizing: border-box;
    display: block;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 17, 17, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 8px 12px; 
    border: 4px solid transparent;
}

.overlay h2 {
    margin: 0 0 3px 0;
    font-size: 20px;
    color: #ffbb33;
}

.overlay p {
    margin: 0 0 8px 0;
    font-size: 11px;
    color: #ccc;
    line-height: 1.3;
}

/* ランキング表示用レイアウト */
.ranking-title {
    font-size: 11px;
    color: #ffbb33;
    margin: 2px 0 2px 0;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* ランキング切り替えタブのデザイン定義 */
.ranking-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 10px;
    color: #888;
}

.rank-tab {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: #333;
    transition: all 0.2s;
    font-weight: bold;
}

.rank-tab.active {
    color: #ffbb33;
    background-color: #444;
}

.ranking-board {
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 4px 10px;
    width: 90%;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.ranking-row {
    display: flex;
    justify-content: space-between;
    margin: 2px 0;
    font-size: 10px;
    color: #ccc;
}

/* 初期化リンク */
#reset-ranking-container {
    margin-top: -6px;
    margin-bottom: 8px;
    width: 90%;
    text-align: right;
    box-sizing: border-box;
}

#btn-reset-ranking {
    font-size: 8px;
    color: #666;
    cursor: pointer;
    text-decoration: underline;
    touch-action: none;
    transition: color 0.2s;
}

#btn-reset-ranking:active {
    color: #ff4444;
}

/* ランクイン点滅アニメーション */
@keyframes gold-flash {
    0%, 100% { color: #ffbb33; text-shadow: 0 0 3px rgba(255,187,51,0.6); }
    50% { color: #fff; text-shadow: 0 0 6px rgba(255,255,255,0.8); }
}

.ranking-row.new-record {
    font-weight: bold;
    animation: gold-flash 0.8s infinite;
}

/* イージー・ノーマルのダイレクト開始ボタンのグループ配置 */
.start-buttons-group {
    display: flex;
    gap: 10px;
    width: 90%;
    margin-top: 4px;
    box-sizing: border-box;
}

.btn-start-mode {
    flex: 1;
    background-color: #444;
    color: #ccc;
    border: none;
    padding: 8px 0;
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
    margin-top: 0;
    box-shadow: none;
}

/* メインの通常モードを目立たせるハイライト指定 */
.btn-start-mode.highlight {
    background-color: #00c851;
    color: white;
}

.btn-start-mode:active {
    transform: scale(0.95);
}

button {
    background-color: #00c851;
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    transition: background 0.2s;
    margin-top: 2px;
}

button:hover {
    background-color: #007e33;
}

/* スマホ操作用のバーチャルコントローラー */
#virtual-controller {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
}

.dpad, .actions {
    display: flex;
    gap: 6px;
}

/* 縮小時にもはみ出さない、タップしやすい標準ボタンサイズ (44px) */
.btn-ctrl {
    width: 44px;
    height: 44px;
    background-color: #444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    box-shadow: 0 3px 0 #222;
    transition: transform 0.05s, box-shadow 0.05s;
}

.btn-ctrl:active {
    background-color: #666;
    transform: translateY(2px);
    box-shadow: 0 1px 0 #222;
}

.action-btn {
    background-color: #00c851;
    font-size: 10px;
    width: 48px;
}

.action-btn:active {
    background-color: #007e33;
}

#btn-drop {
    background-color: #ffbb33;
}

#btn-drop:active {
    background-color: #ff8800;
}

/* ゲーム枠内の幅に収まる説明文 */
#controls {
    font-size: 9px;
    color: #666;
    text-align: center;
    margin-top: 8px;
    line-height: 1.3;
    width: 100%;          
    box-sizing: border-box;
    padding: 0 4px;       
    overflow-wrap: anywhere; 
}