/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.app-container {
    position: relative;
    width: 393px;
    height: 852px;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    border-radius: 40px;
    background: #000;
    box-shadow: 0 0 0 1px #1c1c1e;
}

/* Dynamic Island */
.dynamic-island {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    background: #1c1c1e;
    border-radius: 19px;
    z-index: 1000;
}

/* モバイルでDynamic Island非表示 */
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px) {
    .dynamic-island {
        display: none !important;
    }
}

/* 画面遷移 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    visibility: hidden;
}

.screen.active {
    opacity: 1 !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
    visibility: visible !important;
    z-index: 10 !important;
}

/* 撮影画面 */
#camera-screen {
    background: #000;
    border-radius: 25px;
    overflow: hidden;
    position: relative;
}

.camera-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 70px 20px 30px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    text-align: center;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.camera-viewfinder {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 0;
}

.camera-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #000;
    transform-origin: center;
}

/* カメラのリアルタイム感を演出 */
@keyframes subtle-movement {
    0%, 100% {
        transform: scale(1.02) translateX(0);
    }
    25% {
        transform: scale(1.025) translateX(0.5px);
    }
    50% {
        transform: scale(1.02) translateX(-0.5px);
    }
    75% {
        transform: scale(1.015) translateX(0.3px);
    }
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.focus-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    animation: focusPulse 2s infinite ease-in-out;
    pointer-events: none;
}

@keyframes focusPulse {
    0%, 100% { 
        opacity: 0.4;
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.02);
    }
}

.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 20px 60px;
    background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 60%, rgba(0,0,0,0) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.capture-button {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.capture-button:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.capture-button:active {
    transform: scale(0.95);
    transition: all 0.1s;
}

.capture-inner {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.capture-button:active .capture-inner {
    transform: scale(0.9);
}

.capture-text {
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.3;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* 発行中画面 */
#processing-screen {
    background: #000 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 60px 30px !important;
    border-radius: 40px !important;
    overflow: hidden !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

.processing-header {
    text-align: center;
    margin-bottom: 60px;
    position: relative;
    z-index: 20;
    width: 100%;
}

.processing-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #fff;
    letter-spacing: -0.3px;
}

.processing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    position: relative;
    z-index: 20;
    width: 100%;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    position: relative;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-left-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-steps {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.step {
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0.3;
    transition: all 0.3s ease;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.step.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.step.completed {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.07);
}

.step-icon {
    font-size: 18px;
    width: 32px;
    text-align: center;
}

.step-text {
    font-size: 14px;
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: rgba(255, 255, 255, 0.9);
}

/* 発行完了画面 */
#complete-screen {
    background: #000;
    padding: 60px 16px 16px;
    overflow: hidden;
    border-radius: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
}


.complete-header {
    text-align: center;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.complete-header h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
    color: #fff;
    letter-spacing: -0.3px;
}

.complete-subtitle {
    font-size: 11px;
    opacity: 0.6;
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: rgba(255, 255, 255, 0.5);
}

.complete-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    max-width: 340px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    flex: 1;
}

/* 投稿者情報 - 写真プレビューに統合 */
.photographer-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 6px 10px;
    border-radius: 6px;
}

.photographer-avatar {
    flex-shrink: 0;
}

.avatar-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.photographer-details {
    flex: 1;
    min-width: 0;
}

.photographer-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photographer-handle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.verification-badge {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #007AFF;
    color: #fff;
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 撮影場所情報 */
.location-info {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.location-info h3 {
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.6);
}

.location-map {
    display: flex;
    gap: 12px;
    align-items: center;
}

.map-container {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.map-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
}

.map-pin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    z-index: 2;
}

.location-details {
    flex: 1;
    min-width: 0;
}

.location-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-address {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-coords {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    letter-spacing: 0.2px;
}

.photo-preview {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 4px;
}

#photo-canvas {
    display: block;
    max-width: 120px;
    max-height: 120px;
    border-radius: 6px;
    filter: brightness(1.05) contrast(1.05) saturate(0.9);
}

