body {
    font-family: "M PLUS Rounded 1c", "Helvetica Neue", Arial, sans-serif;
    background-color: #202020;
    color: white;
    text-align: center;
    margin: 0;
    padding: 0;
    user-select: none;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ローディング画面 */
#loading-screen {
    font-family: "M PLUS Rounded 1c", "Helvetica Neue", Arial, sans-serif;
}

#loading-text {
    text-shadow: none;
}

/* タイトル画面 */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#title-screen::before {
    z-index: 0;
}

.title-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.title-particle {
    position: absolute;
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.6;
    animation: particleFloat 8s linear infinite;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100px) rotate(var(--rotation-speed, 360deg));
        opacity: 0;
    }
}

/* 初期パーティクル用のアニメーション（画面内から開始） */
@keyframes particleFloatFromMiddle {
    0% {
        transform: translateY(var(--initial-y, 0vh)) rotate(0deg);
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100px) rotate(var(--rotation-speed, 360deg));
        opacity: 0;
    }
}

#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* background-image: url('pict/titleback.webp'); */
    /* background-size: contain; */
    /* background-position: center; */
    /* background-repeat: no-repeat; */
    background: #ffffff;
    pointer-events: none;
}


.title-content {
    text-align: left;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 5vh 10vw 5vh 5vw;
    box-sizing: border-box;
}

.title-logo {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    margin-bottom: 0;
    animation: titlePulse 2s ease-in-out infinite;
    width: auto !important;
    height: auto !important;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    pointer-events: auto !important;
    display: block;
    z-index: 1;
}

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

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-end;
    position: relative;
    z-index: 10;
}

.title-copyright {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #888;
    z-index: 10;
    pointer-events: none;
}

.title-version {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 12px;
    color: #888;
    z-index: 10;
    pointer-events: none;
}

/* コンプリートマーク */
.complete-mark {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    pointer-events: none;
    opacity: 0.9;
}

.complete-mark img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

/* キャラクターセレクト画面のコンプリートマーク（「キャラクターを選択」の上） */
.character-select-content h2 .complete-mark {
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
}

.character-select-content h2 .complete-mark img {
    width: 160px;
    height: 160px;
}

/* コンテンツエリア内のコンプリートマーク用の親要素を相対配置に */
/* .character-select-content は既に position: relative; が設定されているため、.yaku-list-content のみ追加 */

/* モバイル版のコンプリートマーク */
@media screen and (max-width: 768px) {
    .complete-mark {
        top: 10px;
        right: 10px;
    }
    
    .complete-mark img {
        width: 60px;
        height: 60px;
    }
    
    /* キャラクターセレクト画面のコンプリートマーク（モバイル版） */
    .character-select-content h2 .complete-mark {
        top: -60px;
    }
    
    .character-select-content h2 .complete-mark img {
        width: 120px;
        height: 120px;
    }
}

.title-btn {
    width: min(450px, 30vw);
    min-height: min(90px, 8vh);
    padding: 0;
    font-size: 0;
    background-color: transparent !important;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: transparent;
    text-indent: -9999px;
    overflow: visible;
    transform-origin: center center;
}

.title-btn:hover {
    background-color: transparent !important;
    background-size: 100% 100%;
    transform: translateY(-2px) scale(1.02);
    opacity: 0.9;
}

.title-btn:active {
    background-color: transparent !important;
    background-size: 100% 100%;
    transform: translateY(0);
    opacity: 0.75;
}

/* キャラクターセレクトの決定ボタン */
#confirm-character-btn {
    background-color: #e74c3c !important;
    background-image: none !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: bold !important;
    text-indent: 0 !important;
    border: 3px solid #fff;
    border-radius: 10px;
    padding: 18px 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#confirm-character-btn:hover {
    background-color: #c0392b !important;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#confirm-character-btn:active {
    background-color: #a93226 !important;
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* タイトル画面のレスポンシブ対応 */
@media (max-width: 1200px) {
    .title-logo {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .title-content {
        padding: 4vh 8vw 4vh 4vw;
    }
    
    .title-btn {
        width: min(400px, 28vw);
        min-height: min(80px, 7vh);
    }
}

@media (max-width: 768px) {
    .title-logo {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .title-content {
        padding: 3vh 5vw 3vh 3vw;
    }
    
    .title-btn {
        width: min(350px, 35vw);
        min-height: min(70px, 6vh);
    }
    
    .title-menu {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .title-logo {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .title-content {
        padding: 2vh 3vw 2vh 2vw;
    }
    
    .title-btn {
        width: min(300px, 40vw);
        min-height: min(60px, 5vh);
    }
    
    .title-menu {
        gap: 10px;
    }
}

/* つづきからボタンの情報表示 */
#continue-info {
    font-size: 21px !important;
    font-weight: normal !important;
    opacity: 0.9 !important;
    line-height: 1.2;
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    position: absolute !important;
    bottom: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    white-space: nowrap;
    text-indent: 0 !important;
    pointer-events: none;
    z-index: 10;
    width: 100%;
    text-align: center;
}

/* キャラクターセレクト画面 */
#character-select-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 550;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#character-select-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* background-image: url('pict/titleback.webp'); */
    /* background-size: contain; */
    /* background-position: center; */
    /* background-repeat: no-repeat; */
    background: #ffffff;
    pointer-events: none;
    z-index: 0;
}

.character-select-logo {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
    animation: titlePulse 2s ease-in-out infinite;
}

.character-select-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 250, 250, 0.85) 100%);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 182, 193, 0.4);
    border-radius: 15px;
    padding: 40px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.character-item {
    cursor: pointer;
    text-align: center;
    padding: 15px;
    border: 3px solid #555;
    border-radius: 10px;
    background: rgba(0,0,0,0.5);
    transition: all 0.3s;
}

.character-item:hover {
    border-color: #f1c40f;
    transform: scale(1.05);
    background: rgba(241, 196, 15, 0.1);
}

.character-item.selected {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.2);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.character-item img {
    width: 100%;
    height: auto;
    border-radius: 50%;
    margin-bottom: 10px;
    object-fit: cover;
    aspect-ratio: 1;
}

.character-item .character-name {
    font-size: 14px;
    color: #ddd;
    font-weight: bold;
}

.character-item.selected .character-name {
    color: #333;
}

/* スタッフクレジット画面 */
#credits-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 550;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.credits-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border: 2px solid #555;
    border-radius: 15px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

h1 {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    font-size: 28px;
    color: #ddd;
    z-index: 10;
    width: 100%;
    pointer-events: none;
}

