/* ========================================
   Roulette Wheel Plugin - Style v4.0
   モバイルファースト設計
   ======================================== */

/* ---- ベースリセット ---- */
#roulette-app *,
#roulette-app *::before,
#roulette-app *::after {
    box-sizing: border-box;
}

#roulette-app {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 12px;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Meiryo', sans-serif;
    color: #2d3748;
    /* タップ時のハイライトを消す */
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   タブ
   ======================================== */
.roulette-tabs {
    display: flex;
    gap: 3px;
    border-bottom: 2px solid #e2e8f0;
    margin: 0 -12px;        /* 左右余白をはみ出して全幅に */
    padding: 0 12px;
}
.roulette-tab {
    flex: 1;
    padding: 11px 4px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.78em;
    font-weight: bold;
    color: #718096;
    transition: background 0.15s, color 0.15s;
    /* スマホでテキスト選択されないように */
    user-select: none;
    -webkit-user-select: none;
    /* タップ領域を確保 */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}
.roulette-tab:hover  { background: #edf2f7; color: #4a5568; }
.roulette-tab.active {
    background: #fff;
    color: #2b6cb0;
    border-bottom: 2px solid #fff;
    margin-bottom: -2px;
}

.roulette-tab-content        { display: none; padding: 20px 0 0; }
.roulette-tab-content.active { display: block; }

/* ========================================
   ボタン共通
   ======================================== */
.roulette-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: bold;
    transition: transform 0.1s, background 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    /* タップ領域を最低44px確保 */
    min-height: 44px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.roulette-btn:active:not(:disabled) { transform: scale(0.95); }
.roulette-btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-start {
    background: linear-gradient(135deg,#48bb78,#38a169);
    color: #fff;
    font-size: 1.15em;
    padding: 16px 0;
    width: 140px;
}
.btn-start:hover:not(:disabled) { background: linear-gradient(135deg,#68d391,#48bb78); }

.btn-stop {
    background: linear-gradient(135deg,#fc8181,#e53e3e);
    color: #fff;
    font-size: 1.15em;
    padding: 16px 0;
    width: 140px;
}
.btn-stop:hover:not(:disabled) { background: linear-gradient(135deg,#feb2b2,#fc8181); }

.btn-add     { background: linear-gradient(135deg,#63b3ed,#3182ce); color:#fff; }
.btn-add:hover    { background: linear-gradient(135deg,#90cdf4,#63b3ed); }
.btn-equal   { background: linear-gradient(135deg,#b794f4,#805ad5); color:#fff; }
.btn-equal:hover  { background: linear-gradient(135deg,#d6bcfa,#b794f4); }
.btn-save    { background: linear-gradient(135deg,#68d391,#38a169); color:#fff; }
.btn-save:hover   { background: linear-gradient(135deg,#9ae6b4,#68d391); }
.btn-shuffle { background: linear-gradient(135deg,#f6ad55,#dd6b20); color:#fff; }
.btn-shuffle:hover { background: linear-gradient(135deg,#fbd38d,#f6ad55); }
.btn-danger  { background: linear-gradient(135deg,#fc8181,#e53e3e); color:#fff; }
.btn-danger:hover { background: linear-gradient(135deg,#feb2b2,#fc8181); }

/* 並び替えボタン */
.btn-move {
    background: none;
    border: 1px solid #cbd5e0;
    border-radius: 5px;
    color: #718096;
    font-size: 0.8em;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    min-height: 28px;
    min-width: 28px;
    transition: background 0.15s, color 0.15s;
    touch-action: manipulation;
}
.btn-move:hover:not(:disabled) { background: #edf2f7; color: #2d3748; }
.btn-move:disabled { opacity: 0.25; cursor: default; }
.move-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

/* ========================================
   ルーレット画面
   ======================================== */
.roulette-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* 回数表示 */
.roulette-spin-count {
    display: flex;
    align-items: baseline;
    gap: 4px;
    background: #ebf8ff;
    border: 2px solid #bee3f8;
    border-radius: 50px;
    padding: 5px 18px;
    font-weight: bold;
    color: #2b6cb0;
}
.spin-count-label { font-size: 0.82em; color: #4299e1; }
#spin-count-num {
    font-size: 1.9em;
    line-height: 1;
    color: #2b6cb0;
    transition: transform 0.15s ease, color 0.2s;
    display: inline-block;
}
#spin-count-num.bump { transform: scale(1.35); color: #e53e3e; }
.spin-count-unit { font-size: 0.88em; color: #4299e1; }

/* キャンバスラッパー */
.roulette-canvas-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* キャンバスはコンテナ幅に合わせて縮む */
#roulette-canvas {
    border-radius: 50%;
    box-shadow: 0 6px 28px rgba(0,0,0,0.18);
    width: min(420px, calc(100vw - 48px));
    height: min(420px, calc(100vw - 48px));
    display: block;
    touch-action: none;   /* スクロールより優先 */
}

.roulette-pointer {
    position: absolute;
    top: -13px;
    font-size: 36px;
    color: #e53e3e;
    text-shadow: 0 2px 6px rgba(0,0,0,0.28);
    pointer-events: none;
    z-index: 10;
}

/* ボタン行 */
.roulette-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
}

/* 結果バナー */
.roulette-result-banner {
    width: 100%;
    font-size: 1.4em;
    font-weight: bold;
    padding: 12px 16px;
    border-radius: 50px;
    border: 3px solid currentColor;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    text-align: center;
    transition: all 0.3s;
}
.roulette-result-banner.hidden { display: none; }

/* ========================================
   項目エディタ
   ======================================== */
.roulette-editor {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}
.editor-note {
    margin: 0 0 14px;
    font-size: 0.85em;
    color: #718096;
    line-height: 1.5;
}

#roulette-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

/* 項目1行 */
.roulette-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    flex-wrap: nowrap;
}

.roulette-item-row input[type="text"] {
    flex: 1;
    min-width: 0;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 8px 8px;
    font-size: 0.95em;
    /* iOSでズームしないよう16px以上 */
    font-size: max(0.95em, 16px);
}

.prob-label {
    font-size: 0.72em;
    color: #718096;
    white-space: nowrap;
    flex-shrink: 0;
}

.roulette-item-row input[type="number"] {
    width: 52px;
    flex-shrink: 0;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 8px 4px;
    font-size: max(0.9em, 16px);
    text-align: center;
}

.roulette-item-row input[type="color"] {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.btn-remove-item {
    background: none;
    border: none;
    color: #fc8181;
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    touch-action: manipulation;
}
.btn-remove-item:hover { color: #e53e3e; }

/* 追加行 */
.roulette-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.roulette-add-row input[type="text"] {
    flex: 1;
    min-width: 120px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: max(0.95em, 16px);
}
.roulette-add-row input[type="color"] {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

/* アクションボタン群 */
.roulette-prob-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.roulette-prob-actions .roulette-btn {
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.prob-help {
    margin: 0;
    font-size: 0.8em;
    color: #a0aec0;
    line-height: 1.5;
}

/* ========================================
   履歴
   ======================================== */
.roulette-history {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}
#roulette-history-list {
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 14px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 6px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95em;
    min-height: 44px;
}
.history-item:last-child { border-bottom: none; }
.history-num {
    font-size: 0.76em;
    font-weight: bold;
    color: #fff;
    background: #a0aec0;
    border-radius: 50px;
    padding: 2px 9px;
    white-space: nowrap;
    flex-shrink: 0;
}
.history-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.history-label { font-weight: bold; }
.no-history { color: #a0aec0; font-size: 0.88em; }

/* ========================================
   タブレット以上（600px〜）
   ======================================== */
@media (min-width: 600px) {
    #roulette-app { padding: 0 16px; }

    .roulette-tab { font-size: 0.88em; padding: 12px 8px; }

    .roulette-item-row input[type="text"]   { font-size: 0.95em; }
    .roulette-item-row input[type="number"] { width: 64px; font-size: 0.95em; }
    .roulette-add-row input[type="text"]    { font-size: 0.95em; }

    .roulette-prob-actions .roulette-btn { flex: none; }

    .btn-start, .btn-stop { width: 150px; }
}