.nft-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    text-transform: uppercase;
}

.camera-info,
.provenance-info,
.combined-info {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.camera-info h3,
.provenance-info h3,
.combined-info h3 {
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.6);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
}

.info-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.info-value {
    font-size: 11px;
    font-weight: 600;
    word-break: break-all;
    color: #fff;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    letter-spacing: 0.1px;
}

.complete-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
    margin-top: auto;
}

.action-button {
    padding: 10px 16px;
    border: none;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0px;
    background: #007AFF;
    color: #fff;
    flex: 1;
}

.action-button:hover {
    background: #0056CC;
    transform: translateY(-1px);
}

.action-button:active {
    transform: translateY(0);
    transition: all 0.1s;
}

.action-button.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.action-button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* レスポンシブ対応 */
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px) {
    body {
        padding: 0;
    }
    
    .app-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
    
    #camera-screen,
    #processing-screen,
    #complete-screen {
        border-radius: 0;
    }
    
    .app-title {
        font-size: 22px;
    }
    
    .capture-button {
        width: 76px;
        height: 76px;
    }
    
    .capture-inner {
        width: 56px;
        height: 56px;
    }
    
    /* 完了画面を一画面に収める */
    #complete-screen {
        padding: 30px 12px 12px;
    }
    
    .complete-header {
        margin-bottom: 8px;
    }
    
    .complete-header h2 {
        font-size: 18px;
        margin: 0;
    }
    
    .complete-subtitle {
        font-size: 12px;
        margin: 0;
    }
    
    .complete-content {
        max-width: 100%;
        gap: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    
    
    .photo-preview {
        padding: 6px;
        margin-bottom: 0;
        flex: 0 0 auto;
    }
    
    #photo-canvas {
        max-width: 120px;
        max-height: 120px;
    }
    
    .photographer-info {
        padding: 6px 8px;
    }
    
    .photographer-name {
        font-size: 12px;
        margin: 0;
    }
    
    .photographer-handle {
        font-size: 11px;
        margin: 0;
    }
    
    .avatar-circle {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .location-info {
        padding: 8px;
    }
    
    .location-info h3 {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .location-name {
        font-size: 12px;
        margin: 0;
    }
    
    .location-address {
        font-size: 11px;
        margin: 0;
    }
    
    .location-coords {
        font-size: 10px;
        margin: 0;
    }
    
    .map-container {
        width: 36px;
        height: 36px;
    }
    
    .map-pin {
        font-size: 14px;
    }
    
    .combined-info {
        padding: 8px;
        width: 100%;
    }
    
    .combined-info h3 {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .info-grid {
        gap: 4px;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .info-item {
        padding: 4px;
    }
    
    .info-label {
        font-size: 10px;
        line-height: 1.2;
    }
    
    .info-value {
        font-size: 11px;
        line-height: 1.3;
    }
    
    .complete-actions {
        gap: 8px;
        margin-top: 8px;
        width: 100%;
    }
    
    .action-button {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 18px;
    }
    
    .nft-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .verification-badge {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    
    .processing-steps {
        max-width: 100%;
    }
}

@media (min-width: 501px) {
    body {
        background: #111;
        padding: 20px;
    }
}

/* 完了画面の表示を確実にする */
#complete-screen.active {
    opacity: 1 !important;
    transform: translateX(0) !important;
    visibility: visible !important;
    z-index: 10 !important;
    display: flex !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Chrome対策用 */
@supports (-webkit-appearance:none) {
    @media (max-width: 480px) {
        .dynamic-island {
            display: none !important;
        }
    }
}

/* 完了画面の美しい背景を確実に表示 */
#complete-screen.active {
    animation: completeAnimation 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes completeAnimation {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 完了画面の特別なスタイル */
#complete-screen.active .complete-header h2 {
    animation: checkmarkBounce 0.5s ease-out 0.3s;
}

@keyframes checkmarkBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.1); }
    100% { transform: scale(1); }
}