/* 卓のデザイン - リアルな雀卓風 */
.table-container {
    position: relative;
    /* デフォルト: 横画面では3:4を維持 */
    width: min(100vw, calc(100vh * 3 / 4));
    height: min(100vh, calc(100vw * 4 / 3));
    aspect-ratio: 3 / 4;
    /* 外枠（卓の外側） */
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 
        10px 10px 30px rgba(0,0,0,0.5),
        inset 2px 2px 5px rgba(255,255,255,0.1),
        inset -2px -2px 5px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* 縦長画面（スマホなど）ではより縦長の比率に */
@media screen and (orientation: portrait) {
    .table-container {
        /* 縦長画面では5:3の比率で画面を十分に使う */
        width: min(100vw, calc(100vh * 3 / 5));
        height: min(100vh, calc(100vw * 5 / 3));
        aspect-ratio: 3 / 5;
    }
}

/* より縦長の画面（高さが800px以上）では6:3の比率 */
@media screen and (orientation: portrait) and (min-height: 800px) {
    .table-container {
        /* より縦長の画面では6:3（2:1）の比率で画面を十分に使う */
        width: min(100vw, calc(100vh * 3 / 6));
        height: min(100vh, calc(100vw * 6 / 3));
        aspect-ratio: 3 / 6;
    }
}

/* 画面の高さが小さい時の調整（縦横どちらでも） */
@media screen and (max-height: 800px) {
    /* キャラアイコンを画面高さに応じて縮小（他のメディアクエリより優先） */
    .player-avatar {
        width: min(60px, max(35px, 6vh)) !important;
        height: min(60px, max(35px, 6vh)) !important;
        max-width: 60px !important;
        max-height: 60px !important;
    }
    
    /* キャラアイコン位置を画面高さに応じて調整（重ならないように、より積極的に） */
    .p-right .player-info-container {
        right: max(150px, min(250px, 15vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(150px, min(250px, 15vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(150px, min(220px, 20vh)) !important;
    }
    
    .p-bottom .player-info-container {
        bottom: max(200px, min(400px, calc(100vh * 0.4))) !important;
    }
    
    /* 点数と名前のフォントサイズも縮小 */
    .player-points {
        font-size: min(24px, max(16px, 2.5vh)) !important;
    }
    
    .player-name {
        font-size: min(14px, max(11px, 1.5vh)) !important;
    }
    
    /* 余白を削減 */
    .table-container {
        padding: max(10px, calc((800px - 100vh) / 15)) !important;
    }
    
    .table-container::before {
        top: max(10px, calc((800px - 100vh) / 15)) !important;
        left: max(10px, calc((800px - 100vh) / 15)) !important;
        right: max(10px, calc((800px - 100vh) / 15)) !important;
        bottom: max(10px, calc((800px - 100vh) / 15)) !important;
    }
    
    .player-info-container {
        gap: max(2px, calc((800px - 100vh) / 80)) !important;
    }
    
    /* 自牌を高さに応じて縮小 */
    .p-bottom .tile {
        width: min(75px, max(50px, calc(100vh * 0.08))) !important;
        height: min(105px, max(70px, calc(100vh * 0.11))) !important;
        font-size: min(30px, max(20px, calc(100vh * 0.035))) !important;
    }
    
    .p-bottom .tile-name {
        font-size: min(15px, max(10px, calc(100vh * 0.018))) !important;
    }
    
    .p-bottom .tile-point {
        font-size: min(12px, max(8px, calc(100vh * 0.014))) !important;
    }
    
    /* CPU牌を高さに応じて縮小 */
    .tile-back {
        width: min(48px, max(32px, calc(100vh * 0.05))) !important;
        height: min(66px, max(44px, calc(100vh * 0.068))) !important;
    }
    
    .tile-back.side {
        width: min(48px, max(32px, calc(100vh * 0.05))) !important;
        height: min(66px, max(44px, calc(100vh * 0.068))) !important;
        background-size: min(48px, max(32px, calc(100vh * 0.05))) min(66px, max(44px, calc(100vh * 0.068))) !important;
    }
    
    /* 捨て牌を高さに応じて縮小 */
    .mini-tile {
        width: min(45px, max(30px, calc(100vh * 0.047))) !important;
        height: min(58.5px, max(39px, calc(100vh * 0.061))) !important;
        font-size: min(21px, max(14px, calc(100vh * 0.025))) !important;
    }
    
    /* 残り山札の文字サイズを高さに応じて縮小 */
    .deck-count-text {
        font-size: min(32px, max(20px, calc(100vh * 0.037))) !important;
    }
    
    #game-status {
        font-size: min(18px, max(12px, calc(100vh * 0.021))) !important;
    }
}

/* 画面の高さがさらに小さい時の調整 */
@media screen and (max-height: 600px) {
    /* キャラアイコンをさらに縮小（他のメディアクエリより優先） */
    .player-avatar {
        width: min(50px, max(25px, 5vh)) !important;
        height: min(50px, max(25px, 5vh)) !important;
        max-width: 50px !important;
        max-height: 50px !important;
    }
    
    /* キャラアイコン位置をさらに調整（より積極的に） */
    .p-right .player-info-container {
        right: max(80px, min(200px, 10vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(80px, min(200px, 10vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(80px, min(180px, 15vh)) !important;
    }
    
    .p-bottom .player-info-container {
        bottom: max(150px, min(350px, calc(100vh * 0.35))) !important;
    }
    
    /* 点数と名前のフォントサイズもさらに縮小 */
    .player-points {
        font-size: min(20px, max(12px, 2vh)) !important;
    }
    
    .player-name {
        font-size: min(12px, max(9px, 1.2vh)) !important;
    }
    
    /* 余白をさらに削減 */
    .table-container {
        padding: max(5px, calc((600px - 100vh) / 20)) !important;
    }
    
    .table-container::before {
        top: max(5px, calc((600px - 100vh) / 20)) !important;
        left: max(5px, calc((600px - 100vh) / 20)) !important;
        right: max(5px, calc((600px - 100vh) / 20)) !important;
        bottom: max(5px, calc((600px - 100vh) / 20)) !important;
    }
    
    .player-info-container {
        gap: max(1px, calc((600px - 100vh) / 100)) !important;
    }
    
    /* 自牌をさらに縮小 */
    .p-bottom .tile {
        width: min(60px, max(40px, calc(100vh * 0.08))) !important;
        height: min(84px, max(56px, calc(100vh * 0.11))) !important;
        font-size: min(24px, max(16px, calc(100vh * 0.035))) !important;
    }
    
    .p-bottom .tile-name {
        font-size: min(12px, max(8px, calc(100vh * 0.018))) !important;
    }
    
    .p-bottom .tile-point {
        font-size: min(10px, max(6px, calc(100vh * 0.014))) !important;
    }
    
    /* CPU牌をさらに縮小 */
    .tile-back {
        width: min(40px, max(26px, calc(100vh * 0.05))) !important;
        height: min(55px, max(36px, calc(100vh * 0.068))) !important;
    }
    
    .tile-back.side {
        width: min(40px, max(26px, calc(100vh * 0.05))) !important;
        height: min(55px, max(36px, calc(100vh * 0.068))) !important;
        background-size: min(40px, max(26px, calc(100vh * 0.05))) min(55px, max(36px, calc(100vh * 0.068))) !important;
    }
    
    /* 捨て牌をさらに縮小 */
    .mini-tile {
        width: min(35px, max(23px, calc(100vh * 0.047))) !important;
        height: min(46px, max(30px, calc(100vh * 0.061))) !important;
        font-size: min(18px, max(12px, calc(100vh * 0.025))) !important;
    }
    
    /* 残り山札の文字サイズをさらに縮小 */
    .deck-count-text {
        font-size: min(24px, max(16px, calc(100vh * 0.037))) !important;
    }
    
    #game-status {
        font-size: min(14px, max(10px, calc(100vh * 0.021))) !important;
    }
}

/* 横画面で画面が小さくなった時の調整（高さが大きい時のみ） */
@media screen and (orientation: landscape) and (max-width: 1000px) and (min-height: 801px) {
    /* まず余白を削る（優先順位1） */
    .table-container {
        padding: max(10px, calc((100vw - 600px) / 20)) !important; /* 画面が狭くなるほどpaddingを削減、最小10px */
    }
    
    .table-container::before {
        top: max(10px, calc((100vw - 600px) / 20)) !important;
        left: max(10px, calc((100vw - 600px) / 20)) !important;
        right: max(10px, calc((100vw - 600px) / 20)) !important;
        bottom: max(10px, calc((100vw - 600px) / 20)) !important;
    }
    
    .player-info-container {
        gap: max(2px, calc((100vw - 600px) / 100)) !important; /* gapを削減、最小2px */
    }
    
    .hand {
        gap: max(1px, calc((100vw - 600px) / 150)) !important; /* gapを削減、最小1px */
    }
    
    .p-right .hand, .p-left .hand {
        gap: max(1px, calc((100vw - 600px) / 150)) !important;
    }
    
    .discard-zone {
        gap: max(1px, calc((100vw - 600px) / 150)) !important;
        padding: max(3px, calc((100vw - 600px) / 50)) !important; /* paddingを削減、最小3px */
    }
    
    /* キャラアイコンを画面サイズに応じて縮小（高さが大きい時のみ） */
    .player-avatar {
        width: min(80px, max(40px, 7vw)) !important;
        height: min(80px, max(40px, 7vw)) !important;
    }
    
    /* キャラアイコン位置を画面サイズに応じて調整（重ならないように） */
    .p-right .player-info-container {
        right: max(100px, min(280px, 15vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(100px, min(280px, 15vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(100px, min(273.6px, 15vh)) !important;
    }
    
    /* 点数と名前のフォントサイズも縮小 */
    .player-points {
        font-size: min(28px, max(18px, 2.5vw)) !important;
    }
    
    .player-name {
        font-size: min(16px, max(12px, 1.5vw)) !important;
    }
    
    /* 自牌を卓からはみ出さないように縮小（余白を削っても足りない場合） */
    .p-bottom .tile {
        width: min(75px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 9)) !important;
        height: min(105px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 9 * 1.4)) !important;
        font-size: min(30px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 9 * 0.4)) !important;
    }
    
    .p-bottom .tile-name {
        font-size: min(15px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 9 * 0.2)) !important;
    }
    
    .p-bottom .tile-point {
        font-size: min(12px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 9 * 0.16)) !important;
    }
    
    /* CPUの牌も縮小 */
    .tile-back {
        width: min(48px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12)) !important;
        height: min(66px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12 * 1.375)) !important;
    }
    
    .tile-back.side {
        width: min(48px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12)) !important;
        height: min(66px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12 * 1.375)) !important;
        background-size: min(48px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12)) min(66px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12 * 1.375)) !important;
    }
    
    /* 捨て牌も縮小 */
    .mini-tile {
        width: min(45px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12)) !important;
        height: min(58.5px, calc((100vw - max(20px, calc((100vw - 600px) / 20)) * 2) / 12 * 1.3)) !important;
    }
    
    /* 設定ボタンを卓の右上からはみ出さないように調整 */
    .option-button {
        top: max(5px, calc((100vw - 600px) / 40)) !important;
        right: max(5px, calc((100vw - 600px) / 40)) !important;
        width: min(50px, max(35px, 4vw)) !important;
        height: min(50px, max(35px, 4vw)) !important;
    }
}

