/* 基本スタイル */
* {
    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, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

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

/* ヘッダー */
header {
    text-align: center;
    padding: 30px 0;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

header h1 .accent {
    color: #38ef7d;
    text-shadow: 0 0 20px rgba(56, 239, 125, 0.5);
}

header .subtitle {
    color: #a0a0a0;
    font-size: 1rem;
}

/* カード */
.card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.card h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: #e0e0e0;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.2rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

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

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #fff;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(56, 239, 125, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ルーム情報 */
.room-info {
    text-align: center;
    margin-bottom: 30px;
}

.room-code-display {
    margin: 20px 0;
}

.room-code-display .label {
    display: block;
    color: #a0a0a0;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.room-code-display .code {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 8px;
    color: #38ef7d;
    text-shadow: 0 0 20px rgba(56, 239, 125, 0.5);
}

.qr-section {
    margin-top: 20px;
}

.join-url {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    font-family: monospace;
    word-break: break-all;
    font-size: 0.9rem;
}

/* ステータスバー */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 20px;
}

.status-bar .label {
    color: #a0a0a0;
}

.status-bar .status {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    background: #667eea;
}

.status-bar .status.active {
    background: #38ef7d;
    color: #1a1a2e;
    animation: pulse 1s infinite;
}

.status-bar .status.locked {
    background: #f5576c;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 参加者リストのスタイル調整 */
.participant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.participant-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.participant-name {
    font-weight: 600;
    margin-right: 5px;
}

.participant-actions {
    display: flex;
    gap: 5px;
}

.participant-actions .btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 12px;
    line-height: 1.2;
}

.btn-delete {
    background: rgba(245, 87, 108, 0.8);
    color: #fff;
}

.btn-delete:hover {
    background: rgba(245, 87, 108, 1);
}

/* QRコードコンテナの調整 */
.qr-code-container {
    margin-top: 0; /* モーダル内での余白調整 */
}

/* 点数リスト */
.scores-section {
    margin-bottom: 30px;
}

.scores-list {
    min-height: 100px;
}

.no-scores {
    text-align: center;
    color: #a0a0a0;
    padding: 30px;
}

.score-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 10px;
    gap: 15px;
}

.score-name {
    flex: 0 0 150px;
    font-size: 1rem;
    font-weight: 600;
}

.score-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.score-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    text-align: center;
}

.add-10-btn {
    min-width: 50px;
}

.score-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.score-display {
    flex: 0 0 80px;
    text-align: right;
    font-size: 1.2rem;
    font-weight: 700;
    color: #38ef7d;
}

/* コントロール */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

/* 結果表示 */
.results-section {
    margin-top: 30px;
}

.buzz-results {
    min-height: 100px;
}

.no-results {
    text-align: center;
    color: #a0a0a0;
    padding: 30px;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 10px;
}

.result-item.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.result-item.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.2) 0%, rgba(192, 192, 192, 0.1) 100%);
}

.result-item.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2) 0%, rgba(205, 127, 50, 0.1) 100%);
}

.result-rank {
    font-size: 1.5rem;
    font-weight: 700;
    width: 60px;
    text-align: center;
}

.result-name {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
}

.result-time {
    font-size: 1rem;
    color: #a0a0a0;
}

.tie-badge {
    background: #f093fb;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 10px;
}

/* セクションヘッダー */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
}

/* ルーム一覧 */
.room-list {
    min-height: 200px;
}

.room-list .loading,
.room-list .no-rooms {
    text-align: center;
    color: #a0a0a0;
    padding: 50px 20px;
    font-size: 1.1rem;
}

.room-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.room-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(102, 126, 234, 0.5);
    transform: translateX(5px);
}

.room-card-info {
    flex: 1;
}

.room-card-code {
    font-size: 1.8rem;
    font-weight: 700;
    color: #38ef7d;
    letter-spacing: 4px;
    margin-bottom: 8px;
}

.room-card-meta {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: #a0a0a0;
}

.room-card-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.room-card-status.waiting {
    background: rgba(102, 126, 234, 0.3);
    color: #667eea;
}

.room-card-status.active {
    background: rgba(56, 239, 125, 0.3);
    color: #38ef7d;
}

.room-card-status.locked {
    background: rgba(245, 87, 108, 0.3);
    color: #f5576c;
}

.room-card-actions {
    display: flex;
    gap: 10px;
}

.btn-danger {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: #fff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 65, 108, 0.4);
}

/* ルーム情報コンパクト表示 */
.room-info-compact {
    margin-bottom: 20px;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
}

.room-info-compact .room-code-display {
    margin: 0;
}

.room-info-compact .room-code-display .label {
    display: inline;
    margin-right: 10px;
}

.room-info-compact .room-code-display .code {
    display: inline;
    font-size: 1.5rem;
    letter-spacing: 4px;
}

.room-url-section {
    margin-top: 10px;
}

/* 折りたたみ可能なヘッダー */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

.toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* 参加者リスト（詳細画面用） */
.participant-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 10px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.participant-list.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
}

