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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
}

header h1 {
    font-size: 1.5rem;
}

main {
    display: flex;
    gap: 2rem;
    padding: 1rem;
}

.left-panel {
    flex: 2;
}

.right-panel {
    flex: 1;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    height: fit-content;
}

.image-upload-section h3,
.shop-registration h3,
.shop-list-section h3,
.frame-assignment h3,
.frame-settings h3,
.renumber-section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

#imageUpload {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border: 2px dashed #ddd;
    border-radius: 4px;
    width: 100%;
}

.map-container {
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #fafafa;
    position: relative;
    min-height: 400px;
    overflow: hidden;
}

#mapCanvas {
    cursor: crosshair;
    display: block;
}

.controls {
    margin: 1rem 0;
    display: flex;
    gap: 1rem;
}

.controls button {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
    background-color: #7f8fa6; /* 統一・やや低彩度 */
    color: #fff;
}

#addFrameBtn,
#selectFrameBtn,
#moveFrameBtn { background-color: #7f8fa6; color: #fff; }
#addFrameBtn:hover,
#selectFrameBtn:hover,
#moveFrameBtn:hover { background-color: #72839c; }
#addFrameBtn.active,
#selectFrameBtn.active,
#moveFrameBtn.active { background-color: #2d6cdf; /* 選択中は彩度↑ */ }

.frame-settings {
    margin: 2rem 0;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.frame-size-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#frameSizeSlider {
    flex: 1;
    max-width: 200px;
}

#frameSizeValue {
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.shop-dropdown {
    position: absolute;
    background: white;
    border: 2px solid #3498db;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    min-width: 180px;
    max-width: 250px;
    z-index: 1000;
    transform: translateX(-50%);
}

.shop-dropdown.hidden {
    display: none;
}

.shop-dropdown-header {
    font-weight: bold;
    margin-bottom: 0.5rem;
    text-align: center;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.shop-dropdown-item {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    margin: 2px 0;
}

.shop-dropdown-item:hover {
    background-color: #e8f4f8;
}

.shop-dropdown-item.remove {
    color: #e74c3c;
    border-top: 1px solid #eee;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

.shop-dropdown-item.remove:hover {
    background-color: #ffebee;
}

.renumber-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #ddd;
}

.renumber-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

#renumberDirection {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#renumberBtn {
    padding: 0.5rem 1rem;
    background-color: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#renumberBtn:hover {
    background-color: #8e44ad;
}

#resetAssignmentsBtn {
    padding: 0.5rem 1rem;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#resetAssignmentsBtn:hover {
    background-color: #c0392b;
}

#shopList {
    width: 100%;
    height: 120px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    resize: vertical;
    font-family: inherit;
}

#registerShopsBtn {
    width: 100%;
    padding: 0.75rem;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 2rem;
}

#registerShopsBtn:hover {
    background-color: #219a52;
}

.shop-list {
    margin-bottom: 2rem;
}

.shop-item {
    padding: 0.45rem; /* 約10%小さく */
    margin: 0.225rem 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-item.assigned {
    background-color: #f8f8f8;
    color: #666;
    opacity: 0.7;
}

.shop-number {
    background-color: #3498db;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.shop-item.assigned .shop-number {
    background-color: #95a5a6;
}

.shop-item.clickable { cursor: pointer; border-color: #2d6cdf; }
.shop-item.clickable:hover { background-color: #e8f1fe; border-color: #2d6cdf; }

.shop-item.selected-shop {
    background-color: #e0ebff;
    border-color: #2d6cdf;
    box-shadow: inset 3px 0 0 #2d6cdf;
}

.shop-item.selected-for-assignment {
    background-color: #fff3cd;
    border-color: #ffc107;
    box-shadow: inset 3px 0 0 #ffc107;
    animation: pulse-selected 1.5s infinite;
}

.shop-item.selected-frame-shop {
    background-color: #fff4e6;
    border-color: #fd7e14;
    box-shadow: inset 3px 0 0 #fd7e14;
    color: #fd7e14;
    font-weight: bold;
}

@keyframes pulse-selected {
    0%, 100% {
        background-color: #fff3cd;
    }
    50% {
        background-color: #ffecb5;
    }
}

/* 初期設定画面のスタイル */
.setup-screen {
    min-height: 100vh;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    flex-direction: column;
}

.setup-screen header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    color: #2c3e50;
    padding: 2rem;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
}

.header-import {
    position: absolute;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%);
}

.import-btn {
    padding: 0.6rem 1.2rem;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.import-btn:hover {
    background: #545b62;
}

.setup-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.setup-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin: 1rem 0;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.setup-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.setup-input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setup-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.day-setup {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.day-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.day-label:hover {
    background-color: #f8f9fa;
}

.day-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.image-preview {
    margin-top: 1rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.setup-actions {
    margin-top: 2rem;
    text-align: center;
}

.setup-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 0.5rem;
}

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

.setup-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.setup-btn.secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.setup-btn.secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.main-screen {
    display: none;
}

#selectedFrameInfo {
    padding: 1rem;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    color: #666;
}

.available-shops {
    max-height: 300px;
    overflow-y: auto;
}

.available-shop {
    padding: 0.75rem;
    margin: 0.25rem 0;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.available-shop:hover {
    background-color: #e8f4f8;
    border-color: #3498db;
}

.map-frame {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid #3498db;
    border-radius: 50%;
    background-color: rgba(52, 152, 219, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #2c3e50;
    font-size: 12px;
    transform: translate(-50%, -50%);
}

.map-frame.assigned {
    border-color: #27ae60;
    background-color: rgba(39, 174, 96, 0.3);
}

.map-frame.selected {
    border-color: #e74c3c;
    border-width: 4px;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.shop-name-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    white-space: nowrap;
    margin-top: 2px;
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
        gap: 1rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls button {
        width: 100%;
    }
    
    .renumber-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #renumberDirection,
    #renumberBtn {
        width: 100%;
    }
    
    .frame-size-control {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    #frameSizeSlider {
        max-width: none;
    }
}