/* 横画面でさらに小さくなった時の調整（高さが大きい時のみ） */
@media screen and (orientation: landscape) and (max-width: 700px) and (min-height: 801px) {
    /* さらに余白を削る */
    .table-container {
        padding: max(5px, calc((100vw - 400px) / 30)) !important; /* さらにpaddingを削減、最小5px */
    }
    
    .table-container::before {
        top: max(5px, calc((100vw - 400px) / 30)) !important;
        left: max(5px, calc((100vw - 400px) / 30)) !important;
        right: max(5px, calc((100vw - 400px) / 30)) !important;
        bottom: max(5px, calc((100vw - 400px) / 30)) !important;
    }
    
    .player-info-container {
        gap: max(1px, calc((100vw - 400px) / 200)) !important; /* gapをさらに削減、最小1px */
    }
    
    .hand {
        gap: 0px !important; /* gapを完全に削除 */
    }
    
    .p-right .hand, .p-left .hand {
        gap: 0px !important;
    }
    
    .discard-zone {
        gap: 0px !important;
        padding: max(2px, calc((100vw - 400px) / 80)) !important; /* paddingをさらに削減、最小2px */
    }
    
    /* キャラアイコンをさらに縮小（高さが大きい時のみ） */
    .player-avatar {
        width: min(60px, max(30px, 6vw)) !important;
        height: min(60px, max(30px, 6vw)) !important;
    }
    
    /* キャラアイコン位置をさらに調整（重ならないように） */
    .p-right .player-info-container {
        right: max(50px, min(200px, 12vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(50px, min(200px, 12vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(50px, min(200px, 12vh)) !important;
    }
    
    /* 点数と名前のフォントサイズもさらに縮小 */
    .player-points {
        font-size: min(24px, max(14px, 2vw)) !important;
    }
    
    .player-name {
        font-size: min(14px, max(10px, 1.2vw)) !important;
    }
    
    /* 自牌をさらに縮小（余白を削っても足りない場合） */
    .p-bottom .tile {
        width: min(60px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 9)) !important;
        height: min(84px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 9 * 1.4)) !important;
        font-size: min(24px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 9 * 0.4)) !important;
    }
    
    .p-bottom .tile-name {
        font-size: min(12px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 9 * 0.2)) !important;
    }
    
    .p-bottom .tile-point {
        font-size: min(10px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 9 * 0.16)) !important;
    }
    
    /* CPUの牌もさらに縮小 */
    .tile-back {
        width: min(40px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12)) !important;
        height: min(55px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12 * 1.375)) !important;
    }
    
    .tile-back.side {
        width: min(40px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12)) !important;
        height: min(55px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12 * 1.375)) !important;
        background-size: min(40px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12)) min(55px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12 * 1.375)) !important;
    }
    
    /* 捨て牌もさらに縮小 */
    .mini-tile {
        width: min(35px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12)) !important;
        height: min(46px, calc((100vw - max(10px, calc((100vw - 400px) / 30)) * 2) / 12 * 1.3)) !important;
    }
    
    /* 設定ボタンもさらに縮小 */
    .option-button {
        width: min(40px, max(30px, 5vw)) !important;
        height: min(40px, max(30px, 5vw)) !important;
    }
}

