/* 1. 基本リセット */
* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'Yusei Magic', 'Helvetica Neue', Arial, sans-serif;
    background-color: #fdf5e6;
    background-image: radial-gradient(#e6c1c1 15%, transparent 16%), radial-gradient(#e6c1c1 15%, transparent 16%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    color: #333;
}

/* 2. メインレイアウト */
.main-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.jp-title {
    font-size: 1.8rem;
    color: #d32f2f;
    text-shadow: 2px 2px 0 #fff;
    margin: 0 0 20px 0;
    text-align: center;
    line-height: 1.3;
}

/* 3. ルーレット外枠 */
.roulette-decoration-ring {
    width: 95vmin;
    height: 95vmin;
    max-width: 640px;
    max-height: 640px;
    
    margin: 0 auto 30px auto;
    
    border: 5px solid #fff;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 60%, #ffd700 65%, #d32f2f 70%);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    
    aspect-ratio: 1 / 1;
}

.roulette-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#rouletteCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

.pointer {
    position: absolute;
    top: 50%;
    right: -15px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 20px 12px 0;
    border-color: transparent #333 transparent transparent;
    z-index: 20;
    filter: drop-shadow(2px 2px 0px rgba(255,255,255,0.8));
}

/* 4. 操作ボタン */
.controls {
    width: 100%;
    text-align: center;
    margin-bottom: 40px;
}

.btn-jp {
    font-family: 'Yusei Magic', sans-serif;
    font-size: 1.2rem;
    padding: 12px 30px;
    margin: 0 10px;
    border: 2px solid #fff;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: transform 0.1s;
}
.btn-jp:active { transform: translateY(2px); box-shadow: none; }
.btn-start { background-color: #d32f2f; color: white; }
.btn-stop { background-color: #333; color: white; }
.btn-stop:disabled { background-color: #aaa; cursor: not-allowed; }

/* 5. 管理者パネル */
.admin-footer {
    width: 100%;
    margin-top: auto;
    background: #f0f0f0;
    border-top: 1px solid #ccc;
}

details { width: 100%; }
details summary {
    padding: 15px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    color: #555;
    list-style: none;
    background: #e0e0e0;
    border-bottom: 1px solid #ccc;
}
details summary::-webkit-details-marker { display: none; }
.settings-content { padding: 15px; background: #fafafa; }

#itemsList {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.settings-grid-header { display: none; }

.input-group {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.input-group input {
    font-size: 1rem;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
}

.btn-small {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    margin-top: 5px;
}
.btn-reset { background: #ff9800; color: white; }
.btn-save { background: #4CAF50; color: white; margin-bottom: 10px; }
.input-group .btn-reset { background: #ff5252; margin: 0; }
.admin-buttons { display: flex; flex-direction: column; gap: 10px; }
.help-box { background: #e3f2fd; padding: 10px; border-radius: 5px; margin-bottom: 15px; font-size: 0.9rem; }
.help-list { padding-left: 20px; }

/* 6. モーダル (★修正箇所：絶対中央配置) */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(2px);
}
.modal-content {
    background: #fff;
    
    /* 画面のど真ん中に配置する最強の設定 */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    /* サイズ設定 */
    width: 90%;
    max-width: 400px;
    
    /* 横画面で高さが足りない時はスクロールさせる */
    max-height: 90vh; 
    overflow-y: auto;
    
    padding: 25px;
    border: 8px solid #d32f2f;
    border-radius: 20px;
    text-align: center;
    
    /* Marginはゼロにする */
    margin: 0;
}
.close {
    position: absolute;
    right: 15px; top: 5px;
    font-size: 30px;
    cursor: pointer;
    color: #aaa;
}
.result-amount {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 20px 0;
    border-bottom: 3px solid #ffd700;
    display: inline-block;
}

/* --- PC用レイアウト (600px以上) --- */
@media screen and (min-width: 601px) {
    .settings-grid-header { display: grid; }
    .input-group { display: grid; padding: 0; border: none; box-shadow: none; margin-bottom: 5px; background: none; }
    .input-group input { padding: 5px; font-size: 0.9rem; }
    .btn-small { width: auto; padding: 5px 15px; font-size: 0.8rem; margin: 0; }
    .input-group .btn-reset { width: auto; }
    
    .settings-grid-header, .input-group {
        gap: 5px; align-items: center;
    }
    .mode-normal { grid-template-columns: 40px 2fr 1fr 1fr 2fr 40px; }
    .mode-secret { grid-template-columns: 40px 2fr 1fr 1fr 1fr 2fr 40px; }
}