* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 28px;
    color: #667eea;
    margin: 0;
}

header h1 a {
    text-decoration: none;
    color: inherit;
}

header nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

main {
    padding: 40px 0;
    min-height: calc(100vh - 160px);
}

main .container {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

footer {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    text-align: center;
    padding: 20px 0;
}

footer .footer-links {
    margin-top: 10px;
    font-size: 14px;
}

footer .footer-links a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.3s;
}

footer .footer-links a:hover {
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #777;
    font-size: 14px;
}

.required {
    color: #ff4444;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-large {
    padding: 15px 30px;
    font-size: 18px;
}

.btn-small {
    padding: 5px 10px;
    font-size: 14px;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero h2 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #333;
}

.hero p {
    font-size: 18px;
    color: #666;
}

/* Campaign Form */
.campaign-form {
    max-width: 600px;
    margin: 0 auto;
}

.result-box {
    background: #e8f5e9;
    padding: 20px;
    border-radius: 10px;
    margin-top: 30px;
    border: 2px solid #4caf50;
}

.result-box h4 {
    color: #2e7d32;
    margin-bottom: 15px;
}

.result-box a {
    color: #1976d2;
    word-break: break-all;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background: #f5f5f5;
    font-weight: 600;
}

table tr:hover {
    background: #f9f9f9;
}

.kicked {
    color: #dc3545;
}

.active {
    color: #28a745;
}

/* Roulette Display - 全デバイス対応版 */
.roulette-display {
    margin: 20px 0;
    text-align: center;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.roulette-container {
    position: relative;
    display: inline-block;
    margin: 20px auto;
    overflow: visible !important;
    z-index: 1;
    /* デフォルトサイズ（PC） */
    width: 400px;
    height: 400px;
    touch-action: none; /* ピンチズーム無効 */
}

#rouletteCanvas,
#closedRouletteCanvas {
    border: 8px solid #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    background: transparent;
    display: block;
    position: relative;
    z-index: 1;
    touch-action: none; /* ピンチズーム無効 */
    /* 固定サイズ - JSで上書きされる */
    width: 100%;
    height: 100%;
}

/* ルーレット読み込み中表示 */
.roulette-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 50%;
    z-index: 100;
    border: 8px solid #ffd700;
    box-sizing: border-box;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

.roulette-loading.hidden {
    display: none;
}

.roulette-loading p {
    margin-top: 15px;
    font-size: 18px;
    color: #333;
    font-weight: bold;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e0e0e0;
    border-top: 6px solid #ffd700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ポインター（矢印）のスタイル */
.roulette-pointer {
    width: 0 !important;
    height: 0 !important;
    border-style: solid;
    border-width: 40px 20px 0 20px;
    border-color: #ff0000 transparent transparent transparent;
    position: absolute !important;
    z-index: 9999 !important;
    left: 50%;
    top: -25px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

#winnerDisplay {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    padding: 30px;
    border-radius: 15px;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#winnerDisplay h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#winnerName {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    line-height: 1.5;
}

#winnerName strong {
    display: block;
    font-size: 28px;
    margin-bottom: 5px;
}

.winner-animation {
    animation: bounceIn 0.6s ease;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-content textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Login Page */
.login-page {
    max-width: 400px;
    margin: 0 auto;
}

.login-form {
    margin-top: 30px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.back-link {
    text-align: center;
    margin-top: 20px;
}

.back-link a {
    color: #667eea;
}

/* Apply Page */
.apply-page {
    max-width: 600px;
    margin: 0 auto;
}

.account-info {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
}

.account-info p {
    margin: 5px 0;
}

/* Control Panel */
.control-panel {
    margin-bottom: 30px;
    text-align: center;
}

.control-panel button {
    margin: 0 10px;
}

/* Campaign URLs */
.campaign-urls {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.url-box {
    margin-bottom: 15px;
}

.url-box h4 {
    margin-bottom: 10px;
    color: #333;
}

.url-display {
    display: flex;
    gap: 10px;
    align-items: center;
}

.url-display input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    font-family: monospace;
}

.url-note {
    margin-top: 5px;
    font-size: 14px;
    color: #666;
}

/* Animations */
@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.spinning {
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    }
    to {
        box-shadow: 0 0 50px rgba(255, 215, 0, 1);
    }
}

/* Winners History */
.winners-history {
    margin-top: 30px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.winners-history h3 {
    margin-bottom: 15px;
    color: #333;
}

.winners-list {
    max-height: 400px;
    overflow-y: auto;
}

.winner-item {
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid #ffd700;
}

.winner-number {
    font-weight: bold;
    color: #667eea;
    min-width: 60px;
}

.winner-name {
    font-weight: bold;
    flex: 1;
}

.winner-screen {
    color: #666;
    font-size: 14px;
}

.winner-date {
    color: #999;
    font-size: 13px;
    margin-left: auto;
}

.no-winners {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* Closed Message */
.closed-message {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.closed-message h3 {
    margin-bottom: 10px;
}

/* Closed Badge */
.closed-badge {
    background: #dc3545;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    display: inline-block;
}

/* iOS Safari専用のスタイル */
@supports (-webkit-touch-callout: none) {
    #rouletteCanvas,
    #closedRouletteCanvas {
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
    }
}

/* タブレット (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .roulette-container {
        width: 450px;
        height: 450px;
    }

    .roulette-pointer {
        border-width: 45px 22px 0 22px;
        top: -28px;
    }
}

/* PC (1025px以上) */
@media (min-width: 1025px) {
    .roulette-container {
        width: 500px;
        height: 500px;
    }

    .roulette-pointer {
        border-width: 50px 25px 0 25px;
        top: -32px;
    }
}

/* スマートフォン横向き */
@media (max-width: 767px) and (orientation: landscape) {
    .roulette-container {
        width: min(280px, 50vh);
        height: min(280px, 50vh);
    }

    .roulette-pointer {
        border-width: 30px 15px 0 15px;
        top: -18px;
    }

    .roulette-display h3 {
        font-size: 16px;
        margin-bottom: 5px;
    }
}

/* スマートフォン縦向き (767px以下) */
@media (max-width: 767px) and (orientation: portrait) {
    .container {
        padding: 0 10px;
    }

    main .container {
        padding: 15px;
    }

    header h1 {
        font-size: 22px;
    }

    .hero h2 {
        font-size: 20px;
    }

    .roulette-container {
        width: min(320px, 85vw);
        height: min(320px, 85vw);
    }

    .roulette-pointer {
        border-width: 35px 17px 0 17px;
        top: -22px;
    }

    .roulette-display h3 {
        font-size: 18px;
    }

    #winnerDisplay {
        padding: 20px;
        margin-top: 20px;
    }

    #winnerDisplay h3 {
        font-size: 22px;
    }

    #winnerName {
        font-size: 18px;
    }

    #winnerName strong {
        font-size: 22px;
    }

    /* ボタンサイズ調整 */
    .control-panel {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .control-panel button {
        margin: 0;
        padding: 10px 15px;
        font-size: 14px;
    }

    /* テーブル横スクロール */
    .applicants-section,
    .winners-section {
        overflow-x: auto;
    }

    table {
        font-size: 12px;
        min-width: 500px;
    }

    table th,
    table td {
        padding: 6px 8px;
        white-space: nowrap;
    }
}