/* 画面サイズに応じたキャラアイコンと文字サイズの調整（高さが大きい時のみ） */
@media screen and (max-width: 1200px) and (min-height: 801px) {
    /* 余白を削減（優先順位1） */
    .table-container {
        padding: max(15px, calc((1200px - 100vw) / 10)) !important;
    }
    
    .table-container::before {
        top: max(15px, calc((1200px - 100vw) / 10)) !important;
        left: max(15px, calc((1200px - 100vw) / 10)) !important;
        right: max(15px, calc((1200px - 100vw) / 10)) !important;
        bottom: max(15px, calc((1200px - 100vw) / 10)) !important;
    }
    
    .player-info-container {
        gap: max(3px, calc((1200px - 100vw) / 50)) !important;
    }
    
    .hand {
        gap: max(2px, calc((1200px - 100vw) / 100)) !important;
    }
    
    .discard-zone {
        gap: max(2px, calc((1200px - 100vw) / 100)) !important;
        padding: max(4px, calc((1200px - 100vw) / 40)) !important;
    }
    
    /* キャラアイコンを画面サイズに応じて縮小（高さが大きい時のみ） */
    .player-avatar {
        width: min(80px, max(50px, 8vw)) !important;
        height: min(80px, max(50px, 8vw)) !important;
    }
    
    .deck-count-text {
        font-size: min(32px, 3vw) !important;
    }
    
    #game-status {
        font-size: min(18px, 2vw) !important;
    }
    
    .player-points {
        font-size: min(28px, 3vw) !important;
    }
    
    /* キャラアイコン位置を画面サイズに応じて調整（重ならないように） */
    .p-right .player-info-container {
        right: max(150px, min(280px, 20vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(150px, min(280px, 20vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(150px, min(273.6px, 20vh)) !important;
    }
}

@media screen and (max-width: 900px) and (min-height: 801px) {
    /* 余白をさらに削減 */
    .table-container {
        padding: max(10px, calc((900px - 100vw) / 15)) !important;
    }
    
    .table-container::before {
        top: max(10px, calc((900px - 100vw) / 15)) !important;
        left: max(10px, calc((900px - 100vw) / 15)) !important;
        right: max(10px, calc((900px - 100vw) / 15)) !important;
        bottom: max(10px, calc((900px - 100vw) / 15)) !important;
    }
    
    .player-info-container {
        gap: max(2px, calc((900px - 100vw) / 80)) !important;
    }
    
    .hand {
        gap: max(1px, calc((900px - 100vw) / 150)) !important;
    }
    
    .discard-zone {
        gap: max(1px, calc((900px - 100vw) / 150)) !important;
        padding: max(3px, calc((900px - 100vw) / 60)) !important;
    }
    
    /* キャラアイコンをさらに縮小（高さが大きい時のみ） */
    .player-avatar {
        width: min(60px, max(40px, 7vw)) !important;
        height: min(60px, max(40px, 7vw)) !important;
    }
    
    .deck-count-text {
        font-size: min(24px, 3vw) !important;
    }
    
    #game-status {
        font-size: min(16px, 2vw) !important;
    }
    
    .player-points {
        font-size: min(24px, 2.5vw) !important;
    }
    
    /* キャラアイコン位置をさらに調整（重ならないように） */
    .p-right .player-info-container {
        right: max(100px, min(250px, 15vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(100px, min(250px, 15vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(100px, min(250px, 15vh)) !important;
    }
}

@media screen and (max-width: 600px) and (min-height: 801px) {
    /* 余白をさらに削減 */
    .table-container {
        padding: max(5px, calc((600px - 100vw) / 20)) !important;
    }
    
    .table-container::before {
        top: max(5px, calc((600px - 100vw) / 20)) !important;
        left: max(5px, calc((600px - 100vw) / 20)) !important;
        right: max(5px, calc((600px - 100vw) / 20)) !important;
        bottom: max(5px, calc((600px - 100vw) / 20)) !important;
    }
    
    .player-info-container {
        gap: max(1px, calc((600px - 100vw) / 100)) !important;
    }
    
    .hand {
        gap: 0px !important;
    }
    
    .discard-zone {
        gap: 0px !important;
        padding: max(2px, calc((600px - 100vw) / 80)) !important;
    }
    
    /* キャラアイコンをさらに縮小（高さが大きい時のみ） */
    .player-avatar {
        width: min(50px, max(30px, 6vw)) !important;
        height: min(50px, max(30px, 6vw)) !important;
    }
    
    .deck-count-text {
        font-size: min(18px, 3vw) !important;
    }
    
    #game-status {
        font-size: min(14px, 2vw) !important;
    }
    
    .player-points {
        font-size: min(20px, 2vw) !important;
    }
    
    /* キャラアイコン位置をさらに調整（重ならないように） */
    .p-right .player-info-container {
        right: max(50px, min(200px, 10vw)) !important;
    }
    
    .p-left .player-info-container {
        left: max(50px, min(200px, 10vw)) !important;
    }
    
    .p-top .player-info-container {
        top: max(50px, min(200px, 10vh)) !important;
    }
}

/* マット（卓の表面） */
.table-container::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 25px;
    right: 25px;
    bottom: 25px;
    background-color: #005733;
    border-radius: 8px;
    /* テクスチャ効果 */
    background-image: 
        radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.6) 120%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 3px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 3px);
    box-shadow: inset 3px 3px 15px rgba(0,0,0,0.8);
    z-index: 0;
    pointer-events: none;
}

/* 卓の柄（中央に配置） */
.table-container::after {
    content: '';
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background-image: var(--table-stage-image, url('pict/stage_tamasakura.webp'));
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

/* 中央エリア (修正箇所) */
.center-area {
    position: absolute;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%);
    width: 30%; /* 横幅を半分(60%->30%)に縮小 */
    height: 20%;
    background: transparent; /* 背景を透明に */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15; /* キャラアイコン(z-index:10)より上に表示 */
    pointer-events: none;
}
#game-status {
    display: none; /* 「あなたの番です」を非表示 */
}

.junban-display {
    margin-bottom: 10px;
    display: none;
}

.junban-image {
    max-width: 200px;
    max-height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

/* サイコロ表示（各プレイヤーの捨てハイ位置） */
.dice-player-inline {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* タップオーバーレイ(999)より上に表示 */
    pointer-events: none;
}

.dice-image-inline {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.8));
    animation: diceRoll 0.1s infinite;
}

.dice-image-static {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.8));
    animation: none !important;
    transform: rotate(0deg) !important;
}

@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
}

.deck-count-text {
    font-size: 32px;
    text-shadow: 1px 1px 1px black;
    background: rgba(0, 0, 0, 0.6); /* 半透明黒下地 */
    padding: 8px 16px;
    border-radius: 10px;
    display: inline-block;
}

/* プレイヤーエリア */
.player-area {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 18px;
    z-index: 2;
}
.player-area.active {
    background-color: rgba(255, 255, 0, 0.25);
    box-shadow: 0 0 20px yellow;
    border-radius: 8px;
}

.reach-stick {
    display: none;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid white;
    margin-left: 5px;
    animation: pulse 1s infinite alternate;
}
.player-area.reach .reach-stick { display: inline-block; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.1); } }

/* プレイヤー情報コンテナ */
.player-info-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 10;
}

/* 親アイコンをキャラアイコンの左下に配置するため、player-avatarを相対配置にする */
.player-info-container .player-avatar {
    position: relative;
}

/* プレイヤー名 */
.player-name {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
}

