/**
 * ルーレットモジュール スタイル
 */

/* コンテナ */
.wts-roulette-container {
    max-width: 1200px;
    margin: 0 auto;
}

.wts-roulette-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

@media (min-width: 768px) {
    .wts-roulette-wrapper {
        grid-template-columns: 3fr 2fr;
    }
}

/* ルーレット本体 */
.wts-roulette-main {
    text-align: center;
}

.wts-roulette-canvas-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}

.wts-roulette-canvas {
    display: block;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s var(--wts-ease-bounce);
    image-rendering: crisp-edges; /* より鮮明な描画 */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

.wts-roulette-canvas:hover {
    transform: scale(1.02);
}

/* サイズバリエーション */
.wts-roulette-small .wts-roulette-canvas {
    width: 300px;
    height: 300px;
}

.wts-roulette-medium .wts-roulette-canvas {
    width: 400px;
    height: 400px;
}

.wts-roulette-large .wts-roulette-canvas {
    width: 500px;
    height: 500px;
}

.wts-roulette-xlarge .wts-roulette-canvas {
    width: 600px;
    height: 600px;
}

/* ポインター */
.wts-roulette-pointer {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 80px;
    z-index: 10;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
    animation: pointer-bounce 2s ease-in-out infinite;
}

@keyframes pointer-bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-10px); }
}

.wts-pointer-svg {
    width: 100%;
    height: 100%;
}

/* 中央のスピンボタン */
.wts-roulette-center-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: none; /* ボタン以外のクリックを透過 */
}

.wts-roulette-center-button .wts-spin-button {
    pointer-events: auto; /* ボタン自体はクリック可能 */
}

.wts-spin-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--wts-gradient-main);
    border: 4px solid white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s var(--wts-ease-bounce);
    position: relative;
    overflow: hidden;
}

.wts-spin-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    /* animation: spin-glow 3s linear infinite; */
}

@keyframes spin-glow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wts-spin-button:hover {
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
}

/* タッチデバイスではホバー効果を無効化 */
@media (hover: none) {
    .wts-spin-button:hover {
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    }
}

.wts-spin-button:active {
    transform: scale(0.95);
}

.wts-spin-button.spinning {
    animation: button-pulse 0.5s ease-in-out infinite;
    pointer-events: none;
}

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

/* 結果表示 */
.wts-roulette-result {
    margin-top: 40px;
    animation: result-appear 0.6s var(--wts-ease-bounce);
}

@keyframes result-appear {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    50% {
        transform: scale(1.1) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.wts-result-inner {
    background: var(--wts-gradient-gold);
    padding: 30px;
    border-radius: var(--wts-radius-lg);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.wts-result-inner::before {
    content: '🎉';
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 30px;
    animation: sparkle 2s infinite;
}

.wts-result-inner::after {
    content: '🎊';
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 30px;
    animation: sparkle 2s 0.5s infinite;
}

.wts-result-label {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.wts-result-text {
    font-size: 36px;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: result-text-glow 2s ease-in-out infinite;
}

@keyframes result-text-glow {
    0%, 100% { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); }
    50% { text-shadow: 0 0 20px rgba(255, 255, 255, 0.8); }
}

/* フォーム要素 */
.wts-form-group {
    margin-bottom: 20px;
}

.wts-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--wts-text-primary);
}

.wts-help-text {
    font-size: 12px;
    color: var(--wts-text-muted);
    font-weight: 400;
    margin-left: 8px;
}

/* モバイル向けカスタマイズパネルの改善 */
.wts-roulette-settings .wts-card {
    background: #ffffff !important;
    backdrop-filter: none;
    border: 1px solid #e5e7eb;
    transform: none !important;
    transition: none !important;
}

/* ホバー効果を完全に無効化 */
.wts-roulette-settings .wts-card:hover {
    transform: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
}

.wts-roulette-settings .wts-card:hover::before {
    opacity: 0 !important;
}

@media (max-width: 768px) {
    .wts-roulette-settings .wts-card {
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        padding: 16px;
    }
    
    .wts-roulette-settings .wts-heading {
        background: none;
        -webkit-text-fill-color: #1a202c;
        color: #1a202c;
        font-size: 18px;
        margin-bottom: 12px;
    }
}

.wts-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--wts-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: all 0.3s;
    font-family: inherit;
}