.participant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.participant-name {
    font-size: 1rem;
    font-weight: 500;
}

.btn-delete {
    padding: 8px 16px;
    font-size: 0.9rem;
    background: rgba(255, 65, 108, 0.2);
    color: #ff416c;
    border: 1px solid rgba(255, 65, 108, 0.3);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.btn-delete:hover {
    background: rgba(255, 65, 108, 0.3);
    border-color: rgba(255, 65, 108, 0.5);
}

.btn-delete:active {
    background: rgba(255, 65, 108, 0.4);
    transform: scale(0.98);
}

/* 操作エリア（PC時は.card内に表示されているかのようなスタイル） */
.control-area {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

/* 非表示 */
.hidden {
    display: none !important;
}

/* レスポンシブ（スマホ対応） */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        padding-bottom: 160px; /* 固定操作エリアの高さ分の余白 */
    }

    header {
        padding: 20px 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 15px;
    }

    /* ルーム詳細画面のカードには下部余白を追加 */
    #room-detail-section .card {
        padding-bottom: 20px;
        margin-bottom: 0;
    }

    /* スマホ時は操作エリアを下部に固定 */
    .control-area {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: linear-gradient(180deg, rgba(26, 26, 46, 0.98) 0%, rgba(22, 33, 62, 0.98) 100%) !important;
        backdrop-filter: blur(10px) !important;
        border-top: 2px solid rgba(102, 126, 234, 0.3);
        border-radius: 0 !important;
        padding: 10px !important;
        z-index: 1000 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        margin: 0 !important;
    }

    /* スマホ時はルーム情報をさらにコンパクトに */
    .room-info-compact {
        font-size: 0.9rem;
    }

    .room-info-compact .room-code-display .code {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .room-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .room-url-section {
        margin-top: 8px;
    }

    #copy-url-btn {
        width: 100%;
    }

    /* ステータスバーをコンパクトに */
    .control-area .status-bar {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        padding: 8px 10px !important;
        font-size: 0.75rem;
        background: rgba(0, 0, 0, 0.3);
        margin-bottom: 8px !important;
    }

    .control-area .status-bar .label {
        font-size: 0.7rem;
    }

    .control-area .status-bar .status {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .control-area .status-bar .btn-xs {
        padding: 2px 6px;
        font-size: 0.65rem;
    }

    /* コントロールボタンを横並びコンパクトに */
    .control-area .controls {
        flex-direction: row;
        gap: 6px;
        margin: 0 !important;
    }

    .control-area .controls .btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .control-area .controls .btn-large {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .control-area .controls .btn-secondary {
        flex: 0 0 auto;
        min-width: 80px;
    }

    /* 結果表示をコンパクトに */
    .result-item {
        padding: 8px;
        font-size: 0.85rem;
    }

    .result-rank {
        font-size: 1.1rem;
        width: 35px;
    }

    .result-name {
        font-size: 0.9rem;
    }

    .result-time {
        font-size: 0.8rem;
    }

    /* セクションの余白調整 */
    #room-detail-section .results-section,
    #room-detail-section .participants-section,
    #room-detail-section .scores-section {
        margin-bottom: 15px;
    }

    /* 最後のセクションには固定エリアと重ならないよう大きめの余白 */
    #room-detail-section .scores-section {
        margin-bottom: 20px;
    }

    /* 点数リストをコンパクトに */
    .score-item {
        flex-wrap: wrap;
        gap: 10px;
    }

    .score-name {
        flex: 0 0 100%;
    }

    .score-controls {
        flex: 1;
    }

    .score-display {
        flex: 0 0 auto;
    }

    /* 参加者一覧をコンパクトに */
    .participant-item {
        padding: 10px;
        font-size: 0.9rem;
    }

    /* セクションヘッダー */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .section-header h2 {
        text-align: center;
    }

    /* ルームカード */
    .room-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .room-card-code {
        font-size: 1.5rem;
        letter-spacing: 3px;
    }

    .room-card-meta {
        flex-direction: column;
        gap: 8px;
    }

    .room-card-actions {
        width: 100%;
    }

    .room-card-actions .btn {
        flex: 1;
    }

    /* モーダルをモバイル対応 */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* モーダルスタイル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1e1e30 0%, #2a2a40 100%);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    color: #fff;
}

.btn-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

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

.input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transition: border-color 0.3s ease;
}

.input:focus {
    outline: none;
    border-color: #667eea;
}

.input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* QRコードコンテナ */
.qr-code-container {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: center;
}

.qr-code-container.hidden {
    display: none;
}

.qr-code-container h4 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #e0e0e0;
}

#qr-code {
    display: inline-block;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 15px;
}

#qr-code img {
    display: block;
}

.qr-url {
    color: #a0a0a0;
    font-size: 0.9rem;
    margin-bottom: 15px;
    word-break: break-all;
}

/* セクションヘッダーインライン */
.section-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header-inline h3 {
    margin-bottom: 0;
    flex: 1;
}