/* 親アイコン（PC版） */
.oya-icon {
    position: absolute;
    width: 3em; /* 1.5倍のサイズ */
    height: 3em; /* 1.5倍のサイズ */
    object-fit: contain;
    z-index: 11;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

/* 親アイコンをキャラアイコンの右上に配置（PC版：邪魔にならない位置） */
/* player-info-containerはposition: absoluteのまま、親アイコンをplayer-avatarの位置を基準に配置 */
.player-info-container .oya-icon {
    position: absolute;
    /* player-nameの上、キャラアイコンの右上に配置（点数に被らないように） */
    top: calc(20px + 5px - 0.5em); /* player-nameの上に配置 */
    right: -1.5em; /* キャラアイコンの右端からさらに右に移動（顔に被らないように） */
    left: auto;
    transform: translateX(0);
}

/* プレイヤー得点 */
.player-points {
    font-size: 28px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    white-space: nowrap; /* 改行を防ぐ */
    overflow: hidden; /* はみ出しを防ぐ */
    text-overflow: ellipsis; /* はみ出した場合は省略記号 */
    max-width: 100%; /* 親要素の幅を超えないように */
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: bold;
}

/* プレイヤーアバター */
.player-avatar {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid #f1c40f;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: none;
    transition: transform 0.3s ease;
}

/* 順番の人のキャラアイコンを拡縮アニメ */
.player-area.active .player-avatar {
    animation: playerTurnPulse 1s ease-in-out infinite;
}

@keyframes playerTurnPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* 各プレイヤーエリアでの情報コンテナ位置（テーブル中心寄りに配置、捨て牌ゾーンより内側） */
/* 捨て牌ゾーン: d-top(top:200px, height:150px), d-bottom(bottom:250px, height:150px), d-right(right:120px, width:140px), d-left(left:120px, width:140px) */
.p-top .player-info-container {
    top: 273.6px; /* 捨て牌ゾーン(top:200px + height:150px = 350px)より十分内側、さらに20%上に移動 */
    left: 50%;
    transform: translateX(-50%);
}

.p-bottom .player-info-container {
    bottom: 400px; /* 捨て牌ゾーン(bottom:250px + height:150px = 400px)より十分内側 */
    left: 50%;
    transform: translateX(-50%);
}

.p-right .player-info-container {
    top: 45%;
    right: 280px; /* 捨て牌ゾーン(right:120px + width:140px = 260px)より十分内側 */
    transform: translateY(-50%);
}

.p-left .player-info-container {
    top: 45%;
    left: 280px; /* 捨て牌ゾーン(left:120px + width:140px = 260px)より十分内側 */
    transform: translateY(-50%);
}

/* 配置調整 */
.p-bottom { 
    bottom: 50px; left: 50%; transform: translateX(-50%); 
    width: 95%; height: 180px; 
    flex-direction: column; justify-content: center;
}
.p-top { 
    top: 70px; left: 50%; transform: translateX(-50%); 
    width: 95%; height: 150px; 
    flex-direction: column-reverse; justify-content: flex-end;
}
.p-right { 
    top: 45%; right: 0; transform: translateY(-50%); 
    width: 90px; height: 60%; 
    flex-direction: column-reverse; 
}
.p-left { 
    top: 45%; left: 0; transform: translateY(-50%); 
    width: 90px; height: 60%; 
    flex-direction: column; 
}

.hand { display: flex; gap: 3px; align-items: center; justify-content: center; }
.p-right .hand, .p-left .hand { 
    flex-direction: column; 
    gap: 3px; 
    /* 回転後の牌が切れないように、幅を確保（回転後の高さ48px + 余白） */
    width: 70px;
    align-items: center;
    justify-content: flex-start;
}

/* 牌の基本スタイル */
.tile {
    width: 66px; height: 90px;
    background-color: #ecf0f1;
    color: #2c3e50;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid #bdc3c7;
    font-size: 24px;
    position: relative;
    transition: transform 0.1s;
    overflow: hidden;
}
.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}
.tile-name { 
    font-size: 13.5px; 
    font-weight: bold; 
    line-height: 1; 
    margin-top: -2px; 
    position: absolute;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    bottom: 2px;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 2px 3px;
    border-radius: 0 0 5px 5px;
}
.tile-point {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    padding: 1px 4px;
    border-radius: 3px;
    z-index: 5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* 自分の牌 */
.p-bottom .tile { cursor: pointer; width: 75px; height: 105px; font-size: 30px; }
.p-bottom .tile:hover { transform: translateY(-10px); }
.p-bottom .tile-name { font-size: 15px; }

/* セット (光るだけ) */
.tile.complete-set {
    background-color: #fff9c4;
    border-color: #fbc02d;
    box-shadow: 0 0 10px #ffeb3b;
    z-index: 10;
}

/* ツモ牌 (青色＆左に隙間) */
.tile.new { 
    background-color: #81d4fa; 
    border-color: #29b6f6;
    margin-left: 22.5px; 
}

/* 裏面 */
.tile-back {
    width: 48px; height: 66px;
    background: linear-gradient(135deg, #c0392b 50%, #e74c3c 50%);
    border-radius: 3px; border: 1px solid #922b21;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.tile-back.side { 
    /* 回転前のサイズ（縦長）を指定 */
    width: 48px; height: 66px; 
    box-sizing: border-box;
    /* 90度回転させて横長にする */
    transform: rotate(90deg);
    transform-origin: center center;
    /* 回転後のサイズ（66px x 48px）に合わせて背景画像を調整 */
    background-size: 48px 66px; /* 回転前のサイズで画像を設定 */
    background-position: center center;
    /* 回転後の視覚的な高さ（48px）に合わせて間隔を調整 */
    /* レイアウト上の高さ（66px）と視覚的な高さ（48px）の差（18px）を負のマージンで調整 */
    margin-top: -9px;
    margin-bottom: -9px;
    flex-shrink: 0;
}

/* 捨て牌エリア */
.discard-zone {
    position: absolute;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    background: transparent;
    padding: 6px;
    border-radius: 4px;
    align-content: center;
    justify-content: center;
    z-index: 2;
}
/* リーチ宣言牌は横向き */
.mini-tile { 
    font-size: 21px; 
    background: #ecf0f1; 
    width: 45px; 
    height: 58.5px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 2px; 
    color:#333;
    overflow: hidden;
}
.mini-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

/* ロン牌のスタイル（画面中央に表示） */
.ron-tile-center {
    border: 4px solid #ffeb3b;
    box-shadow: 
        0 0 20px #ffeb3b,
        0 0 40px #ff9800,
        0 0 60px #f44336,
        inset 0 0 20px rgba(255, 235, 59, 0.5);
    animation: ronPulse 0.5s ease-in-out infinite;
}

/* ロン牌の爆発エフェクト */
.ron-explosion::before,
.ron-explosion::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 235, 59, 0.8) 0%, rgba(255, 152, 0, 0.6) 30%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: ronExplosion 0.6s ease-out forwards;
    pointer-events: none;
    z-index: -1;
}

.ron-explosion::after {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 87, 34, 0.6) 0%, rgba(244, 67, 54, 0.4) 40%, transparent 70%);
    animation-delay: 0.1s;
    animation-duration: 0.8s;
}

@keyframes ronPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 0 20px #ffeb3b,
            0 0 40px #ff9800,
            0 0 60px #f44336,
            inset 0 0 20px rgba(255, 235, 59, 0.5);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 
            0 0 30px #ffeb3b,
            0 0 60px #ff9800,
            0 0 90px #f44336,
            inset 0 0 30px rgba(255, 235, 59, 0.7);
    }
}

@keyframes ronExplosion {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}
.mini-tile.reach-marker { 
    background: #e74c3c; 
    color: white; 
    margin: 0 11.25px; 
}

.d-bottom { bottom: 250px; left: 50%; transform: translateX(-50%); width: 480px; height: 150px; }
.d-top    { top: 144px; left: 50%; transform: translateX(-50%); width: 480px; height: 150px; flex-direction: row-reverse; }
.d-right  { right: 120px; top: 50%; transform: translateY(-50%); width: 140px; height: 400px; flex-direction: column-reverse; }
.d-left   { left: 120px; top: 45%; transform: translateY(-50%); width: 140px; height: 400px; flex-direction: column; }