.wts-textarea:focus {
    outline: none;
    border-color: var(--wts-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.wts-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--wts-radius-sm);
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.wts-select:focus {
    outline: none;
    border-color: var(--wts-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* テーマセレクター */
.wts-theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.wts-theme-option {
    position: relative;
    cursor: pointer;
    text-align: center;
}

.wts-theme-option input {
    position: absolute;
    opacity: 0;
}

.wts-theme-preview {
    display: block;
    width: 100%;
    height: 40px;
    border-radius: var(--wts-radius-sm);
    margin-bottom: 5px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
}

.wts-theme-option input:checked + .wts-theme-preview {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--wts-primary);
    border-color: var(--wts-primary);
}

.wts-theme-option:hover .wts-theme-preview {
    border-color: transparent !important;
    transform: none !important;
}

.wts-theme-name {
    font-size: 12px;
    color: #374151;
    font-weight: 500;
}

/* モバイル向けのテーマセレクター改善 */
@media (max-width: 768px) {
    .wts-theme-selector {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .wts-theme-preview {
        height: 35px;
    }
    
    /* タッチデバイスでのパフォーマンス改善 */
    .wts-roulette-canvas {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* テーマプレビュー */
.wts-theme-rainbow { background: linear-gradient(90deg, #FF6B6B, #4ECDC4, #45B7D1, #FFA07A); }
.wts-theme-pastel { background: linear-gradient(90deg, #FFB3BA, #BAFFC9, #BAE1FF, #E8B4F5); }
.wts-theme-neon { background: linear-gradient(90deg, #FF006E, #FFBE0B, #3A86FF, #06FFB4); }
.wts-theme-gold { background: linear-gradient(90deg, #FFD700, #FFA500, #FF8C00, #FF6347); }
.wts-theme-ocean { background: linear-gradient(90deg, #0077BE, #00BFFF, #87CEEB, #20B2AA); }
.wts-theme-forest { background: linear-gradient(90deg, #228B22, #00FF00, #90EE90, #2E8B57); }
.wts-theme-sunset { background: linear-gradient(90deg, #FF6B35, #FFCC00, #C70039, #FFC300); }
.wts-theme-monochrome { background: linear-gradient(90deg, #2C3E50, #7F8C8D, #BDC3C7, #ECF0F1); }

/* チェックボックス */
.wts-checkbox-label {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    cursor: pointer;
}

.wts-checkbox {
    margin-right: 8px;
}

/* プリセットボタン */
.wts-preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.wts-preset-button {
    font-size: 14px;
    padding: 8px 20px;
}

/* 共有ボタン */
.wts-share-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.wts-share-buttons .wts-btn-small {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wts-share-buttons .wts-share-result[data-platform="twitter"] {
    background: #1DA1F2;
    color: white;
    border-color: #1a91da;
}

.wts-share-buttons .wts-copy-result {
    background: #6366f1;
    color: white;
    border-color: #4f46e5;
}

.wts-share-buttons .wts-btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 履歴 */
.wts-roulette-history {
    max-height: 300px;
    overflow-y: auto;
}

.wts-history-item {
    padding: 12px;
    border-radius: var(--wts-radius-sm);
    background: var(--wts-bg-light);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slide-in-left 0.3s var(--wts-ease-bounce);
}

@keyframes slide-in-left {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.wts-history-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--wts-gradient-main);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.wts-history-result {
    flex: 1;
    margin: 0 15px;
    font-weight: 500;
}

.wts-history-time {
    font-size: 12px;
    color: var(--wts-text-muted);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .wts-roulette-wrapper {
        grid-template-columns: 1fr;
    }
    
    /* Canvasサイズはmax-widthを使用してより柔軟に */
    .wts-roulette-canvas {
        max-width: 100%;
        height: auto;
    }
    
    .wts-roulette-small .wts-roulette-canvas,
    .wts-roulette-medium .wts-roulette-canvas {
        width: 280px;
        height: 280px;
        max-width: calc(100vw - 40px);
    }
    
    .wts-roulette-large .wts-roulette-canvas,
    .wts-roulette-xlarge .wts-roulette-canvas {
        width: 320px;
        height: 320px;
        max-width: calc(100vw - 40px);
    }
    
    .wts-spin-button {
        width: 70px;
        height: 70px;
        font-size: 14px;
        border: 3px solid white;
    }
    
    .wts-result-text {
        font-size: 28px;
    }
    
    /* モバイル向けフォーム要素の改善 */
    .wts-textarea {
        font-size: 16px; /* iOS のズーム防止 */
        padding: 14px;
    }
    
    .wts-select {
        font-size: 16px; /* iOS のズーム防止 */
        padding: 12px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23374151'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
        appearance: none;
    }
    
    /* タッチターゲットの拡大 */
    .wts-items-toolbar .wts-btn-small {
        min-height: 44px;
        padding: 10px 16px;
    }
    
    .wts-checkbox-label {
        padding: 8px 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .wts-checkbox {
        width: 20px;
        height: 20px;
    }
}

/* アニメーション無効化対応 */
@media (prefers-reduced-motion: reduce) {
    .wts-roulette-pointer,
    .wts-spin-button::before,
    .wts-result-inner::before,
    .wts-result-inner::after,
    .wts-result-text {
        animation: none !important;
    }
}

/* アイテムツールバーの改善 */
.wts-items-toolbar {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.wts-items-toolbar .wts-btn-small {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wts-items-toolbar .wts-btn-small:hover {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    transform: none !important;
}

.wts-items-toolbar .wts-btn-small:active {
    transform: scale(0.95);
}

.wts-items-toolbar .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* プリセットグリッドの改善 */
.wts-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.wts-preset-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.wts-preset-card:hover {
    background: #f9fafb !important;
    border-color: #e5e7eb !important;
    transform: none !important;
    box-shadow: none !important;
}

.wts-preset-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.wts-preset-name {
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

/* プリセット保存エリア */
.wts-preset-save-area {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.wts-save-preset {
    background: #6366f1;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wts-save-preset:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

.wts-save-preset .dashicons {
    font-size: 18px;
}

/* 訪問者プリセット */
.wts-visitor-presets {
    display: contents;
}

.wts-visitor-preset {
    position: relative;
    background: #fef3c7;
    border-color: #fbbf24;
}

.wts-visitor-preset .wts-preset-icon {
    color: #f59e0b;
}

.wts-delete-preset {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.wts-visitor-preset:hover .wts-delete-preset {
    opacity: 1;
}

/* 履歴リストの改善 */
.wts-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wts-history-list li {
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
}

.wts-history-list strong {
    color: #6366f1;
    margin-right: 8px;
}

.wts-history-list small {
    color: #6b7280;
    font-size: 12px;
    margin-left: 8px;
}

/* 代替お祝いアニメーション */
.wts-celebration-fallback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
}

.wts-celebration-emoji {
    position: absolute;
    font-size: 40px;
    animation: celebration-float 2s ease-out forwards;
}

.wts-celebration-emoji:nth-child(1) {
    left: -80px;
    animation-delay: 0s;
}

.wts-celebration-emoji:nth-child(2) {
    left: -40px;
    animation-delay: 0.2s;
}

.wts-celebration-emoji:nth-child(3) {
    left: 0;
    animation-delay: 0.4s;
}

.wts-celebration-emoji:nth-child(4) {
    left: 40px;
    animation-delay: 0.6s;
}

.wts-celebration-emoji:nth-child(5) {
    left: 80px;
    animation-delay: 0.8s;
}

@keyframes celebration-float {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-40px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.8);
    }
}