/* 小さいスマートフォン (375px以下) */
@media (max-width: 375px) {
    .roulette-container {
        width: min(280px, 90vw);
        height: min(280px, 90vw);
    }

    .roulette-pointer {
        border-width: 30px 15px 0 15px;
        top: -18px;
    }

    .control-panel button {
        padding: 8px 12px;
        font-size: 12px;
    }

    header h1 {
        font-size: 18px;
    }
}

/* Alert Messages */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 8px;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert strong {
    font-weight: 600;
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.auth-real {
    text-align: center;
    padding: 40px;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.button-group .btn {
    flex: 0 1 auto;
}

/* ===== Landing Page Styles ===== */

/* Landing Hero */
.landing-hero {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 20px;
    margin-bottom: 50px;
}

.hero-content h2 {
    font-size: 36px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

.hero-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.hero-cta {
    margin-top: 30px;
}

/* Section Title */
.section-title {
    text-align: center;
    font-size: 28px;
    color: #333;
    margin-bottom: 40px;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    margin: 15px auto 0;
    border-radius: 2px;
}

/* Features Section */
.features-section {
    margin-bottom: 60px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.feature-card {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.feature-icon {
    color: #667eea;
    margin-bottom: 20px;
}

.feature-card h4 {
    font-size: 20px;
    color: #333;
    margin-bottom: 15px;
}

.feature-card p {
    font-size: 14px;
    color: #666;
    line-height: 1.7;
}

/* How To Section */
.howto-section {
    margin-bottom: 60px;
}

.steps-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.step {
    background: #f8f9fa;
    padding: 30px 25px;
    border-radius: 15px;
    text-align: center;
    width: 250px;
    position: relative;
}

.step-number {
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    font-size: 24px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.step h4 {
    font-size: 18px;
    color: #333;
    margin-bottom: 12px;
}

.step p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.step-arrow {
    color: #667eea;
    display: flex;
    align-items: center;
}

/* Use Cases Section */
.usecases-section {
    margin-bottom: 60px;
}

.usecases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.usecase-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    font-size: 16px;
    color: #333;
    transition: transform 0.2s ease;
}

.usecase-item:hover {
    transform: translateX(5px);
}

.usecase-icon {
    font-size: 28px;
}

/* CTA Section */
.cta-section {
    text-align: center;
    padding: 50px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    color: white;
}

.cta-section h3 {
    font-size: 28px;
    margin-bottom: 15px;
}

.cta-section p {
    font-size: 16px;
    margin-bottom: 25px;
    opacity: 0.9;
}

.cta-section .btn-primary {
    background: white;
    color: #667eea;
}

.cta-section .btn-primary:hover {
    background: #f0f0f0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Landing Page Responsive */
@media (max-width: 767px) {
    .landing-hero {
        padding: 40px 15px;
    }

    .hero-content h2 {
        font-size: 24px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .section-title {
        font-size: 22px;
    }

    .steps-container {
        flex-direction: column;
    }

    .step {
        width: 100%;
        max-width: 300px;
    }

    .step-arrow {
        transform: rotate(90deg);
    }

    .cta-section {
        padding: 40px 20px;
    }

    .cta-section h3 {
        font-size: 22px;
    }
}

/* Create Page Styles */
.create-campaign-section {
    max-width: 600px;
    margin: 0 auto;
}

.create-campaign-section .campaign-form {
    background: #f8f9fa;
    padding: 40px;
    border-radius: 15px;
}

.create-campaign-section .btn-large {
    width: 100%;
    margin-top: 10px;
}