/* 演出テキスト */
#msg-overlay {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 400;
    pointer-events: none;
    align-items: center;
    justify-content: center;
}
.pop-text {
    font-size: 70px; font-weight: 900;
    color: #ffeb3b;
    text-shadow: 4px 4px 0px #c0392b, -2px -2px 0 white;
    animation: zoomIn 0.5s ease-out forwards;
    white-space: pre-line;
    line-height: 1.4;
    max-width: 90vw;
    text-align: left;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.score-detail {
    font-size: 35px;
    font-weight: 600;
    color: #ffeb3b;
    text-shadow: 2px 2px 0px #c0392b, -1px -1px 0 white;
    margin-top: 10px;
    line-height: 1.3;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    border-radius: 5px;
}

/* モバイル版：得点計算ウィンドウを小さく */
@media screen and (orientation: portrait) and (max-width: 768px) {
    .pop-text {
        font-size: 24px !important;
        max-width: 85vw !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        padding: 15px !important;
    }
    
    .score-detail {
        font-size: 18px !important;
        padding: 8px 12px !important;
        margin-top: 8px !important;
    }
    
    .winner-character-icon {
        width: 40px !important;
        height: 40px !important;
    }
}

/* 勝ったキャラのアイコン表示 */
.winner-character-icons {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.winner-character-icon {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 2px solid #f1c40f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    object-fit: cover;
}
@keyframes zoomIn { 0% { transform: scale(0); opacity: 0; } 80% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* サイコロ画面 */
.dice-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dice-container {
    background: rgba(30, 30, 30, 0.95);
    border: 3px solid #f1c40f;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.dice-title {
    font-size: 32px;
    font-weight: bold;
    color: #f1c40f;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.dice-players {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

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

.dice-player-name {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.dice-result {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid #f1c40f;
}

.dice-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8));
}

.dice-instruction {
    font-size: 24px;
    color: #fff;
    text-align: center;
    margin-top: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* カットイン演出 */
.cutin-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1100; /* ロン牌(1000)より上に表示 */
    pointer-events: none;
    align-items: center;
    justify-content: center;
}

.cutin-base {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    overflow: hidden;
}

.cutin-base-img {
    width: 100%;
    height: 50%;
    object-fit: contain;
    object-position: center;
    animation: cutinFadeIn 0.3s ease-out forwards;
    opacity: 0.85;
    pointer-events: none;
}

.cutin-particles {
    position: absolute;
    /* 画面の中央に配置して、背景画像と位置を合わせる */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 50%; /* 背景画像と同じ高さ */
    overflow: hidden; /* この枠からハミ出たパーティクルは消す */
    pointer-events: none;
    z-index: 5;
    /* ベース画像と同じ画像をマスクとして使い、その形に切り抜きます */
    -webkit-mask-image: url('pict/cutin_base.webp');
    mask-image: url('pict/cutin_base.webp');
    /* マスクのサイズ合わせ（画像表示と同じ設定にする） */
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.cutin-particle {
    position: absolute;
    width: 120px;
    height: 120px;
    background-image: url('pict/cutin_particle.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: particleScroll 0.25s linear infinite;
    opacity: 0.9;
    /* 重なった部分を明るく発光させる */
    mix-blend-mode: screen;
}

.cutin-character {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 50%;
    z-index: 10;
    animation: characterSlideIn 0.5s ease-out 0.2s both;
}

.cutin-character-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.cutin-text {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    animation: textZoomIn 0.6s ease-out 0.4s both;
}

.cutin-text-img {
    width: auto;
    height: 30%;
    max-width: 100%;
    object-fit: contain;
}

/* 雷エフェクト */
.cutin-thunder {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 10%;
    z-index: 15;
    pointer-events: none;
    overflow: hidden;
}

.cutin-thunder-top {
    /* 位置とサイズはJavaScriptで動的に設定される */
    left: 50%;
}

.cutin-thunder-bottom {
    /* 位置とサイズはJavaScriptで動的に設定される */
    left: 50%;
}

.thunder-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 100% 100%; /* 1つの画像で幅いっぱいに表示 */
    background-repeat: no-repeat; /* 繰り返しなし */
    background-position: center;
    opacity: 0;
}

.thunder-frame-1 {
    background-image: url('pict/thunder01.webp');
    animation: thunderFrame1 0.2s steps(1) infinite;
}

.thunder-frame-2 {
    background-image: url('pict/thunder02.webp');
    animation: thunderFrame2 0.2s steps(1) infinite;
}

.thunder-frame-3 {
    background-image: url('pict/thunder03.webp');
    animation: thunderFrame3 0.2s steps(1) infinite;
}

.thunder-frame-4 {
    background-image: url('pict/thunder04.webp');
    animation: thunderFrame4 0.2s steps(1) infinite;
}

@keyframes thunderFrame1 {
    0%, 24.99% {
        opacity: 1;
    }
    25%, 100% {
        opacity: 0;
    }
}

@keyframes thunderFrame2 {
    0%, 24.99% {
        opacity: 0;
    }
    25%, 49.99% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

@keyframes thunderFrame3 {
    0%, 49.99% {
        opacity: 0;
    }
    50%, 74.99% {
        opacity: 1;
    }
    75%, 100% {
        opacity: 0;
    }
}

@keyframes thunderFrame4 {
    0%, 74.99% {
        opacity: 0;
    }
    75%, 100% {
        opacity: 1;
    }
}

@keyframes cutinFadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes particleScroll {
    0% {
        /* 左側の完全な外(-120%)からスタート */
        transform: translate(-120%, 0);
        opacity: 0;
    }
    10% {
        /* 入ってきたらすぐ表示 */
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        /* 右側の完全な外(120%)まで移動 */
        transform: translate(120%, 0);
        opacity: 0;
    }
}

@keyframes characterSlideIn {
    0% {
        transform: translate(-150%, -50%);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

@keyframes textZoomIn {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    80% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* オプションボタン */
.option-button {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    font-size: 24px;
    background: rgba(0,0,0,0.7);
    background-image: url('pict/setteiico.webp');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;
    border: 2px solid #555;
    border-radius: 50%;
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    overflow: hidden;
}

.option-button:hover {
    background-color: rgba(0,0,0,0.9);
    border-color: #777;
    transform: scale(1.1);
}

/* オプション画面 */
#sound-setup-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 700;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sound-setup-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border: 2px solid #555;
    border-radius: 15px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

#option-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 600;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.option-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border: 2px solid #555;
    border-radius: 15px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

#yaku-list-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

.yaku-list-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border: 2px solid #555;
    border-radius: 15px;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    position: relative;
}

#rule-explanation-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

.rule-explanation-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    border: 2px solid #555;
    border-radius: 15px;
    padding: 40px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

.rule-section {
    margin-bottom: 30px;
}

.rule-section h3 {
    font-size: 24px;
    color: #f1c40f;
    margin-bottom: 15px;
    border-bottom: 2px solid #526BFF;
    padding-bottom: 10px;
}

.rule-section p {
    margin-bottom: 10px;
    font-size: 16px;
    color: #ddd;
}

.rule-section ul {
    margin-left: 20px;
    margin-bottom: 15px;
    color: #ddd;
}

.rule-section li {
    margin-bottom: 8px;
    font-size: 16px;
}

.yaku-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.yaku-item-name {
    font-size: 20px;
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 8px;
}

.yaku-item-points {
    font-size: 18px;
    color: #2ecc71;
    margin-bottom: 8px;
}

.yaku-item-desc {
    font-size: 14px;
    color: #ddd;
    line-height: 1.6;
}

.option-section {
    margin-bottom: 20px;
}

.volume-control {
    margin-bottom: 15px;
}

.volume-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #444;
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f1c40f;
    cursor: pointer;
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f1c40f;
    cursor: pointer;
    border: none;
}

.option-btn {
    width: 100%;
    padding: 12px 25px;
    font-size: 18px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.option-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* リザルト画面 */
#result-screen {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 300;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
button { padding: 12px 25px; font-size: 18px; background: #e74c3c; color: white; border: none; border-radius: 5px; cursor: pointer; margin-top:20px; }
button:hover { background: #c0392b; }

/* =========================================
   スマホ・縦画面用レスポンシブ対応
   (既存のCSSの一番下に追加してください)
   ========================================= */
@media screen and (max-width: 768px) {
    
    /* 全体のコンテナ調整 */
    body {
        height: 100vh;
        height: 100dvh; /* モバイルブラウザのアドレスバー対策 */
        overflow: hidden;
        background-color: #1a1a1a;
    }

    /* -----------------------------
       タイトル・メニュー周り
       ----------------------------- */
    .title-logo {
        max-width: 90vw;
        top: 25% !important; /* 上に移動（元は50%） */
    }
    
    .title-content {
        justify-content: flex-end !important;
        padding-bottom: 10vh !important; /* ボトムにベタ付きすぎないように余白を追加 */
    }
    
    .title-btn {
        width: 80vw; /* ボタンを大きく */
        min-height: 60px;
    }

    .character-select-content,
    .option-content,
    .credits-content,
    .rule-explanation-content,
    .yaku-list-content {
        width: 95%;
        max-height: 85vh;
        padding: 20px;
    }

    .character-grid {
        grid-template-columns: repeat(3, 1fr); /* 3列表示に固定 */
        gap: 10px;
    }

    /* -----------------------------
       ゲーム画面 (卓) の調整
       ----------------------------- */
    .table-container {
        /* 幅は画面いっぱい、高さは比率に合わせて自動設定 */
        width: 100vw;
        height: auto; 
        
        /* スマホ縦画面では5:3の比率で画面を十分に使う */
        aspect-ratio: 3 / 5;
        
        /* 画面の縦幅を超えないように制限（念のため） */
        max-height: 100dvh;
        
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        
        /* 中央配置 */
        margin: auto; 
    }
    
    /* より縦長の画面（高さが800px以上）では6:3の比率 */
    @media screen and (orientation: portrait) and (min-height: 800px) {
        .table-container {
            /* より縦長の画面では6:3（2:1）の比率で画面を十分に使う */
            aspect-ratio: 3 / 6;
        }
    }

    /* 卓の表面（マット） */
    .table-container::before {
        top: 5px; bottom: 5px; left: 5px; right: 5px;
    }

    /* --- 中央エリア（ステータス・残り枚数） --- */
    .center-area {
        width: 40%;
        height: 15%;
        z-index: 25; /* スマホでもキャラアイコン(z-index:20)より上に表示 */
    }
    #game-status { font-size: 14px; }
    .deck-count-text { font-size: min(24px, 3vw) !important; }
    #deck-count { font-size: inherit !important; }
    
    /* サイコロ画面のモバイル対応 */
    .dice-container {
        padding: 20px;
        max-width: 95%;
    }
    
    .dice-title {
        font-size: min(28px, 5vw);
        margin-bottom: 20px;
    }
    
    .dice-players {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .dice-player-name {
        font-size: min(18px, 3.5vw);
    }
    
    .dice-result {
        width: min(100px, 20vw);
        height: min(100px, 20vw);
    }
    
    .dice-image {
        width: min(80px, 16vw);
        height: min(80px, 16vw);
    }
    
    .dice-instruction {
        font-size: min(20px, 4vw);
    }

    /* --- 捨て牌エリア (Discard Zones) --- */
    /* px指定だとスマホで崩れるため、%配置に変更して中央に寄せる */
    
    /* 自分（下）の捨て牌 */
    .d-bottom {
        bottom: 26%; /* 手牌のすぐ上 */
        width: 60%;
        height: 20%;
        flex-direction: row;
        left: 50%;
        transform: translateX(-50%);
        gap: 1px; /* 隙間を詰める */
    }

    /* 対面（上）の捨て牌 */
    .d-top {
        top: 18.72%;
        width: 60%;
        height: 20%;
        flex-direction: row-reverse; /* 右から左に並べる */
        left: 50%;
        transform: translateX(-50%);
        gap: 1px; /* 隙間を詰める */
    }

    /* 右CPUの捨て牌 */
    .d-right {
        right: 18%;
        top: 50%;
        width: 16%; /* 横幅を微調整して2列がきれいに収まるように */
        height: 40%;
        left: auto;
        transform: translateY(-50%);
        flex-direction: column-reverse; /* 下から上に並べる */
        
        /* 【重要】隙間制御 */
        gap: 0 !important; /* デスクトップのgapを無効化 */
        align-content: center; /* 垂直方向中央寄せ */
        justify-content: center; /* 水平方向中央寄せ */
    }

    /* 左CPUの捨て牌 */
    .d-left {
        left: 18%;
        top: 45%;
        width: 16%; /* 横幅を微調整 */
        height: 40%;
        transform: translateY(-50%);
        
        /* 【重要】隙間制御 */
        gap: 0 !important; /* デスクトップのgapを無効化 */
        align-content: center;
        justify-content: center;
    }
    
    /* 捨て牌のサイズ調整 - より小さくして重なりを防ぐ */
    .mini-tile {
        width: min(8vw, 35px); /* 画面幅に応じたサイズ、最大35px */
        height: min(10.5vw, 45px);
        font-size: 10px;
        /* デフォルトのマージンをリセット */
        margin: 0;
    }
    /* 回転している牌の位置微調整（ここがポイント） */
    .d-left .mini-tile, .d-right .mini-tile {
        /* 上下: 回転によって生まれる余白を打ち消して詰める
           左右: 隣の列と重ならないようにわずかに確保
        */
        margin: min(-1.8vw, -6px) 1px; 
    }
    
    /* 捨て牌エリアのサイズ調整 */
    .d-bottom, .d-top {
        width: min(480px, 90vw) !important;
        height: auto !important;
        min-height: 50px;
        max-height: 120px;
    }
    .d-left, .d-right {
        width: min(120px, 25vw) !important;
        height: auto !important;
        min-height: 100px;
        max-height: 300px;
    }

    /* --- プレイヤーエリア (Player Areas) --- */

    /* 共通: アバターと点数表示 */
    .player-info-container {
        transform: scale(0.7); /* 少し小さくして邪魔にならないように */
        z-index: 20;
    }
    .player-points { font-size: 20px; }
    .player-name { font-size: 14px; }
    
    /* キャラアイコンを画面サイズに応じて縮小（1.5倍のサイズ） */
    .player-avatar {
        width: min(120px, 12vw) !important;
        height: min(120px, 12vw) !important;
    }
    
    /* 順番表示のサイズ調整 */
    .junban-image {
        max-width: min(200px, 25vw) !important;
        max-height: min(60px, 8vw) !important;
    }
    
    /* 残り山札の文字サイズを画面サイズに応じて縮小 */
    .deck-count-text {
        font-size: min(32px, 4vw) !important;
    }

    /* 各プレイヤーの位置調整 */
    .p-top .player-info-container { top: 5px; }
    .p-bottom .player-info-container { bottom: 110px; /* 手牌の上 */ }
    .p-left .player-info-container { left: -10px; }
    .p-right .player-info-container { right: -10px; left: auto; }

    /* --- 手牌 (Hands) --- */

    /* 対面・左右の手牌（裏面） */
    .tile-back {
        width: 6vw; height: 8vw;
        background-size: cover;
    }
    .tile-back.side {
        width: 6vw; height: 8vw;
        background-size: 6vw 8vw;
        margin-top: -1vw; margin-bottom: -1vw;
    }
    
    /* 試合終了時にオープンされたCPU牌のサイズをゲーム中の手持ちと同じにする */
    .p-right .tile,
    .p-left .tile,
    .p-top .tile {
        width: 6vw !important;
        height: 8vw !important;
        font-size: min(12px, 1.5vw) !important;
    }
    
    .p-right .tile-name,
    .p-left .tile-name,
    .p-top .tile-name {
        font-size: min(8px, 1vw) !important;
    }
    
    /* CPU1とCPU3の牌の間隔を広げる（重なりを解消） */
    .p-right .hand,
    .p-left .hand {
        gap: 8px !important;
    }

    /* 左右の手牌位置 */
    .p-left { left: 2px; width: 40px; }
    .p-right { right: 2px; width: 40px; }
    .p-top { top: 5px; height: 60px; }

    /* ★重要：自分の手牌（操作エリア） */
    .p-bottom {
        bottom: 15px; /* 画面下から少し上に配置 */
        width: 100%;
        height: auto;
        padding-bottom: env(safe-area-inset-bottom, 20px); /* iPhoneの下部バー対策（セーフエリア対応） */
        background: rgba(0,0,0,0.5); /* 手牌が見やすいように背景追加 */
        z-index: 100;
    }

    .p-bottom .hand {
        gap: 2px;
        width: 100%;
        justify-content: center;
        padding: 0 10px; /* 左右の余白を確保 */
        box-sizing: border-box;
    }

    /* 自分の牌のサイズ（画面内に収まるように計算） */
    .p-bottom .tile {
        width: calc((100vw - 20px - 16px) / 9) !important;  /* 画面幅から左右の余白(20px)とgap(16px=2px*8)を引いて9で割る */
        max-width: 13vw; /* 最大でも13vwを超えない */
        height: calc((100vw - 20px - 16px) / 9 * 1.4) !important; /* 縦横比1.4:1 */
        max-height: 18vw; /* 最大でも18vwを超えない */
        font-size: 12px;
        flex-shrink: 0; /* 縮小しない */
    }
    
    .p-bottom .tile.new {
        margin-left: 10px; /* ツモ牌の間隔 */
    }
    
    .p-bottom .tile-name {
        font-size: 10px;
    }
    
    .p-bottom .tile-point {
        font-size: 10px;
        padding: 0 2px;
    }
    
    /* ホバーエフェクト（スマホではタップ時に少し動く程度に） */
    .p-bottom .tile:active {
        transform: translateY(-10px);
    }
    
    /* --- その他のUI調整 --- */
    
    /* リーチ棒 */
    .reach-stick {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* オプションボタン */
    .option-button {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
        background-size: contain;
        background-position: center;
        background-repeat: no-repeat;
    }
    
    /* ロン牌表示 */
    .ron-tile-center {
        width: 30vw !important;
        height: 40vw !important;
    }

    /* ポップアップテキスト */
    .pop-text {
        font-size: 40px;
    }
    
    /* リザルト画面 */
    #res-title { font-size: 32px !important; }
    #res-winner { font-size: 24px !important; }
    
    /* ロン選択ボタンを小さく（改行しない程度） */
    #ron-choice {
        max-width: 90vw !important;
    }
    
    #ron-choice > div:first-child {
        font-size: 20px !important;
        padding: 10px 20px !important;
        margin-bottom: 15px !important;
    }
    
    #ron-choice button {
        padding: 10px 20px !important;
        font-size: 16px !important;
        white-space: nowrap !important;
    }
    
    #ron-choice > div:last-child {
        gap: 10px !important;
    }
}

/* =========================================
   レスポンシブ対応：アイコン位置の再調整
   画面幅1024px以下（スマホ・ノートPC等）向け
   ========================================= */
@media screen and (max-width: 1024px) {
    
    /* コンテナ共通：位置リセットとサイズ縮小 */
    .player-info-container {
        position: absolute !important;
        margin: 0 !important;
        transform: scale(0.85) !important;
        z-index: 50 !important;
        width: auto !important;
        /* 以前の固定位置指定を解除 */
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
    }

    /* --- あなた (下) --- */
    /* 位置：画面左下（変更なし、余白のみ調整） */
    .p-bottom .player-info-container {
        bottom: max(140px, 18vh) !important; 
        left: 20px !important; /* 余白を20px確保 */
        align-items: flex-start !important;
    }
    .p-bottom .player-name, .p-bottom .player-points {
        text-align: left !important;
        margin-left: 5px;
    }

    /* --- CPU3 (左) --- */
    /* 位置：画面左上（変更なし、余白のみ調整） */
    .p-left .player-info-container {
        top: 20px !important; /* 余白を20px確保 */
        left: 20px !important; /* 余白を20px確保 */
        align-items: flex-start !important;
    }
    .p-left .player-name, .p-left .player-points {
        text-align: left !important;
        margin-left: 5px;
    }

    /* --- CPU2 (上) --- */
    /* 位置：自牌の右側 → 画面右上寄りへ移動 */
    .p-top .player-info-container {
        top: 20px !important;  /* 余白を20px確保 */
        right: 10% !important; /* 画面右から10%の位置（右上に寄せる） */
        align-items: flex-end !important;
        transform-origin: top right !important;
    }
    .p-top .player-name, .p-top .player-points {
        text-align: right !important;
        margin-right: 5px;
    }

    /* --- CPU1 (右) --- */
    /* 位置：自牌の下側 → 画面右下寄りへ移動（捨て牌より下） */
    .p-right .player-info-container {
        /* 捨て牌エリアより下に配置（より下に移動） */
        bottom: max(20px, 3vh) !important; 
        right: 20px !important; /* 余白を20px確保 */
        align-items: flex-end !important;
    }
    .p-right .player-name, .p-right .player-points {
        text-align: right !important;
        margin-right: 5px;
    }
    
    /* モバイル版：点数を大きく表示（見やすくする） */
    .player-points {
        font-size: min(24px, max(20px, 3vh)) !important;
    }
    
    /* モバイル版：親アイコンをキャラアイコンの右上に配置（点数に被らないように） */
    .player-info-container .oya-icon {
        position: absolute !important;
        width: 2em !important;
        height: 2em !important;
        top: calc(20px + 5px - 0.5em) !important; /* player-nameの上に配置 */
        right: -0.5em !important; /* キャラアイコンの右端から少し外側 */
        left: auto !important;
        transform: translateX(0) !important;
    }
}

/* --- タブレット横画面 (iPadなど) の調整 --- */
/* 画面幅が768px〜1600pxの横画面でプレイヤー情報を四隅に配置 */
@media screen and (min-width: 768px) and (max-width: 1600px) and (min-height: 600px) and (max-height: 1100px) {
    /* プレイヤー情報コンテナの位置を適切に設定 */
    .player-info-container {
        position: absolute !important;
        z-index: 50 !important;
    }
    
    /* あなた (下) - 左下に配置 */
    .p-bottom .player-info-container {
        bottom: 200px !important;
        left: 50px !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
    }
    
    /* CPU3 (左) - 左上に配置 */
    .p-left .player-info-container {
        top: 100px !important;
        left: 50px !important;
        bottom: auto !important;
        right: auto !important;
        transform: none !important;
    }
    
    /* CPU2 (上) - 右上に配置 */
    .p-top .player-info-container {
        top: 100px !important;
        right: 50px !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* CPU1 (右) - 右下に配置 */
    .p-right .player-info-container {
        bottom: 200px !important;
        right: 50px !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
    }
}

/* 横長画面（アスペクト比で判定） */
@media screen and (min-aspect-ratio: 4/3) and (max-width: 1600px) and (min-width: 800px) {
    /* あなた (下) - 左下に配置 */
    .p-bottom .player-info-container {
        bottom: 200px !important;
        left: 50px !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
    }
    
    /* CPU3 (左) - 左上に配置 */
    .p-left .player-info-container {
        top: 100px !important;
        left: 50px !important;
        bottom: auto !important;
        right: auto !important;
        transform: none !important;
    }
    
    /* CPU2 (上) - 右上に配置 */
    .p-top .player-info-container {
        top: 100px !important;
        right: 50px !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
    }
    
    /* CPU1 (右) - 右下に配置 */
    .p-right .player-info-container {
        bottom: 200px !important;
        right: 50px !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
    }
}

/* --- スマホ縦画面 (幅がさらに狭い時) の微調整 --- */
@media screen and (max-width: 768px) {
    .player-info-container {
        transform: scale(0.75) !important;
    }

    /* CPU2 (上) の位置調整：幅が狭いので少し右に寄せる */
    .p-top .player-info-container {
        right: 8% !important; 
    }

    /* CPU1 (右) の位置調整：捨て牌より下に配置（より下に移動） */
    .p-right .player-info-container {
        bottom: max(10px, 2vh) !important;
    }
    
    /* リーチ棒のサイズ調整 */
    .reach-stick {
        font-size: 10px !important;
        padding: 1px 3px !important;
    }
    
    /* モバイル版（768px以下）：点数をさらに大きく表示（見やすくする） */
    .player-points {
        font-size: min(22px, max(18px, 2.8vh)) !important;
    }
    
    /* モバイル版（768px以下）：親アイコンをキャラアイコンの右上に配置（点数に被らないように） */
    .player-info-container .oya-icon {
        position: absolute !important;
        width: 1.8em !important;
        height: 1.8em !important;
        top: calc(20px + 5px - 0.5em) !important; /* player-nameの上に配置 */
        right: -0.5em !important; /* キャラアイコンの右端から少し外側 */
        left: auto !important;
        transform: translateX(0) !important;
    }
}

/* 紙吹雪のアニメーション */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 301;
    overflow: hidden;
}

.confetti {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 10px;
    background: #f1c40f;
    opacity: 0;
    animation: confettiFall linear forwards;
}

.confetti:nth-child(2n) {
    background: #e74c3c;
    animation-duration: 3s;
}

.confetti:nth-child(3n) {
    background: #3498db;
    animation-duration: 4s;
}

.confetti:nth-child(4n) {
    background: #2ecc71;
    animation-duration: 3.5s;
}

.confetti:nth-child(5n) {
    background: #9b59b6;
    animation-duration: 4.5s;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    5% {
        opacity: 0.8;
    }
    95% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 順番表示アニメーション */
.rank-item {
    opacity: 0;
    transform: translateY(20px);
    animation: rankReveal 0.5s ease-out forwards;
}

@keyframes rankReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* トグルスイッチ */
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #f1c40f;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}